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.

266 lines
5.6 KiB

  1. /*++
  2. Copyright (c) 1998, Microsoft Corporation
  3. Module Name:
  4. dhcpif.h
  5. Abstract:
  6. This module contains declarations for the DHCP allocator's interface
  7. management.
  8. Author:
  9. Abolade Gbadegesin (aboladeg) 4-Mar-1998
  10. Revision History:
  11. --*/
  12. #ifndef _NATHLP_DHCPIF_H_
  13. #define _NATHLP_DHCPIF_H_
  14. //
  15. // Enumeration: DHCP_INTERFACE_TYPE
  16. // 4 Types of Interfaces possible:
  17. // (1) Private
  18. // (2) Boundary
  19. // (3) Firewalled
  20. // (4) Boundary + Firewalled
  21. // DHCP should be active only on the Private Interface
  22. // (A Public interface is simply a non-Private interface.)
  23. //
  24. typedef enum {
  25. DhcpInterfaceInvalid,
  26. DhcpInterfacePrivate,
  27. DhcpInterfaceBoundary,
  28. DhcpInterfaceFirewalled,
  29. DhcpInterfaceBoundaryFirewalled
  30. } DHCP_INTERFACE_TYPE;
  31. //
  32. // Structure: DHCP_BINDING
  33. //
  34. // This structure holds information used for I/O on a logical network.
  35. // Each interface's 'BindingArray' contains an entry for each binding-entry
  36. // supplied during 'BindInterface'.
  37. // The 'TimerPending' field is set when a receive-attempt fails on an interface
  38. // and a timer is queued to reattempt the receive later.
  39. //
  40. typedef struct _DHCP_BINDING {
  41. ULONG Address;
  42. ULONG Mask;
  43. SOCKET Socket;
  44. SOCKET ClientSocket;
  45. BOOLEAN TimerPending;
  46. } DHCP_BINDING, *PDHCP_BINDING;
  47. //
  48. // Structure: DHCP_INTERFACE
  49. //
  50. // This structure holds operational information for an interface.
  51. //
  52. // Each interface is inserted into the list of DHCP interfaces,
  53. // sorted by 'Index'.
  54. //
  55. // Synchronization on an interface makes use of an interface-list lock
  56. // ('DhcpInterfaceLock'), a per-interface reference count, and a per-interface
  57. // critical-section:
  58. //
  59. // Acquiring a reference to an interface guarantees the interface's existence;
  60. // acquiring the interface's lock guarantees the interface's consistency.
  61. //
  62. // To acquire a reference, first acquire the interface-list lock;
  63. // to traverse the interface-list, first acquire the interface-list lock.
  64. //
  65. // An interface's lock can only be acquired if
  66. // (a) a reference to the interface has been acquired, or
  67. // (b) the interface-list lock is currently held.
  68. // Note that holding the list lock alone does not guarantee consistency.
  69. //
  70. // Fields marked read-only can be read so long as the interface is referenced.
  71. //
  72. typedef struct _DHCP_INTERFACE {
  73. LIST_ENTRY Link;
  74. CRITICAL_SECTION Lock;
  75. ULONG ReferenceCount;
  76. ULONG Index;
  77. NET_INTERFACE_TYPE Type;
  78. DHCP_INTERFACE_TYPE DhcpInterfaceType;
  79. IP_AUTO_DHCP_INTERFACE_INFO Info;
  80. ULONG Flags;
  81. ULONG BindingCount;
  82. PDHCP_BINDING BindingArray;
  83. } DHCP_INTERFACE, *PDHCP_INTERFACE;
  84. //
  85. // Flags
  86. //
  87. #define DHCP_INTERFACE_FLAG_DELETED 0x80000000
  88. #define DHCP_INTERFACE_DELETED(i) \
  89. ((i)->Flags & DHCP_INTERFACE_FLAG_DELETED)
  90. #define DHCP_INTERFACE_FLAG_BOUND 0x40000000
  91. #define DHCP_INTERFACE_BOUND(i) \
  92. ((i)->Flags & DHCP_INTERFACE_FLAG_BOUND)
  93. #define DHCP_INTERFACE_FLAG_ENABLED 0x20000000
  94. #define DHCP_INTERFACE_ENABLED(i) \
  95. ((i)->Flags & DHCP_INTERFACE_FLAG_ENABLED)
  96. #define DHCP_INTERFACE_FLAG_CONFIGURED 0x10000000
  97. #define DHCP_INTERFACE_CONFIGURED(i) \
  98. ((i)->Flags & DHCP_INTERFACE_FLAG_CONFIGURED)
  99. #define DHCP_INTERFACE_FLAG_NAT_NONBOUNDARY 0x08000000
  100. #define DHCP_INTERFACE_NAT_NONBOUNDARY(i) \
  101. ((i)->Flags & DHCP_INTERFACE_FLAG_NAT_NONBOUNDARY)
  102. #define DHCP_INTERFACE_ACTIVE(i) \
  103. (((i)->Flags & (DHCP_INTERFACE_FLAG_BOUND|DHCP_INTERFACE_FLAG_ENABLED)) \
  104. == (DHCP_INTERFACE_FLAG_BOUND|DHCP_INTERFACE_FLAG_ENABLED))
  105. #define DHCP_INTERFACE_ADMIN_DISABLED(i) \
  106. ((i)->Flags & IP_AUTO_DHCP_INTERFACE_FLAG_DISABLED)
  107. //
  108. // Synchronization
  109. //
  110. #define DHCP_REFERENCE_INTERFACE(i) \
  111. REFERENCE_OBJECT(i, DHCP_INTERFACE_DELETED)
  112. #define DHCP_DEREFERENCE_INTERFACE(i) \
  113. DEREFERENCE_OBJECT(i, DhcpCleanupInterface)
  114. //
  115. // GLOBAL DATA DECLARATIONS
  116. //
  117. extern LIST_ENTRY DhcpInterfaceList;
  118. extern CRITICAL_SECTION DhcpInterfaceLock;
  119. //
  120. // FUNCTION DECLARATIONS
  121. //
  122. ULONG
  123. DhcpActivateInterface(
  124. PDHCP_INTERFACE Interfacep
  125. );
  126. ULONG
  127. DhcpBindInterface(
  128. ULONG Index,
  129. PIP_ADAPTER_BINDING_INFO BindingInfo
  130. );
  131. VOID
  132. DhcpCleanupInterface(
  133. PDHCP_INTERFACE Interfacep
  134. );
  135. ULONG
  136. DhcpConfigureInterface(
  137. ULONG Index,
  138. PIP_AUTO_DHCP_INTERFACE_INFO InterfaceInfo
  139. );
  140. ULONG
  141. DhcpCreateInterface(
  142. ULONG Index,
  143. NET_INTERFACE_TYPE Type,
  144. PIP_AUTO_DHCP_INTERFACE_INFO InterfaceInfo,
  145. PDHCP_INTERFACE* InterfaceCreated
  146. );
  147. VOID
  148. DhcpDeactivateInterface(
  149. PDHCP_INTERFACE Interfacep
  150. );
  151. VOID
  152. DhcpDeferReadInterface(
  153. PDHCP_INTERFACE Interfacep,
  154. SOCKET Socket
  155. );
  156. ULONG
  157. DhcpDeleteInterface(
  158. ULONG Index
  159. );
  160. ULONG
  161. DhcpDisableInterface(
  162. ULONG Index
  163. );
  164. ULONG
  165. DhcpEnableInterface(
  166. ULONG Index
  167. );
  168. ULONG
  169. DhcpInitializeInterfaceManagement(
  170. VOID
  171. );
  172. BOOLEAN
  173. DhcpIsLocalHardwareAddress(
  174. PUCHAR HardwareAddress,
  175. ULONG HardwareAddressLength
  176. );
  177. PDHCP_INTERFACE
  178. DhcpLookupInterface(
  179. ULONG Index,
  180. OUT PLIST_ENTRY* InsertionPoint OPTIONAL
  181. );
  182. ULONG
  183. DhcpQueryInterface(
  184. ULONG Index,
  185. PVOID InterfaceInfo,
  186. PULONG InterfaceInfoSize
  187. );
  188. VOID
  189. DhcpReactivateEveryInterface(
  190. VOID
  191. );
  192. VOID
  193. DhcpShutdownInterfaceManagement(
  194. VOID
  195. );
  196. VOID
  197. DhcpSignalNatInterface(
  198. ULONG Index,
  199. BOOLEAN Boundary
  200. );
  201. ULONG
  202. DhcpUnbindInterface(
  203. ULONG Index
  204. );
  205. ULONG
  206. DhcpGetPrivateInterfaceAddress(
  207. VOID
  208. );
  209. #endif // _NATHLP_DHCPIF_H_