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.

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