Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1159 lines
31 KiB

  1. /*++
  2. Copyright (c) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. dnslibp.h
  5. Abstract:
  6. Domain Name System (DNS) Library
  7. Private DNS Library Routines
  8. Author:
  9. Jim Gilroy (jamesg) December 7, 1996
  10. Revision History:
  11. --*/
  12. #ifndef _DNSLIBP_INCLUDED_
  13. #define _DNSLIBP_INCLUDED_
  14. #include <windns.h>
  15. #include <dnsapi.h>
  16. #include <dnslib.h>
  17. #ifdef __cplusplus
  18. extern "C"
  19. {
  20. #endif // __cplusplus
  21. // headers are screwed up
  22. // neither ntdef.h nor winnt.h brings in complete set, so depending
  23. // on whether you include nt.h or not you end up with different set
  24. #define MINCHAR 0x80
  25. #define MAXCHAR 0x7f
  26. #define MINSHORT 0x8000
  27. #define MAXSHORT 0x7fff
  28. #define MINLONG 0x80000000
  29. #define MAXLONG 0x7fffffff
  30. #define MAXBYTE 0xff
  31. #define MAXUCHAR 0xff
  32. #define MAXWORD 0xffff
  33. #define MAXUSHORT 0xffff
  34. #define MAXDWORD 0xffffffff
  35. #define MAXULONG 0xffffffff
  36. //
  37. // Handy bad ptr
  38. //
  39. #define DNS_BAD_PTR ((PVOID)(-1))
  40. //
  41. // "Wire" char set
  42. //
  43. // Explicitly create wire char set in case the ACE format
  44. // wins out.
  45. //
  46. #define DnsCharSetWire DnsCharSetUtf8
  47. //
  48. // Private DNS_RECORD Flag field structure definition and macros
  49. //
  50. typedef struct _PrivateRecordFlags
  51. {
  52. DWORD Section : 2;
  53. DWORD Delete : 1;
  54. DWORD CharSet : 2;
  55. DWORD Cached : 1; // or maybe a "Source" field
  56. DWORD HostsFile : 1;
  57. DWORD Cluster : 1;
  58. DWORD Unused : 3;
  59. DWORD Matched : 1;
  60. DWORD FreeData : 1;
  61. DWORD FreeOwner : 1;
  62. DWORD Reserved : 18;
  63. }
  64. PRIV_RR_FLAGS, *PPRIV_RR_FLAGS;
  65. #define RRFLAGS( pRecord ) ((PPRIV_RR_FLAGS)&pRecord->Flags.DW)
  66. // Defined in dnslib.h too late to pull now
  67. //#define FLAG_Section( pRecord ) (RRFLAGS( pRecord )->Section)
  68. //#define FLAG_Delete( pRecord ) (RRFLAGS( pRecord )->Delete)
  69. //#define FLAG_CharSet( pRecord ) (RRFLAGS( pRecord )->CharSet)
  70. //#define FLAG_FreeData( pRecord ) (RRFLAGS( pRecord )->FreeData)
  71. //#define FLAG_FreeOwner( pRecord ) (RRFLAGS( pRecord )->FreeOwner)
  72. //#define FLAG_Matched( pRecord ) (RRFLAGS( pRecord )->Matched)
  73. //#define FLAG_Cached( pRecord ) (RRFLAGS( pRecord )->Cached)
  74. #define FLAG_HostsFile( pRecord ) (RRFLAGS( pRecord )->HostsFile)
  75. #define FLAG_Cluster( pRecord ) (RRFLAGS( pRecord )->Cluster)
  76. //#define SET_FREE_OWNER(pRR) (FLAG_FreeOwner(pRR) = TRUE)
  77. //#define SET_FREE_DATA(pRR) (FLAG_FreeData(pRR) = TRUE)
  78. //#define SET_RR_MATCHED(pRR) (FLAG_Matched(pRR) = TRUE)
  79. #define SET_RR_HOSTS_FILE(pRR) (FLAG_HostsFile(pRR) = TRUE)
  80. #define SET_RR_CLUSTER(pRR) (FLAG_Cluster(pRR) = TRUE)
  81. //#define CLEAR_FREE_OWNER(pRR) (FLAG_FreeOwner(pRR) = FALSE)
  82. //#define CLEAR_FREE_DATA(pRR) (FLAG_FreeData(pRR) = FALSE)
  83. //#define CLEAR_RR_MATCHED(pRR) (FLAG_Matched(pRR) = FALSE)
  84. #define CLEAR_RR_HOSTS_FILE(pRR) (FLAG_HostsFile(pRR) = FALSE)
  85. //#define IS_FREE_OWNER(pRR) (FLAG_FreeOwner(pRR))
  86. //#define IS_FREE_DATA(pRR) (FLAG_FreeData(pRR))
  87. //#define IS_RR_MATCHED(pRR) (FLAG_Matched(pRR))
  88. #define IS_HOSTS_FILE_RR(pRR) (FLAG_HostsFile(pRR))
  89. #define IS_CLUSTER_RR(pRR) (FLAG_Cluster(pRR))
  90. //#define IS_ANSWER_RR(pRR) (FLAG_Section(pRR) == DNSREC_ANSWER)
  91. //#define IS_AUTHORITY_RR(pRR) (FLAG_Section(pRR) == DNSREC_AUTHORITY)
  92. //#define IS_ADDITIONAL_RR(pRR) (FLAG_Section(pRR) == DNSREC_ADDITIONAL)
  93. //
  94. // Address family info (addr.c)
  95. //
  96. typedef struct _AddrFamilyInfo
  97. {
  98. WORD Family;
  99. WORD DnsType;
  100. DWORD LengthAddr;
  101. DWORD LengthSockaddr;
  102. DWORD OffsetToAddrInSockaddr;
  103. }
  104. FAMILY_INFO, *PFAMILY_INFO;
  105. extern FAMILY_INFO AddrFamilyTable[];
  106. #define FamilyInfoIp4 (AddrFamilyTable[0])
  107. #define FamilyInfoIp6 (AddrFamilyTable[1])
  108. #define FamilyInfoAtm (AddrFamilyTable[2])
  109. #define pFamilyInfoIp4 (&AddrFamilyTable[0])
  110. #define pFamilyInfoIp6 (&AddrFamilyTable[1])
  111. #define pFamilyInfoAtm (&AddrFamilyTable[2])
  112. PFAMILY_INFO
  113. FamilyInfo_GetForFamily(
  114. IN DWORD Family
  115. );
  116. #define FamilyInfo_GetForSockaddr(pSA) \
  117. FamilyInfo_GetForFamily( (pSA)->sa_family )
  118. //
  119. // IP Union
  120. //
  121. // DCR: probably should have just used sockaddr here
  122. //
  123. // Advantages over sockaddr_in6
  124. // - bool test
  125. // - addresses pointers start in the same place for both
  126. // types
  127. // - size
  128. // - no munging (sockaddr_in6) needs casting to get back to IP4
  129. // alternatively regular sockaddr is not fixed size
  130. //
  131. // If keep this type should make it available for all address
  132. // operations including local IP, in which case should include
  133. // flag field for cluster, weird info.
  134. //
  135. typedef struct _DnsIpUnion
  136. {
  137. BOOL IsIp6;
  138. union
  139. {
  140. IP4_ADDRESS Ip4;
  141. IP6_ADDRESS Ip6;
  142. }
  143. Addr;
  144. }
  145. IP_UNION, *PIP_UNION;
  146. #define IPUNION_IS_IP4( p ) (!(p)->IsIp6)
  147. #define IPUNION_IS_IP6( p ) ((p)->IsIp6)
  148. #define IPUNION_IP4_PTR( p ) (&(p)->Addr.Ip4)
  149. #define IPUNION_IP6_PTR( p ) (&(p)->Addr.Ip6)
  150. #define IPUNION_GET_IP4( p ) ((p)->Addr.Ip4)
  151. #define IPUNION_GET_IP6( p ) ((p)->Addr.Ip6)
  152. #define IPUNION_SET_IP4( p, ip4 ) \
  153. { \
  154. PIP_UNION pip = (p); \
  155. pip->IsIp6 = FALSE; \
  156. pip->Addr.Ip4 = (ip4); \
  157. }
  158. #define IPUNION_SET_IP6( p, ip6 ) \
  159. { \
  160. PIP_UNION pip = (p); \
  161. pip->IsIp6 = TRUE; \
  162. pip->Addr.Ip6 = (ip6); \
  163. }
  164. //
  165. // Address manipulation (addr.c)
  166. //
  167. BOOL
  168. Dns_EqualIpUnion(
  169. IN PIP_UNION pIp1,
  170. IN PIP_UNION pIp2
  171. );
  172. BOOL
  173. Dns_SockaddrToIpUnion(
  174. OUT PIP_UNION pIpUnion,
  175. IN PSOCKADDR pSockaddr
  176. );
  177. IP6_ADDRESS
  178. Ip6AddressFromSockaddr(
  179. IN PSOCKADDR pSockaddr
  180. );
  181. VOID
  182. InitSockaddrWithIp6Address(
  183. OUT PSOCKADDR pSockaddr,
  184. IN IP6_ADDRESS Ip6Addr,
  185. IN WORD Port
  186. );
  187. DNS_STATUS
  188. Dns_AddressToSockaddr(
  189. OUT PSOCKADDR pSockaddr,
  190. IN OUT PDWORD pSockaddrLength,
  191. IN BOOL fClearSockaddr,
  192. IN PBYTE pAddr,
  193. IN DWORD AddrLength,
  194. IN DWORD AddrFamily
  195. );
  196. DWORD
  197. Family_SockaddrLength(
  198. IN WORD Family
  199. );
  200. DWORD
  201. Sockaddr_Length(
  202. IN PSOCKADDR pSockaddr
  203. );
  204. //
  205. // String to address conversion (straddr.c)
  206. //
  207. // Most of the routines are public. These ones handle
  208. // non-NULL terminated strings for DNS server file load.
  209. //
  210. BOOL
  211. Dns_Ip4StringToAddressEx_A(
  212. OUT PIP4_ADDRESS pIp4Addr,
  213. IN PCSTR pchString,
  214. IN DWORD StringLength
  215. );
  216. BOOL
  217. Dns_Ip6StringToAddressEx_A(
  218. OUT PIP6_ADDRESS pIp6Addr,
  219. IN PCSTR pchString,
  220. IN DWORD StringLength
  221. );
  222. //
  223. // RPC-able type (record.c)
  224. //
  225. BOOL
  226. Dns_IsRpcRecordType(
  227. IN WORD wType
  228. );
  229. //
  230. // Record copy (rrcopy.c)
  231. //
  232. PDNS_RECORD
  233. WINAPI
  234. Dns_RecordCopy_W(
  235. IN PDNS_RECORD pRecord
  236. );
  237. PDNS_RECORD
  238. WINAPI
  239. Dns_RecordCopy_A(
  240. IN PDNS_RECORD pRecord
  241. );
  242. PDNS_RECORD
  243. Dns_RecordListCopyEx(
  244. IN PDNS_RECORD pRR,
  245. IN DWORD ScreenFlag,
  246. IN DNS_CHARSET CharSetIn,
  247. IN DNS_CHARSET CharSetOut
  248. );
  249. //
  250. // Record list routines (rrlist.c)
  251. //
  252. //
  253. // Record screening (rrlist.c)
  254. //
  255. #define SCREEN_OUT_ANSWER (0x00000001)
  256. #define SCREEN_OUT_AUTHORITY (0x00000010)
  257. #define SCREEN_OUT_ADDITIONAL (0x00000100)
  258. #define SCREEN_OUT_NON_RPC (0x00100000)
  259. #define SCREEN_OUT_SECTION \
  260. (SCREEN_OUT_ANSWER | SCREEN_OUT_AUTHORITY | SCREEN_OUT_ADDITIONAL)
  261. BOOL
  262. Dns_ScreenRecord(
  263. IN PDNS_RECORD pRR,
  264. IN DWORD ScreenFlag
  265. );
  266. PDNS_RECORD
  267. Dns_RecordListScreen(
  268. IN PDNS_RECORD pRR,
  269. IN DWORD ScreenFlag
  270. );
  271. DWORD
  272. Dns_RecordListGetMinimumTtl(
  273. IN PDNS_RECORD pRRList
  274. );
  275. //
  276. // New free
  277. // DCR: switch to dnslib.h when world builds clean
  278. //
  279. #undef Dns_RecordListFree
  280. VOID
  281. WINAPI
  282. Dns_RecordListFree(
  283. IN OUT PDNS_RECORD pRRList
  284. );
  285. //
  286. // String (string.c)
  287. //
  288. DWORD
  289. MultiSz_Length_A(
  290. IN PCSTR pmszString
  291. );
  292. PSTR
  293. MultiSz_NextString_A(
  294. IN PCSTR pmszString
  295. );
  296. PSTR
  297. MultiSz_Copy_A(
  298. IN PCSTR pmszString
  299. );
  300. //
  301. // Name utilities (name.c)
  302. //
  303. DWORD
  304. Dns_MakeCanonicalNameW(
  305. OUT PWSTR pBuffer,
  306. IN DWORD BufLength,
  307. IN PWSTR pwsString,
  308. IN DWORD StringLength
  309. );
  310. DWORD
  311. Dns_MakeCanonicalNameInPlaceW(
  312. IN PWCHAR pwString,
  313. IN DWORD StringLength
  314. );
  315. //
  316. // Name checking -- server name checking levels
  317. //
  318. #define DNS_ALLOW_RFC_NAMES_ONLY (0)
  319. #define DNS_ALLOW_NONRFC_NAMES (1)
  320. #define DNS_ALLOW_MULTIBYTE_NAMES (2)
  321. #define DNS_ALLOW_ALL_NAMES (3)
  322. INT
  323. Dns_DowncaseNameLabel(
  324. OUT PCHAR pchResult,
  325. IN PCHAR pchLabel,
  326. IN DWORD cchLabel,
  327. IN DWORD dwFlags
  328. );
  329. PSTR
  330. Dns_NameAppend_A(
  331. OUT PCHAR pNameBuffer,
  332. IN DWORD BufferLength,
  333. IN PSTR pszName,
  334. IN PSTR pszDomain
  335. );
  336. PWSTR
  337. Dns_NameAppend_W(
  338. OUT PWCHAR pNameBuffer,
  339. IN DWORD BufferLength,
  340. IN PWSTR pwsName,
  341. IN PWSTR pwsDomain
  342. );
  343. PSTR
  344. Dns_SplitHostFromDomainName_A(
  345. IN PSTR pszName
  346. );
  347. BOOL
  348. _fastcall
  349. Dns_IsNameNumeric_A(
  350. IN PCSTR pszName
  351. );
  352. DWORD
  353. Dns_NameCopyWireToUnicode(
  354. OUT PWCHAR pBufferUnicode,
  355. IN PCSTR pszNameWire
  356. );
  357. DWORD
  358. Dns_NameCopyUnicodeToWire(
  359. OUT PCHAR pBufferWire,
  360. IN PCWSTR pwsNameUnicode
  361. );
  362. DWORD
  363. Dns_NameCopyStandard_W(
  364. OUT PWCHAR pBuffer,
  365. IN PCWSTR pwsNameUnicode
  366. );
  367. DWORD
  368. Dns_NameCopyStandard_A(
  369. OUT PCHAR pBuffer,
  370. IN PCSTR pszName
  371. );
  372. //
  373. // Sting to address (straddr.c)
  374. //
  375. // Need for hostent routine which doesn unicode\ANSI.
  376. //
  377. BOOL
  378. Dns_StringToAddressEx(
  379. OUT PCHAR pAddrBuf,
  380. IN OUT PDWORD pBufLength,
  381. IN PCSTR pString,
  382. IN OUT PDWORD pAddrFamily,
  383. IN BOOL fUnicode,
  384. IN BOOL fReverse
  385. );
  386. //
  387. // Special record creation (rralloc.c)
  388. //
  389. PDNS_RECORD
  390. Dns_CreateFlatRecord(
  391. IN PDNS_NAME pOwnerName,
  392. IN WORD wType,
  393. IN PCHAR pData,
  394. IN DWORD DataLength,
  395. IN DWORD Ttl,
  396. IN DNS_CHARSET NameCharSet,
  397. IN DNS_CHARSET RecordCharSet
  398. );
  399. PDNS_RECORD
  400. Dns_CreatePtrTypeRecord(
  401. IN PDNS_NAME pOwnerName,
  402. IN BOOL fCopyName,
  403. IN PDNS_NAME pTargetName,
  404. IN WORD wType,
  405. IN DWORD Ttl,
  406. IN DNS_CHARSET NameCharSet,
  407. IN DNS_CHARSET RecordCharSet
  408. );
  409. PDNS_RECORD
  410. Dns_CreatePtrRecordEx(
  411. IN PIP_UNION pIp,
  412. IN PDNS_NAME pszHostName,
  413. IN DWORD Ttl,
  414. IN DNS_CHARSET NameCharSet,
  415. IN DNS_CHARSET RecordCharSet
  416. );
  417. PDNS_RECORD
  418. Dns_CreatePtrRecordExEx(
  419. IN PIP_UNION pIp,
  420. IN PSTR pszHostName,
  421. IN PSTR pszDomainName,
  422. IN DWORD Ttl,
  423. IN DNS_CHARSET NameCharSet,
  424. IN DNS_CHARSET RecordCharSet
  425. );
  426. PDNS_RECORD
  427. Dns_CreateARecord(
  428. IN PDNS_NAME pOwnerName,
  429. IN IP_ADDRESS IpAddress,
  430. IN DWORD Ttl,
  431. IN DNS_CHARSET NameCharSet,
  432. IN DNS_CHARSET RecordCharSet
  433. );
  434. PDNS_RECORD
  435. Dns_CreateAAAARecord(
  436. IN PDNS_NAME pOwnerName,
  437. IN IP6_ADDRESS Ip6Address,
  438. IN DWORD Ttl,
  439. IN DNS_CHARSET NameCharSet,
  440. IN DNS_CHARSET RecordCharSet
  441. );
  442. PDNS_RECORD
  443. Dns_CreateForwardRecord(
  444. IN PDNS_NAME pOwnerName,
  445. IN PIP_UNION pIp,
  446. IN DWORD Ttl,
  447. IN DNS_CHARSET NameCharSet,
  448. IN DNS_CHARSET RecordCharSet
  449. );
  450. PDNS_RECORD
  451. Dns_CreateForwardRecordFromSockaddr(
  452. IN PDNS_NAME pOwnerName,
  453. IN PSOCKADDR pSockaddr,
  454. IN DWORD Ttl,
  455. IN DNS_CHARSET NameCharSet,
  456. IN DNS_CHARSET RecordCharSet
  457. );
  458. PDNS_RECORD
  459. Dns_CreateRecordForIpString_W(
  460. IN PCWSTR pwsName,
  461. IN WORD wType,
  462. IN DWORD Ttl
  463. );
  464. //
  465. // Security stuff (security.c)
  466. //
  467. #define SECURITY_WIN32
  468. #include <sspi.h>
  469. #define DNS_SPN_SERVICE_CLASS "DNS"
  470. #define DNS_SPN_SERVICE_CLASS_W L"DNS"
  471. //
  472. // Some useful stats
  473. //
  474. extern DWORD SecContextCreate;
  475. extern DWORD SecContextFree;
  476. extern DWORD SecContextQueue;
  477. extern DWORD SecContextQueueInNego;
  478. extern DWORD SecContextDequeue;
  479. extern DWORD SecContextTimeout;
  480. extern DWORD SecPackAlloc;
  481. extern DWORD SecPackFree;
  482. // Security packet verifications
  483. extern DWORD SecTkeyInvalid;
  484. extern DWORD SecTkeyBadTime;
  485. extern DWORD SecTsigFormerr;
  486. extern DWORD SecTsigEcho;
  487. extern DWORD SecTsigBadKey;
  488. extern DWORD SecTsigVerifySuccess;
  489. extern DWORD SecTsigVerifyOldSig;
  490. extern DWORD SecTsigVerifyFailed;
  491. // Hacks
  492. // Allowing old TSIG off by default, server can turn on.
  493. // Big Time skew on by default
  494. extern BOOL SecAllowOldTsig;
  495. extern DWORD SecTsigVerifyOldSig;
  496. extern DWORD SecTsigVerifyOldFailed;
  497. extern DWORD SecBigTimeSkew;
  498. extern DWORD SecBigTimeSkewBypass;
  499. //
  500. // Security globals
  501. // expose some of these which may be accessed by update library
  502. //
  503. extern BOOL g_fSecurityPackageInitialized;
  504. extern DWORD g_SecurityTokenMaxLength;
  505. //
  506. // Security context cache
  507. //
  508. VOID
  509. Dns_TimeoutSecurityContextList(
  510. IN BOOL fClearList
  511. );
  512. //
  513. // Security API
  514. //
  515. BOOL
  516. Dns_DnsNameToKerberosTargetName(
  517. IN LPSTR pszDnsName,
  518. IN LPSTR pszKerberosTargetName
  519. );
  520. DNS_STATUS
  521. Dns_StartSecurity(
  522. IN BOOL fProcessAttach
  523. );
  524. DNS_STATUS
  525. Dns_StartServerSecurity(
  526. VOID
  527. );
  528. DNS_STATUS
  529. Dns_InitializeSecurityPackage(
  530. OUT PDWORD pdwMaxMessage,
  531. IN BOOL bDnsSvr
  532. );
  533. VOID
  534. Dns_TerminateSecurityPackage(
  535. VOID
  536. );
  537. HANDLE
  538. Dns_CreateAPIContext(
  539. IN DWORD Flags,
  540. IN PVOID Credentials, OPTIONAL
  541. IN BOOL fUnicode
  542. );
  543. VOID
  544. Dns_FreeAPIContext(
  545. IN OUT HANDLE hContextHandle
  546. );
  547. PVOID
  548. Dns_GetApiContextCredentials(
  549. IN HANDLE hContextHandle
  550. );
  551. DWORD
  552. Dns_GetCurrentRid(
  553. VOID);
  554. BOOL
  555. Dns_CreateUserCredentials(
  556. IN PCHAR pszUser,
  557. IN DWORD dwUserLength,
  558. IN PCHAR pszDomain,
  559. IN DWORD dwDomainLength,
  560. IN PCHAR pszPassword,
  561. IN DWORD dwPasswordLength,
  562. IN BOOL FromWide,
  563. OUT PCHAR * ppCreds
  564. );
  565. PSEC_WINNT_AUTH_IDENTITY_W
  566. Dns_AllocateAndInitializeCredentialsW(
  567. IN PSEC_WINNT_AUTH_IDENTITY_W pAuthIn
  568. );
  569. PSEC_WINNT_AUTH_IDENTITY_A
  570. Dns_AllocateAndInitializeCredentialsA(
  571. IN PSEC_WINNT_AUTH_IDENTITY_A pAuthIn
  572. );
  573. VOID
  574. Dns_FreeAuthIdentityCredentials(
  575. IN PVOID pAuthIn
  576. );
  577. DNS_STATUS
  578. Dns_SignMessageWithGssTsig(
  579. IN HANDLE hContext,
  580. IN PDNS_HEADER pMsgHead,
  581. IN PCHAR pMsgBufEnd,
  582. IN OUT PCHAR * ppCurrent
  583. );
  584. #if 1
  585. DNS_STATUS
  586. Dns_RefreshSSpiCredentialsHandle(
  587. IN BOOL bDnsSvr,
  588. IN PCHAR pCreds );
  589. #endif
  590. VOID
  591. Dns_FreeSecurityContextList(
  592. VOID
  593. );
  594. //
  595. // Client security routines
  596. //
  597. DNS_STATUS
  598. Dns_DoSecureUpdate(
  599. IN PDNS_MSG_BUF pMsgSend,
  600. OUT PDNS_MSG_BUF pMsgRecv,
  601. IN OUT PHANDLE phContext,
  602. IN DWORD dwFlag,
  603. IN PDNS_NETINFO pNetworkInfo,
  604. IN PIP_ARRAY aipServer,
  605. IN LPSTR pszNameServer,
  606. IN PCHAR pCreds,
  607. IN PCHAR pszContext
  608. );
  609. //
  610. // Server security routines
  611. //
  612. DNS_STATUS
  613. Dns_FindSecurityContextFromAndVerifySignature(
  614. IN PHANDLE phContext,
  615. IN IP_ADDRESS ipRemote,
  616. IN PDNS_HEADER pMsgHead,
  617. IN PCHAR pMsgEnd
  618. );
  619. DNS_STATUS
  620. Dns_ServerNegotiateTkey(
  621. IN IP_ADDRESS ipRemote,
  622. IN PDNS_HEADER pMsgHead,
  623. IN PCHAR pMsgEnd,
  624. IN PCHAR pMsgBufEnd,
  625. IN BOOL fBreakOnAscFailure,
  626. OUT PCHAR * ppCurrent
  627. );
  628. DNS_STATUS
  629. Dns_SrvImpersonateClient(
  630. IN HANDLE hContext
  631. );
  632. DNS_STATUS
  633. Dns_SrvRevertToSelf(
  634. IN HANDLE hContext
  635. );
  636. VOID
  637. Dns_CleanupSessionAndEnlistContext(
  638. IN OUT HANDLE hSession
  639. );
  640. DWORD
  641. Dns_GetKeyVersion(
  642. IN LPSTR pszContext
  643. );
  644. //
  645. // Security utilities
  646. //
  647. DNS_STATUS
  648. Dns_CreateSecurityDescriptor(
  649. OUT PSECURITY_DESCRIPTOR * ppSD,
  650. IN DWORD AclCount,
  651. IN PSID * SidPtrArray,
  652. IN DWORD * AccessMaskArray
  653. );
  654. //
  655. // Security credentials
  656. //
  657. // Only defined if WINNT_AUTH_IDENTITY defined
  658. #ifdef __RPCDCE_H__
  659. PSEC_WINNT_AUTH_IDENTITY_W
  660. Dns_AllocateCredentials(
  661. IN PWSTR pwsUserName,
  662. IN PWSTR pwsDomain,
  663. IN PWSTR pwsPassword
  664. );
  665. #endif
  666. DNS_STATUS
  667. Dns_ImpersonateUser(
  668. IN PDNS_CREDENTIALS pCreds
  669. );
  670. VOID
  671. Dns_FreeCredentials(
  672. IN PDNS_CREDENTIALS pCreds
  673. );
  674. PDNS_CREDENTIALS
  675. Dns_CopyCredentials(
  676. IN PDNS_CREDENTIALS pCreds
  677. );
  678. //
  679. // Debug globals
  680. //
  681. // Expose here to allow debug file sharing
  682. //
  683. typedef struct _DnsDebugInfo
  684. {
  685. DWORD Flag;
  686. HANDLE hFile;
  687. DWORD FileCurrentSize;
  688. DWORD FileWrapCount;
  689. DWORD FileWrapSize;
  690. DWORD LastThreadId;
  691. DWORD LastSecond;
  692. BOOL fConsole;
  693. CHAR FileName[ MAX_PATH ];
  694. }
  695. DNS_DEBUG_INFO, *PDNS_DEBUG_INFO;
  696. // WANING: MUST ONLY be called in dnsapi.dll
  697. PDNS_DEBUG_INFO
  698. Dns_SetDebugGlobals(
  699. IN OUT PDNS_DEBUG_INFO pInfo
  700. );
  701. //
  702. // No DnsApi.dll
  703. //
  704. // If not using dnsapi.dll, let those names be used without
  705. //
  706. #ifdef NO_DNSAPI_DLL
  707. //
  708. // remove DnsApi.dll function definition
  709. //
  710. // timer
  711. #undef InitializeSecondsTimer
  712. #undef GetCurrentTimeInSeconds
  713. // IP array
  714. #undef DnsValidateIpAddressArray
  715. #undef DnsCreateIpAddressArrayCopy
  716. #undef DnsCreateIpArray
  717. #undef DnsSizeofIpArray
  718. #undef DnsBuildIpArray
  719. #undef DnsCreateIpArrayCopy
  720. #undef DnsIsAddressInIpArray
  721. #undef DnsAddIpToIpArray
  722. #undef DnsClearIpArray
  723. #undef DnsCheckAndMakeIpArraySubset
  724. #undef DnsDeleteIpFromIpArray
  725. #undef DnsRemoveZerosFromIpArray
  726. #undef DnsDiffOfIpArrays
  727. #undef DnsIntersectionOfIpArrays
  728. // general DNS utilities
  729. #undef DnsGetDomainName
  730. #undef DnsValidateAndCategorizeDnsName
  731. #undef DnsStatusString
  732. #undef DnsMapRcodeToStatus
  733. #undef DnsIsStatusRcode
  734. #undef DnsResponseCodeString
  735. #undef DnsResponseCodeExplanationString
  736. #undef DnsOpcodeString
  737. #undef DnsOpcodeCharacter
  738. #undef DnsSectionNameString
  739. // local machine info
  740. #undef Dns_GetIpAddresses
  741. // records
  742. #undef DnsWinsRecordFlagForString
  743. #undef DnsWinsRecordFlagString
  744. #undef DnsIsAMailboxType
  745. #undef DnsRecordTypeForName
  746. #undef DnsRecordStringForType
  747. #undef DnsRecordStringForWritableType
  748. #undef DnsIsStringCountValidForTextType
  749. #undef DnsIpv6StringToAddress
  750. #undef DnsIpv6AddressToString
  751. // strings
  752. #undef DnsCreateStringCopy
  753. #undef DnsGetBufferLengthForStringCopy
  754. #undef DnsCopyStringEx
  755. #undef DnsStringCopyAllocateEx
  756. #undef DnsWriteReverseNameStringForIpAddress
  757. #undef DnsCreateReverseNameStringForIpAddress
  758. #undef DnsValidateDnsName_UTF8
  759. #undef DnsValidateDnsName_W
  760. #undef DnsRelationalCompare_UTF8
  761. #undef DnsRelationalCompare_W
  762. #undef DnsValidateDnsString_UTF8
  763. #undef DnsValidateDnsString_W
  764. #undef DnsCreateStandardDnsNameCopy
  765. #undef DnsDowncaseDnsNameLabel
  766. #undef DnsUnicodeToUtf8
  767. #undef DnsUtf8ToUnicode
  768. #undef DnsValidateUtf8Byte
  769. //
  770. // redefine DnsApi.dll function as dnslib function
  771. //
  772. // timer
  773. #define InitializeSecondsTimer() Dns_InitializeSecondsTimer()
  774. #define GetCurrentTimeInSeconds() Dns_GetCurrentTimeInSeconds()
  775. // IP array
  776. #define DnsValidateIpAddressArray(a,b,c) Dns_ValidateIpAddressArray(a,b,c)
  777. #define DnsCreateIpAddressArrayCopy(a,b) Dns_CreateIpAddressArrayCopy(a,b)
  778. #define DnsCreateIpArray(a) Dns_CreateIpArray(a)
  779. #define DnsSizeofIpArray(a) Dns_SizeofIpArray(a)
  780. #define DnsBuildIpArray(a,b) Dns_BuildIpArray((a),(b))
  781. #define DnsCreateIpArrayCopy(a) Dns_CreateIpArrayCopy(a)
  782. #define DnsIsAddressInIpArray(a,b) Dns_IsAddressInIpArray((a),(b))
  783. #define DnsAddIpToIpArray(a,b) Dns_AddIpToIpArray((a),(b))
  784. #define DnsClearIpArray(a) Dns_ClearIpArray(a)
  785. #define DnsCheckAndMakeIpArraySubset(a,b) Dns_CheckAndMakeIpArraySubset((a),(b))
  786. #define DnsDeleteIpFromIpArray(a,b) Dns_DeleteIpFromIpArray((a),(b))
  787. #define DnsRemoveZerosFromIpArray(a) Dns_RemoveZerosFromIpArray(a)
  788. #define DnsDiffOfIpArrays(a,b,c,d,e) Dns_DiffOfIpArrays((a),(b),(c),(d),(e))
  789. #define DnsIntersectionOfIpArrays(a,b,c) Dns_IntersectionOfIpArrays((a),(b),(c))
  790. // general DNS utilities
  791. #define DnsGetDomainName(a) Dns_GetDomainName(a)
  792. #define DnsValidateAndCategorizeDnsName(a,b) Dns_ValidateAndCategorizeDnsName(a,b)
  793. #define DnsStatusString(a) Dns_StatusString(a)
  794. #define DnsMapRcodeToStatus(a) Dns_MapRcodeToStatus(a)
  795. #define DnsIsStatusRcode(a) Dns_IsStatusRcode(a)
  796. #define DnsResponseCodeString(a) Dns_ResponseCodeString(a)
  797. #define DnsResponseCodeExplanationString(a) Dns_ResponseCodeExplanationString(a)
  798. #define DnsOpcodeString(a) Dns_OpcodeString(a)
  799. #define DnsOpcodeCharacter(a) Dns_OpcodeCharacter(a)
  800. #define DnsSectionNameString(a,b) Dns_SectionNameString(a,b)
  801. // local machine info
  802. #define DnsGetIpAddresses(a,b) Dns_GetIpAddresses(a,b)
  803. // records
  804. #define DnsWinsRecordFlagForString(a,b) Dns_WinsRecordFlagForString(a,b)
  805. #define DnsWinsRecordFlagString(a,b) Dns_WinsRecordFlagString(a,b)
  806. #define DnsIsAMailboxType(a) Dns_IsAMailboxType(a)
  807. #define DnsRecordTypeForName(a,b) Dns_RecordTypeForName(a,b)
  808. #define DnsRecordStringForType(a) Dns_RecordStringForType(a)
  809. #define DnsRecordStringForWritableType(a) Dns_RecordStringForWritableType(a)
  810. #define DnsIsStringCountValidForTextType(a,b) Dns_IsStringCountValidForTextType(a,b)
  811. // strings
  812. #define DnsCreateStringCopy(a,b) Dns_CreateStringCopy(a,b)
  813. #define DnsGetBufferLengthForStringCopy(a,b,c,d) Dns_GetBufferLengthForStringCopy(a,b,c,d)
  814. #define DnsCopyStringEx(a,b,c,d,e) Dns_CopyStringEx(a,b,c,d,e)
  815. #define DnsStringCopyAllocateEx(a,b,c,d) Dns_NameCopyAllocateEx(a,b,c,d)
  816. #define DnsValidateDnsName_UTF8(a) Dns_ValidateDnsName_UTF8(a)
  817. #define DnsValidateDnsName_W(a) Dns_ValidateDnsName_W(a)
  818. #define DnsRelationalCompare_UTF8(a,b,c,d) Dns_RelationalCompare_UTF8(a,b,c,d)
  819. #define DnsRelationalCompare_W(a,b,c,d) Dns_RelationalCompare_W(a,b,c,d)
  820. #define DnsValidateDnsString_UTF8(a) Dns_ValidateDnsString_UTF8(a)
  821. #define DnsValidateDnsString_W(a) Dns_ValidateDnsString_W(a)
  822. #define DnsCreateStandardDnsNameCopy(a,b,c) Dns_CreateStandardDnsNameCopy(a,b,c)
  823. #define DnsDowncaseDnsNameLabel(a,b,c,d) Dns_DowncaseDnsNameLabel(a,b,c,d)
  824. #define DnsUnicodeToUtf8(a,b,c,d) Dns_UnicodeToUtf8(a,b,c,d)
  825. #define DnsUtf8ToUnicode(a,b,c,d) Dns_Utf8ToUnicode(a,b,c,d)
  826. #define DnsValidateUtf8Byte(a,b) Dns_ValidateUtf8Byte(a,b)
  827. // address\string mapping
  828. // some ones to make official?
  829. #define DnsIpv6StringToAddress(a,b,c) Dns_Ip6StringToAddressEx_A(a,b,c)
  830. #define DnsIpv6AddressToString(a,b) Dns_Ip6AddressToString_A(a,b)
  831. #define DnsWriteReverseNameStringForIpAddress(a,b) Dns_WriteReverseNameForIp4Address(a,b)
  832. #define DnsWriteReverseNameStringForIpAddress_W(a,b)Dns_WriteReverseNameForIp4Address_W(a,b)
  833. #define DnsCreateReverseNameStringForIpAddress(a) Dns_CreateReverseNameStringForIpAddress(a)
  834. #endif // NO_DNSAPI_DLL
  835. //
  836. // Use old names
  837. // Covering old names with new -- done for dnsapi.dll (and associated utils)
  838. // This is done only for non-exported routines.
  839. // Exported routines must be directly covered.
  840. //
  841. // IP array
  842. #define DnsValidateIpAddressArray(a,b,c) Dns_ValidateIpAddressArray(a,b,c)
  843. #define DnsCreateIpAddressArrayCopy(a,b) Dns_CreateIpAddressArrayCopy(a,b)
  844. #define DnsCreateIpArray(a) Dns_CreateIpArray(a)
  845. #define DnsSizeofIpArray(a) Dns_SizeofIpArray(a)
  846. #define DnsBuildIpArray(a,b) Dns_BuildIpArray((a),(b))
  847. #define DnsCreateIpArrayCopy(a) Dns_CreateIpArrayCopy(a)
  848. #define DnsIsAddressInIpArray(a,b) Dns_IsAddressInIpArray((a),(b))
  849. #define DnsAddIpToIpArray(a,b) Dns_AddIpToIpArray((a),(b))
  850. #define DnsClearIpArray(a) Dns_ClearIpArray(a)
  851. #define DnsCheckAndMakeIpArraySubset(a,b) Dns_CheckAndMakeIpArraySubset((a),(b))
  852. #define DnsDeleteIpFromIpArray(a,b) Dns_DeleteIpFromIpArray((a),(b))
  853. #define DnsRemoveZerosFromIpArray(a) Dns_RemoveZerosFromIpArray(a)
  854. #define DnsDiffOfIpArrays(a,b,c,d,e) Dns_DiffOfIpArrays((a),(b),(c),(d),(e))
  855. #define DnsIntersectionOfIpArrays(a,b,c) Dns_IntersectionOfIpArrays((a),(b),(c))
  856. // DNS configuration
  857. #define DnsInitNetworkInfo() Dns_InitNetworkInfo()
  858. #define DnsGetDnsAdapterInfo(a) Dns_GetDnsAdapterInfo(a)
  859. #define DnsGetDnsNetworkInfo(a,b) Dns_GetDnsNetworkInfo(a,b)
  860. #define DnsCreateAdapterInfo(a) Dns_CreateAdapterInfo(a)
  861. #define DnsCreateSearchList(a,b) Dns_CreateSearchList(a,b)
  862. #define DnsCreateNetworkInfo(a) Dns_CreateNetworkInfo(a)
  863. #define DnsSizeofAdapterInfo(a) Dns_SizeofAdapterInfo(a)
  864. #define DnsCreateAdapterInfoCopy(a) Dns_CreateAdapterInfoCopy(a)
  865. #define DnsCreateSearchListCopy(a) Dns_CreateSearchListCopy(a)
  866. #define DnsCreateNetworkInfoCopy(a) Dns_CreateNetworkInfoCopy(a)
  867. #define DnsAddAdapterInfoToNetworkInfo(a,b) Dns_AddAdapterInfoToNetworkInfo(a,b)
  868. #define DnsGetNextSearchName(a,b,c) Dns_GetNextSearchName(a,b,c)
  869. #define DnsConvertIpArrayToAdapterInfo(a) Dns_ConvertIpArrayToAdapterInfo(a)
  870. #define DnsConvertIpArrayToNetworkInfo(a,b) Dns_ConvertIpArrayToNetworkInfo(a,b)
  871. #define DnsConvertNetworkInfoToIpArray(a) Dns_ConvertNetworkInfoToIpArray(a)
  872. #define DnsFreeAdapterInfo(a) Dns_FreeAdapterInfo(a)
  873. #define DnsFreeSearchList(a) Dns_FreeSearchList(a)
  874. #define DnsFreeNetworkInfo(a) Dns_FreeNetworkInfo(a)
  875. // same stuff but the infamous "NetAdapter"
  876. #define DnsConvertNetworkInfoToIpArray(a) Dns_ConvertNetworkInfoToIpArray(a)
  877. #define DnsFreeNetworkInfo(a) Dns_FreeNetworkInfo(a)
  878. #define DnsCreateNetworkInfo(a) Dns_CreateNetworkInfo(a)
  879. #define DnsCreateNetworkInfoCopy(a) Dns_CreateNetworkInfoCopy(a)
  880. #define DnsCreateUpdateNetworkInfo(a,b) Dns_CreateUpdateNetworkInfo((b),NULL,(a),0)
  881. // packet
  882. #define DnsAllocateMsgBuf(a) Dns_AllocateMsgBuf(a)
  883. #define DnsInitializeMsgBuf(a) Dns_InitializeMsgBuf(a)
  884. #define DnsWriteDottedNameToPacket(a,b,c,d,e,f) Dns_WriteDottedNameToPacket(a,b,c,d,e,f)
  885. #define DnsWriteStringToPacket(a,b,c,d) Dns_WriteStringToPacket(a,b,c,d)
  886. #define DnsWriteQuestionToMessage(a,b,c,d) Dns_WriteQuestionToMessage(a,b,c,d)
  887. #define DnsWriteRecordStructureToMessage(a,b,c,d,e) Dns_WriteRecordStructureToMessage(a,b,c,d,e)
  888. #define DnsWriteRecordStructureToPacket(a,b,c) Dns_WriteRecordStructureToPacket(a,b,c)
  889. #define DnsAddRecordsToMessage(a,b,c) Dns_AddRecordsToMessage(a,b,c)
  890. #define DnsSkipPacketName(a,b) Dns_SkipPacketName(a,b)
  891. #define DnsExtractRecordsFromMessage(a,b,c) Dns_ExtractRecordsFromMessage(a,b,c)
  892. #define DnsReadPacketName(a,b,c,d,e,f,g) Dns_ReadPacketName(a,b,c,d,e,f,g)
  893. // socket
  894. #define DnsCreateSocket(a,b,c) Dns_CreateSocket(a,b,c)
  895. #define DnsCloseSocket(a) Dns_CloseSocket(a)
  896. #define DnsCloseConnection(a) Dns_CloseConnection(a)
  897. #define DnsSetupGlobalAsyncSocket() Dns_SetupGlobalAsyncSocket()
  898. // send
  899. #define DnsSend(a) Dns_Send(a)
  900. #define DnsRecv(b) Dns_Recv(b)
  901. #define DnsRecvUdp(b) Dns_RecvUdp(b)
  902. #define DnsSendMultipleUdp(a,b) Dns_SendMultipleUdp(a,b)
  903. #define DnsSendAndRecvUdp(a,b,c) Dns_SendAndRecvUdp(a,b,c)
  904. #define DnsSendAndRecvUdpEx(a,b,c) Dns_SendAndRecvUdpEx(a,b,c)
  905. #define DnsOpenTcpConnectionAndSend(a,b,c) Dns_OpenTcpConnectionAndSend(a,b,c)
  906. #define DnsRecvTcp(a) Dns_RecvTcp(a)
  907. #define DnsSendAndRecvTcp(a,b,c) Dns_SendAndRecvTcp(a,b,c)
  908. #define DnsInitializeMsgRemoteSockaddr(a,b) Dns_InitializeMsgRemoteSockaddr(a,b)
  909. //
  910. // Redefinitions to old naming
  911. //
  912. // DCR: remove once fixed
  913. // shouldn't be in use anywhere but DNS source tree
  914. //
  915. #if 0
  916. #define DnsStartDebug(a,b,c,d,e) Dns_StartDebug(a,b,c,d,e)
  917. #define DnsEndDebug() Dns_EndDebug()
  918. #define DnsAssert(a,b,c) Dns_Assert(a,b,c)
  919. #define DnsDebugFlush() DnsDbg_Flush()
  920. #define DnsDebugCSEnter(a,b,c,d) DnsDbg_CSEnter(a,b,c,d)
  921. #define DnsDebugCSLeave(a,b,c,d) DnsDbg_CSLeave(a,b,c,d)
  922. #define DnsPrintf DnsDbg_Printf
  923. #define DnsDbgPrint DnsDbg_PrintfToDebugger
  924. #define DnsDebugLock() DnsDbg_Lock()
  925. #define DnsDebugUnlock() DnsDbg_Unlock()
  926. #endif
  927. #ifdef __cplusplus
  928. }
  929. #endif // __cplusplus
  930. #endif // _DNSLIBP_INCLUDED_