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.

216 lines
4.8 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 <basetyps.h>
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <limits.h>
  27. //#include <tchar.h>
  28. #include <align.h> // Alignment macros
  29. #include <windns.h> // Public DNS definitions
  30. #define NO_DNSAPI_DLL
  31. //#define DNSLIB_SECURITY
  32. #define DNSAPI_INTERNAL
  33. #include "..\..\resolver\idl\resrpc.h"
  34. #include "dnslibp.h" // Private DNS definitions
  35. #include "..\dnsapi\dnsapip.h"
  36. #include "message.h"
  37. //#include "..\dnsapi\registry.h"
  38. //#include "rtlstuff.h" // Handy macros from NT RTL
  39. //
  40. // Use winsock2
  41. //
  42. #define DNS_WINSOCK_VERSION (0x0202) // Winsock 2.2
  43. //
  44. // Debugging
  45. //
  46. #define DNS_LOG_EVENT(a,b,c,d)
  47. // use DNS_ASSERT for dnslib debugging
  48. #undef ASSERT
  49. #define ASSERT(expr) DNS_ASSERT(expr)
  50. //
  51. // Single async socket for internal use
  52. //
  53. // If want async socket i/o then can create single async socket, with
  54. // corresponding event and always use it. Requires winsock 2.2
  55. //
  56. extern SOCKET DnsSocket;
  57. extern OVERLAPPED DnsSocketOverlapped;
  58. extern HANDLE hDnsSocketEvent;
  59. //
  60. // App shutdown flag
  61. //
  62. extern BOOLEAN fApplicationShutdown;
  63. //
  64. // Heap operations
  65. //
  66. #define ALLOCATE_HEAP(size) Dns_AllocZero( size )
  67. #define REALLOCATE_HEAP(p,size) Dns_Realloc( (p), (size) )
  68. #define FREE_HEAP(p) Dns_Free( p )
  69. #define ALLOCATE_HEAP_ZERO(size) Dns_AllocZero( size )
  70. //
  71. // RPC Exception filters
  72. //
  73. #define DNS_RPC_EXCEPTION_FILTER \
  74. (((RpcExceptionCode() != STATUS_ACCESS_VIOLATION) && \
  75. (RpcExceptionCode() != STATUS_DATATYPE_MISALIGNMENT) && \
  76. (RpcExceptionCode() != STATUS_PRIVILEGED_INSTRUCTION) && \
  77. (RpcExceptionCode() != STATUS_ILLEGAL_INSTRUCTION)) \
  78. ? 0x1 : EXCEPTION_CONTINUE_SEARCH )
  79. // Not defined (RpcExceptionCode() != STATUS_POSSIBLE_DEADLOCK) && \
  80. // Not defined (RpcExceptionCode() != STATUS_INSTRUCTION_MISALIGNMENT) && \
  81. //
  82. // Table lookup.
  83. //
  84. // Many DNS Records have human readable mnemonics for given data values.
  85. // These are used for data file formats, and display in nslookup or debug
  86. // output or cmdline tools.
  87. //
  88. // To simplify this process, have a single mapping functionality that
  89. // supports DWORD \ LPSTR mapping tables. Tables for indivual types
  90. // may then be layered on top of this.
  91. //
  92. // Support two table types.
  93. // VALUE_TABLE_ENTRY is simple value-string mapping
  94. // FLAG_TABLE_ENTRY is designed for bit field flag mappings where
  95. // several flag strings might be contained in flag; this table
  96. // contains additional mask field to allow multi-bit fields
  97. // within the flag
  98. //
  99. typedef struct
  100. {
  101. DWORD dwValue; // flag value
  102. PCHAR pszString; // string representation of value
  103. }
  104. DNS_VALUE_TABLE_ENTRY, *PDNS_VALUE_TABLE;
  105. typedef struct
  106. {
  107. DWORD dwFlag; // flag value
  108. DWORD dwMask; // flag value mask
  109. PCHAR pszString; // string representation of value
  110. }
  111. DNS_FLAG_TABLE_ENTRY, *PDNS_FLAG_TABLE;
  112. // Error return on unmatched string
  113. #define DNS_TABLE_LOOKUP_ERROR (-1)
  114. DWORD
  115. Dns_ValueForString(
  116. IN PDNS_VALUE_TABLE Table,
  117. IN BOOL fIgnoreCase,
  118. IN PCHAR pchName,
  119. IN INT cchNameLength
  120. );
  121. PCHAR
  122. Dns_GetStringForValue(
  123. IN PDNS_VALUE_TABLE Table,
  124. IN DWORD dwValue
  125. );
  126. VOID
  127. DnsPrint_ValueTable(
  128. IN PRINT_ROUTINE PrintRoutine,
  129. IN PPRINT_CONTEXT pPrintContext,
  130. IN LPSTR pszHeader,
  131. IN PDNS_VALUE_TABLE Table
  132. );
  133. DWORD
  134. Dns_FlagForString(
  135. IN PDNS_FLAG_TABLE Table,
  136. IN BOOL fIgnoreCase,
  137. IN PCHAR pchName,
  138. IN INT cchNameLength
  139. );
  140. PCHAR
  141. Dns_WriteStringsForFlag(
  142. IN PDNS_FLAG_TABLE Table,
  143. IN DWORD dwFlag,
  144. IN OUT PCHAR pchFlag
  145. );
  146. //
  147. // Random -- back to dnslib.h when it goes private again
  148. //
  149. // DCR: return these to dnslib.h when private
  150. //
  151. PCHAR
  152. Dns_ParsePacketRecord(
  153. IN PCHAR pchPacket,
  154. IN PCHAR pchMsgEnd,
  155. IN OUT PDNS_PARSED_RR pParsedRR
  156. );
  157. #endif // _DNSLIB_LOCAL_INCLUDED_