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.

258 lines
5.9 KiB

  1. /*++
  2. Copyright (c) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. local.h
  5. Abstract:
  6. Domain Name System (DNS)
  7. DNS Library local include file
  8. Author:
  9. Jim Gilroy December 1996
  10. Revision History:
  11. --*/
  12. #ifndef _DNSLIB_LOCAL_INCLUDED_
  13. #define _DNSLIB_LOCAL_INCLUDED_
  14. //#pragma warning(disable:4214)
  15. //#pragma warning(disable:4514)
  16. //#pragma warning(disable:4152)
  17. #include <nt.h>
  18. #include <ntrtl.h>
  19. #include <nturtl.h>
  20. #include <windows.h>
  21. #include <winsock2.h>
  22. #include <ws2tcpip.h>
  23. #include <iptypes.h>
  24. #include <basetyps.h>
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <limits.h>
  28. //#include <tchar.h>
  29. #include <align.h> // Alignment macros
  30. #include <windns.h> // Public DNS definitions
  31. #define DNS_INTERNAL
  32. #include "dnslibp.h" // Private DNS definitions
  33. #include "..\..\resolver\idl\resrpc.h"
  34. #include "..\dnsapi\dnsapip.h"
  35. #include "message.h"
  36. //#include "..\dnsapi\registry.h"
  37. //#include "rtlstuff.h" // Handy macros from NT RTL
  38. //
  39. // Use winsock2
  40. //
  41. #define DNS_WINSOCK_VERSION (0x0202) // Winsock 2.2
  42. //
  43. // Debugging
  44. //
  45. #define DNS_LOG_EVENT(a,b,c,d)
  46. // use DNS_ASSERT for dnslib debugging
  47. #undef ASSERT
  48. #define ASSERT(expr) DNS_ASSERT(expr)
  49. //
  50. // Single async socket for internal use
  51. //
  52. // If want async socket i/o then can create single async socket, with
  53. // corresponding event and always use it. Requires winsock 2.2
  54. //
  55. extern SOCKET DnsSocket;
  56. extern OVERLAPPED DnsSocketOverlapped;
  57. extern HANDLE hDnsSocketEvent;
  58. //
  59. // App shutdown flag
  60. //
  61. extern BOOLEAN fApplicationShutdown;
  62. //
  63. // Heap operations
  64. //
  65. #define ALLOCATE_HEAP(size) Dns_AllocZero( size )
  66. #define REALLOCATE_HEAP(p,size) Dns_Realloc( (p), (size) )
  67. #define FREE_HEAP(p) Dns_Free( p )
  68. #define ALLOCATE_HEAP_ZERO(size) Dns_AllocZero( size )
  69. //
  70. // RPC Exception filters
  71. //
  72. #define DNS_RPC_EXCEPTION_FILTER \
  73. (((RpcExceptionCode() != STATUS_ACCESS_VIOLATION) && \
  74. (RpcExceptionCode() != STATUS_DATATYPE_MISALIGNMENT) && \
  75. (RpcExceptionCode() != STATUS_PRIVILEGED_INSTRUCTION) && \
  76. (RpcExceptionCode() != STATUS_ILLEGAL_INSTRUCTION)) \
  77. ? 0x1 : EXCEPTION_CONTINUE_SEARCH )
  78. // Not defined (RpcExceptionCode() != STATUS_POSSIBLE_DEADLOCK) && \
  79. // Not defined (RpcExceptionCode() != STATUS_INSTRUCTION_MISALIGNMENT) && \
  80. //
  81. // Table lookup.
  82. //
  83. // Many DNS Records have human readable mnemonics for given data values.
  84. // These are used for data file formats, and display in nslookup or debug
  85. // output or cmdline tools.
  86. //
  87. // To simplify this process, have a single mapping functionality that
  88. // supports DWORD \ LPSTR mapping tables. Tables for indivual types
  89. // may then be layered on top of this.
  90. //
  91. // Support two table types.
  92. // VALUE_TABLE_ENTRY is simple value-string mapping
  93. // FLAG_TABLE_ENTRY is designed for bit field flag mappings where
  94. // several flag strings might be contained in flag; this table
  95. // contains additional mask field to allow multi-bit fields
  96. // within the flag
  97. //
  98. typedef struct
  99. {
  100. DWORD dwValue; // flag value
  101. PCHAR pszString; // string representation of value
  102. }
  103. DNS_VALUE_TABLE_ENTRY, *PDNS_VALUE_TABLE;
  104. typedef struct
  105. {
  106. DWORD dwFlag; // flag value
  107. DWORD dwMask; // flag value mask
  108. PCHAR pszString; // string representation of value
  109. }
  110. DNS_FLAG_TABLE_ENTRY, *PDNS_FLAG_TABLE;
  111. // Error return on unmatched string
  112. #define DNS_TABLE_LOOKUP_ERROR (-1)
  113. DWORD
  114. Dns_ValueForString(
  115. IN PDNS_VALUE_TABLE Table,
  116. IN BOOL fIgnoreCase,
  117. IN PCHAR pchName,
  118. IN INT cchNameLength
  119. );
  120. PCHAR
  121. Dns_GetStringForValue(
  122. IN PDNS_VALUE_TABLE Table,
  123. IN DWORD dwValue
  124. );
  125. VOID
  126. DnsPrint_ValueTable(
  127. IN PRINT_ROUTINE PrintRoutine,
  128. IN PPRINT_CONTEXT pPrintContext,
  129. IN LPSTR pszHeader,
  130. IN PDNS_VALUE_TABLE Table
  131. );
  132. DWORD
  133. Dns_FlagForString(
  134. IN PDNS_FLAG_TABLE Table,
  135. IN BOOL fIgnoreCase,
  136. IN PCHAR pchName,
  137. IN INT cchNameLength
  138. );
  139. PCHAR
  140. Dns_WriteStringsForFlag(
  141. IN PDNS_FLAG_TABLE Table,
  142. IN DWORD dwFlag,
  143. IN OUT PCHAR pchFlag
  144. );
  145. //
  146. // Random -- back to dnslib.h when it goes private again
  147. //
  148. // DCR: return these to dnslib.h when private
  149. //
  150. PCHAR
  151. Dns_ParsePacketRecord(
  152. IN PCHAR pchPacket,
  153. IN PCHAR pchMsgEnd,
  154. IN OUT PDNS_PARSED_RR pParsedRR
  155. );
  156. //
  157. // TSIG\TKEY read from wire function (rrread.c)
  158. // called in security.c
  159. //
  160. PDNS_RECORD
  161. Tsig_RecordRead(
  162. IN OUT PDNS_RECORD pRR,
  163. IN DNS_CHARSET OutCharSet,
  164. IN OUT PCHAR pchStart,
  165. IN PCHAR pchData,
  166. IN PCHAR pchEnd
  167. );
  168. PDNS_RECORD
  169. Tkey_RecordRead(
  170. IN OUT PDNS_RECORD pRR,
  171. IN DNS_CHARSET OutCharSet,
  172. IN OUT PCHAR pchStart,
  173. IN PCHAR pchData,
  174. IN PCHAR pchEnd
  175. );
  176. //
  177. // Hostent stuff (hostent.c)
  178. // needed by sablob.c
  179. //
  180. PHOSTENT
  181. Hostent_Init(
  182. IN OUT PBYTE * ppBuffer,
  183. IN INT Family,
  184. IN INT AddrLength,
  185. IN DWORD AddrCount,
  186. IN DWORD AliasCount
  187. );
  188. VOID
  189. Hostent_ConvertToOffsets(
  190. IN OUT PHOSTENT pHostent
  191. );
  192. #endif // _DNSLIB_LOCAL_INCLUDED_