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.

278 lines
5.9 KiB

  1. /*++
  2. Copyright (c) 1998, Microsoft Corporation
  3. Module Name:
  4. dnsif.h
  5. Abstract:
  6. This module contains declarations for the DNS proxy's interface
  7. management.
  8. Author:
  9. Abolade Gbadegesin (aboladeg) 9-Mar-1998
  10. Revision History:
  11. --*/
  12. #ifndef _NATHLP_DNSIF_H_
  13. #define _NATHLP_DNSIF_H_
  14. //
  15. // Enumeration: DNS_PROXY_TYPE
  16. //
  17. typedef enum {
  18. DnsProxyDns = 0,
  19. DnsProxyWins,
  20. DnsProxyCount
  21. } DNS_PROXY_TYPE;
  22. #define DNS_PROXY_TYPE_TO_PORT(t) \
  23. (USHORT)(((t) == DnsProxyDns) ? DNS_PORT_SERVER : WINS_PORT_SERVER)
  24. #define DNS_PROXY_PORT_TO_TYPE(p) \
  25. (DNS_PROXY_TYPE)(((p) == DNS_PORT_SERVER) ? DnsProxyDns : DnsProxyWins)
  26. //
  27. // Enumeration: DNS_INTERFACE_TYPE
  28. // 4 Types of Interfaces possible:
  29. // (1) Private
  30. // (2) Boundary
  31. // (3) Firewalled
  32. // (4) Boundary + Firewalled
  33. // DNS should be active only on the Private Interface
  34. // (A Public interface is simply a non-Private interface.)
  35. //
  36. typedef enum {
  37. DnsInterfaceInvalid,
  38. DnsInterfacePrivate,
  39. DnsInterfaceBoundary,
  40. DnsInterfaceFirewalled,
  41. DnsInterfaceBoundaryFirewalled
  42. } DNS_INTERFACE_TYPE;
  43. //
  44. // Structure: DNS_BINDING
  45. //
  46. // This structure holds information used for I/O on a logical network.
  47. // Each interface's 'BindingArray' contains an entry for each binding-entry
  48. // supplied during 'BindInterface'.
  49. // The 'TimerPending' field is set when a receive-attempt fails on an interface
  50. // and a timer is queued to reattempt the receive later.
  51. //
  52. typedef struct _DNS_BINDING {
  53. ULONG Address;
  54. ULONG Mask;
  55. SOCKET Socket[DnsProxyCount];
  56. BOOLEAN TimerPending[DnsProxyCount];
  57. } DNS_BINDING, *PDNS_BINDING;
  58. //
  59. // Structure: DNS_INTERFACE
  60. //
  61. // This structure holds operational information for an interface.
  62. //
  63. // Each interface is inserted into the list of DNS interfaces,
  64. // sorted by 'Index'.
  65. //
  66. // Synchronization on an interface makes use of an interface-list lock
  67. // ('DnsInterfaceLock'), a per-interface reference count, and a per-interface
  68. // critical-section:
  69. //
  70. // Acquiring a reference to an interface guarantees the interface's existence;
  71. // acquiring the interface's lock guarantees the interface's consistency.
  72. //
  73. // To acquire a reference, first acquire the interface-list lock;
  74. // to traverse the interface-list, first acquire the interface-list lock.
  75. //
  76. // An interface's lock can only be acquired if
  77. // (a) a reference to the interface has been acquired, or
  78. // (b) the interface-list lock is currently held.
  79. // Note that holding the list lock alone does not guarantee consistency.
  80. //
  81. // Fields marked read-only can be read so long as the interface is referenced.
  82. //
  83. typedef struct _DNS_INTERFACE {
  84. LIST_ENTRY Link;
  85. CRITICAL_SECTION Lock;
  86. ULONG ReferenceCount;
  87. ULONG Index; // read-only
  88. NET_INTERFACE_TYPE Type; // read-only
  89. DNS_INTERFACE_TYPE DnsInterfaceType;
  90. IP_DNS_PROXY_INTERFACE_INFO Info;
  91. ULONG Flags;
  92. ULONG BindingCount;
  93. PDNS_BINDING BindingArray;
  94. LIST_ENTRY QueryList;
  95. } DNS_INTERFACE, *PDNS_INTERFACE;
  96. //
  97. // Flags
  98. //
  99. #define DNS_INTERFACE_FLAG_DELETED 0x80000000
  100. #define DNS_INTERFACE_DELETED(i) \
  101. ((i)->Flags & DNS_INTERFACE_FLAG_DELETED)
  102. #define DNS_INTERFACE_FLAG_BOUND 0x40000000
  103. #define DNS_INTERFACE_BOUND(i) \
  104. ((i)->Flags & DNS_INTERFACE_FLAG_BOUND)
  105. #define DNS_INTERFACE_FLAG_ENABLED 0x20000000
  106. #define DNS_INTERFACE_ENABLED(i) \
  107. ((i)->Flags & DNS_INTERFACE_FLAG_ENABLED)
  108. #define DNS_INTERFACE_FLAG_CONFIGURED 0x10000000
  109. #define DNS_INTERFACE_CONFIGURED(i) \
  110. ((i)->Flags & DNS_INTERFACE_FLAG_CONFIGURED)
  111. #define DNS_INTERFACE_ACTIVE(i) \
  112. (((i)->Flags & (DNS_INTERFACE_FLAG_BOUND|DNS_INTERFACE_FLAG_ENABLED)) \
  113. == (DNS_INTERFACE_FLAG_BOUND|DNS_INTERFACE_FLAG_ENABLED))
  114. #define DNS_INTERFACE_ADMIN_DISABLED(i) \
  115. ((i)->Flags & IP_DNS_PROXY_INTERFACE_FLAG_DISABLED)
  116. #define DNS_INTERFACE_ADMIN_DEFAULT(i) \
  117. ((i)->Flags & IP_DNS_PROXY_INTERFACE_FLAG_DEFAULT)
  118. //
  119. // Synchronization
  120. //
  121. #define DNS_REFERENCE_INTERFACE(i) \
  122. REFERENCE_OBJECT(i, DNS_INTERFACE_DELETED)
  123. #define DNS_DEREFERENCE_INTERFACE(i) \
  124. DEREFERENCE_OBJECT(i, DnsCleanupInterface)
  125. //
  126. // GLOBAL DATA DECLARATIONS
  127. //
  128. extern LIST_ENTRY DnsInterfaceList;
  129. extern CRITICAL_SECTION DnsInterfaceLock;
  130. //
  131. // FUNCTION DECLARATIONS
  132. //
  133. ULONG
  134. DnsActivateInterface(
  135. PDNS_INTERFACE Interfacep
  136. );
  137. ULONG
  138. DnsBindInterface(
  139. ULONG Index,
  140. PIP_ADAPTER_BINDING_INFO BindingInfo
  141. );
  142. VOID
  143. DnsCleanupInterface(
  144. PDNS_INTERFACE Interfacep
  145. );
  146. VOID APIENTRY
  147. DnsConnectDefaultInterface(
  148. PVOID Unused
  149. );
  150. ULONG
  151. DnsConfigureInterface(
  152. ULONG Index,
  153. PIP_DNS_PROXY_INTERFACE_INFO InterfaceInfo
  154. );
  155. ULONG
  156. DnsCreateInterface(
  157. ULONG Index,
  158. NET_INTERFACE_TYPE Type,
  159. PIP_DNS_PROXY_INTERFACE_INFO InterfaceInfo,
  160. PDNS_INTERFACE* InterfaceCreated
  161. );
  162. VOID
  163. DnsDeactivateInterface(
  164. PDNS_INTERFACE Interfacep
  165. );
  166. VOID
  167. DnsDeferReadInterface(
  168. PDNS_INTERFACE Interfacep,
  169. SOCKET Socket
  170. );
  171. ULONG
  172. DnsDeleteInterface(
  173. ULONG Index
  174. );
  175. ULONG
  176. DnsDisableInterface(
  177. ULONG Index
  178. );
  179. ULONG
  180. DnsEnableInterface(
  181. ULONG Index
  182. );
  183. ULONG
  184. DnsInitializeInterfaceManagement(
  185. VOID
  186. );
  187. PDNS_INTERFACE
  188. DnsLookupInterface(
  189. ULONG Index,
  190. OUT PLIST_ENTRY* InsertionPoint OPTIONAL
  191. );
  192. ULONG
  193. DnsQueryInterface(
  194. ULONG Index,
  195. PVOID InterfaceInfo,
  196. PULONG InterfaceInfoSize
  197. );
  198. VOID
  199. DnsReactivateEveryInterface(
  200. VOID
  201. );
  202. VOID
  203. DnsShutdownInterfaceManagement(
  204. VOID
  205. );
  206. VOID
  207. DnsSignalNatInterface(
  208. ULONG Index,
  209. BOOLEAN Boundary
  210. );
  211. ULONG
  212. DnsUnbindInterface(
  213. ULONG Index
  214. );
  215. ULONG
  216. DnsGetPrivateInterfaceAddress(
  217. VOID
  218. );
  219. #endif // _NATHLP_DNSIF_H_