Leaked source code of windows server 2003
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.

210 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1998, Microsoft Corporation
  3. Module Name:
  4. dnslookup.h
  5. Abstract:
  6. This module contains declarations related to the DNS server's
  7. lookup table.
  8. Author:
  9. Tom Brown (tbrown) 25-Oct-1999
  10. Revision History:
  11. Raghu Gatta (rgatta) 21-Oct-2000
  12. Time macros + New Functions
  13. --*/
  14. #ifndef _NATHLP_DNSLOOKUP_H_
  15. #define _NATHLP_DNSLOOKUP_H_
  16. #define LOCAL_DOMAIN L"local"
  17. #define LOCAL_DOMAIN_ANSI "local"
  18. //
  19. // move to somewhere else if necessary
  20. //
  21. //
  22. // Time conversion constants and macros
  23. //
  24. #define SYSTIME_UNITS_IN_1_MSEC (1000 * 10)
  25. #define SYSTIME_UNITS_IN_1_SEC (1000 * SYSTIME_UNITS_IN_1_MSEC)
  26. //
  27. // macro to get system time in 100-nanosecond units
  28. //
  29. #define DnsQuerySystemTime(p) NtQuerySystemTime((p))
  30. //
  31. // macros to convert time between 100-nanosecond, 1millsec, and 1 sec units
  32. //
  33. #define DnsSystemTimeToMillisecs(p) { \
  34. DWORD _r; \
  35. *(p) = RtlExtendedLargeIntegerDivide(*(p), SYSTIME_UNITS_IN_1_MSEC, &_r);\
  36. }
  37. #define DnsMillisecsToSystemTime(p) \
  38. *(p) = RtlExtendedIntegerMultiply(*(p), SYSTIME_UNITS_IN_1_MSEC)
  39. #define DnsSecsToSystemTime(p) \
  40. *(p) = RtlExtendedIntegerMultiply(*(p), SYSTIME_UNITS_IN_1_SEC)
  41. #define CACHE_ENTRY_EXPIRY (7 * 24 * 60 * 60) // (matches DHCP lease time)
  42. typedef ULONG DNS_ADDRESS;
  43. typedef struct
  44. {
  45. DNS_ADDRESS ulAddress;
  46. FILETIME ftExpires;
  47. //ULONG ulExpires;
  48. } ADDRESS_INFO, *PADDRESS_INFO;
  49. typedef struct
  50. {
  51. WCHAR *pszName;
  52. UINT cAddresses;
  53. DWORD cAddressesAllocated;
  54. PADDRESS_INFO aAddressInfo;
  55. } DNS_ENTRY, *PDNS_ENTRY;
  56. typedef struct
  57. {
  58. DNS_ADDRESS ulAddress;
  59. WCHAR *pszName; // do not free this! It is the same pointer as used in the
  60. // forward lookup table.
  61. } REVERSE_DNS_ENTRY, *PREVERSE_DNS_ENTRY;
  62. extern CRITICAL_SECTION DnsTableLock; // protects both tables
  63. extern RTL_GENERIC_TABLE g_DnsTable,
  64. g_ReverseDnsTable;
  65. ULONG
  66. DnsInitializeTableManagement(
  67. VOID
  68. );
  69. VOID
  70. DnsShutdownTableManagement(
  71. VOID
  72. );
  73. VOID
  74. DnsEmptyTables(
  75. VOID
  76. );
  77. BOOL
  78. DnsRegisterName(
  79. WCHAR *pszName,
  80. UINT cAddresses,
  81. ADDRESS_INFO aAddressInfo[]
  82. );
  83. VOID
  84. DnsAddAddressForName(
  85. WCHAR *pszName,
  86. DNS_ADDRESS ulAddress,
  87. FILETIME ftExpires
  88. //ULONG ulExpires
  89. );
  90. VOID
  91. DnsDeleteAddressForName(
  92. WCHAR *pszName,
  93. DNS_ADDRESS ulAddress
  94. );
  95. PDNS_ENTRY
  96. DnsLookupAddress(
  97. WCHAR *pszName
  98. );
  99. PREVERSE_DNS_ENTRY
  100. DnsLookupName(
  101. DNS_ADDRESS ulAddress
  102. );
  103. VOID
  104. DnsDeleteName(
  105. WCHAR *pszName
  106. );
  107. VOID
  108. DnsUpdateName(
  109. WCHAR *pszName,
  110. DNS_ADDRESS ulAddress
  111. );
  112. VOID
  113. DnsUpdate(
  114. CHAR *pszName,
  115. ULONG len,
  116. ULONG ulAddress
  117. );
  118. VOID
  119. DnsAddSelf(
  120. VOID
  121. );
  122. VOID
  123. DnsCleanupTables(
  124. VOID
  125. );
  126. DWORD
  127. DnsConvertHostNametoUnicode(
  128. UINT CodePage,
  129. CHAR *pszHostName,
  130. PWCHAR DnsICSDomainSuffix,
  131. PWCHAR *ppszUnicodeFQDN
  132. );
  133. BOOL
  134. ConvertToUtf8(
  135. IN UINT CodePage,
  136. IN LPSTR pszName,
  137. OUT PCHAR *ppszUtf8Name,
  138. OUT ULONG *pUtf8NameSize
  139. );
  140. BOOL
  141. ConvertUTF8ToUnicode(
  142. IN LPBYTE UTF8String,
  143. OUT LPWSTR *ppszUnicodeName,
  144. OUT DWORD *pUnicodeNameSize
  145. );
  146. #endif