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.

257 lines
5.1 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. // Structure: DNS_BINDING
  28. //
  29. // This structure holds information used for I/O on a logical network.
  30. // Each interface's 'BindingArray' contains an entry for each binding-entry
  31. // supplied during 'BindInterface'.
  32. // The 'TimerPending' field is set when a receive-attempt fails on an interface
  33. // and a timer is queued to reattempt the receive later.
  34. //
  35. typedef struct _DNS_BINDING {
  36. ULONG Address;
  37. ULONG Mask;
  38. SOCKET Socket[DnsProxyCount];
  39. BOOLEAN TimerPending[DnsProxyCount];
  40. } DNS_BINDING, *PDNS_BINDING;
  41. //
  42. // Structure: DNS_INTERFACE
  43. //
  44. // This structure holds operational information for an interface.
  45. //
  46. // Each interface is inserted into the list of DNS interfaces,
  47. // sorted by 'Index'.
  48. //
  49. // Synchronization on an interface makes use of an interface-list lock
  50. // ('DnsInterfaceLock'), a per-interface reference count, and a per-interface
  51. // critical-section:
  52. //
  53. // Acquiring a reference to an interface guarantees the interface's existence;
  54. // acquiring the interface's lock guarantees the interface's consistency.
  55. //
  56. // To acquire a reference, first acquire the interface-list lock;
  57. // to traverse the interface-list, first acquire the interface-list lock.
  58. //
  59. // An interface's lock can only be acquired if
  60. // (a) a reference to the interface has been acquired, or
  61. // (b) the interface-list lock is currently held.
  62. // Note that holding the list lock alone does not guarantee consistency.
  63. //
  64. // Fields marked read-only can be read so long as the interface is referenced.
  65. //
  66. typedef struct _DNS_INTERFACE {
  67. LIST_ENTRY Link;
  68. CRITICAL_SECTION Lock;
  69. ULONG ReferenceCount;
  70. ULONG Index; // read-only
  71. NET_INTERFACE_TYPE Type; // read-only
  72. IP_DNS_PROXY_INTERFACE_INFO Info;
  73. ULONG Flags;
  74. ULONG BindingCount;
  75. PDNS_BINDING BindingArray;
  76. LIST_ENTRY QueryList;
  77. } DNS_INTERFACE, *PDNS_INTERFACE;
  78. //
  79. // Flags
  80. //
  81. #define DNS_INTERFACE_FLAG_DELETED 0x80000000
  82. #define DNS_INTERFACE_DELETED(i) \
  83. ((i)->Flags & DNS_INTERFACE_FLAG_DELETED)
  84. #define DNS_INTERFACE_FLAG_BOUND 0x40000000
  85. #define DNS_INTERFACE_BOUND(i) \
  86. ((i)->Flags & DNS_INTERFACE_FLAG_BOUND)
  87. #define DNS_INTERFACE_FLAG_ENABLED 0x20000000
  88. #define DNS_INTERFACE_ENABLED(i) \
  89. ((i)->Flags & DNS_INTERFACE_FLAG_ENABLED)
  90. #define DNS_INTERFACE_FLAG_CONFIGURED 0x10000000
  91. #define DNS_INTERFACE_CONFIGURED(i) \
  92. ((i)->Flags & DNS_INTERFACE_FLAG_CONFIGURED)
  93. #define DNS_INTERFACE_ACTIVE(i) \
  94. (((i)->Flags & (DNS_INTERFACE_FLAG_BOUND|DNS_INTERFACE_FLAG_ENABLED)) \
  95. == (DNS_INTERFACE_FLAG_BOUND|DNS_INTERFACE_FLAG_ENABLED))
  96. #define DNS_INTERFACE_ADMIN_DISABLED(i) \
  97. ((i)->Flags & IP_DNS_PROXY_INTERFACE_FLAG_DISABLED)
  98. #define DNS_INTERFACE_ADMIN_DEFAULT(i) \
  99. ((i)->Flags & IP_DNS_PROXY_INTERFACE_FLAG_DEFAULT)
  100. //
  101. // Synchronization
  102. //
  103. #define DNS_REFERENCE_INTERFACE(i) \
  104. REFERENCE_OBJECT(i, DNS_INTERFACE_DELETED)
  105. #define DNS_DEREFERENCE_INTERFACE(i) \
  106. DEREFERENCE_OBJECT(i, DnsCleanupInterface)
  107. //
  108. // GLOBAL DATA DECLARATIONS
  109. //
  110. extern LIST_ENTRY DnsInterfaceList;
  111. extern CRITICAL_SECTION DnsInterfaceLock;
  112. //
  113. // FUNCTION DECLARATIONS
  114. //
  115. ULONG
  116. DnsActivateInterface(
  117. PDNS_INTERFACE Interfacep
  118. );
  119. ULONG
  120. DnsBindInterface(
  121. ULONG Index,
  122. PIP_ADAPTER_BINDING_INFO BindingInfo
  123. );
  124. VOID
  125. DnsCleanupInterface(
  126. PDNS_INTERFACE Interfacep
  127. );
  128. VOID APIENTRY
  129. DnsConnectDefaultInterface(
  130. PVOID Unused
  131. );
  132. ULONG
  133. DnsConfigureInterface(
  134. ULONG Index,
  135. PIP_DNS_PROXY_INTERFACE_INFO InterfaceInfo
  136. );
  137. ULONG
  138. DnsCreateInterface(
  139. ULONG Index,
  140. NET_INTERFACE_TYPE Type,
  141. PIP_DNS_PROXY_INTERFACE_INFO InterfaceInfo,
  142. PDNS_INTERFACE* InterfaceCreated
  143. );
  144. VOID
  145. DnsDeactivateInterface(
  146. PDNS_INTERFACE Interfacep
  147. );
  148. VOID
  149. DnsDeferReadInterface(
  150. PDNS_INTERFACE Interfacep,
  151. SOCKET Socket
  152. );
  153. ULONG
  154. DnsDeleteInterface(
  155. ULONG Index
  156. );
  157. ULONG
  158. DnsDisableInterface(
  159. ULONG Index
  160. );
  161. ULONG
  162. DnsEnableInterface(
  163. ULONG Index
  164. );
  165. ULONG
  166. DnsInitializeInterfaceManagement(
  167. VOID
  168. );
  169. PDNS_INTERFACE
  170. DnsLookupInterface(
  171. ULONG Index,
  172. OUT PLIST_ENTRY* InsertionPoint OPTIONAL
  173. );
  174. ULONG
  175. DnsQueryInterface(
  176. ULONG Index,
  177. PVOID InterfaceInfo,
  178. PULONG InterfaceInfoSize
  179. );
  180. VOID
  181. DnsReactivateEveryInterface(
  182. VOID
  183. );
  184. VOID
  185. DnsShutdownInterfaceManagement(
  186. VOID
  187. );
  188. VOID
  189. DnsSignalNatInterface(
  190. ULONG Index,
  191. BOOLEAN Boundary
  192. );
  193. ULONG
  194. DnsUnbindInterface(
  195. ULONG Index
  196. );
  197. ULONG
  198. DnsGetPrivateInterfaceAddress(
  199. VOID
  200. );
  201. #endif // _NATHLP_DNSIF_H_