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.

238 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 1998, Microsoft Corporation
  3. Module Name:
  4. dhcpmsg.h
  5. Abstract:
  6. This module contains declarations related to the DHCP allocator's
  7. message-processing.
  8. Author:
  9. Abolade Gbadegesin (aboladeg) 6-Mar-1998
  10. Revision History:
  11. --*/
  12. #ifndef _NATHLP_DHCPMSG_H_
  13. #define _NATHLP_DHCPMSG_H_
  14. //
  15. // CONSTANT DECLARATIONS
  16. //
  17. #define DHCP_MAXIMUM_RENEWAL_TIME (5 * 60)
  18. #define DHCP_NBT_NODE_TYPE_B 1
  19. #define DHCP_NBT_NODE_TYPE_P 2
  20. #define DHCP_NBT_NODE_TYPE_M 4
  21. #define DHCP_NBT_NODE_TYPE_H 8
  22. //
  23. // DHCP message format
  24. //
  25. #include <pshpack1.h>
  26. //
  27. // Disable "zero-sized array in struct/union" warning
  28. //
  29. #pragma warning(push)
  30. #pragma warning(disable : 4200)
  31. typedef struct _DHCP_OPTION {
  32. UCHAR Tag;
  33. UCHAR Length;
  34. UCHAR Option[];
  35. } DHCP_OPTION, *PDHCP_OPTION;
  36. typedef struct _DHCP_FOOTER {
  37. UCHAR Cookie[4];
  38. } DHCP_FOOTER, *PDHCP_FOOTER;
  39. typedef struct _DHCP_HEADER {
  40. UCHAR Operation;
  41. UCHAR HardwareAddressType;
  42. UCHAR HardwareAddressLength;
  43. UCHAR HopCount;
  44. ULONG TransactionId;
  45. USHORT SecondsSinceBoot;
  46. USHORT Flags;
  47. ULONG ClientAddress;
  48. ULONG AssignedAddress;
  49. ULONG BootstrapServerAddress;
  50. ULONG RelayAgentAddress;
  51. UCHAR HardwareAddress[16];
  52. UCHAR ServerHostName[64];
  53. UCHAR BootFile[128];
  54. DHCP_FOOTER Footer[];
  55. } DHCP_HEADER, *PDHCP_HEADER;
  56. #pragma warning(pop)
  57. #include <poppack.h>
  58. //
  59. // MACRO DECLARATIONS
  60. //
  61. //
  62. // BOOTP operation codes
  63. //
  64. #define BOOTP_OPERATION_REQUEST 1
  65. #define BOOTP_OPERATION_REPLY 2
  66. //
  67. // BOOTP flags
  68. //
  69. #define BOOTP_FLAG_BROADCAST 0x0080
  70. //
  71. // BOOTP maximum option-area size
  72. //
  73. #define BOOTP_VENDOR_LENGTH 64
  74. //
  75. // Internal transaction ID for DHCP server detection
  76. //
  77. #define DHCP_DETECTION_TRANSACTION_ID 'MSFT'
  78. //
  79. // DHCP magic cookie
  80. //
  81. #define DHCP_MAGIC_COOKIE ((99 << 24) | (83 << 16) | (130 << 8) | (99))
  82. #define DHCP_MAGIC_COOKIE_SIZE 4
  83. //
  84. // DHCP option tag values
  85. //
  86. #define DHCP_TAG_PAD 0
  87. #define DHCP_TAG_SUBNET_MASK 1
  88. #define DHCP_TAG_ROUTER 3
  89. #define DHCP_TAG_DNS_SERVER 6
  90. #define DHCP_TAG_HOST_NAME 12
  91. #define DHCP_TAG_DOMAIN_NAME 15
  92. #define DHCP_TAG_STATIC_ROUTE 33
  93. #define DHCP_TAG_WINS_SERVER 44
  94. #define DHCP_TAG_NBT_NODE_TYPE 46
  95. #define DHCP_TAG_NBT_SCOPE 47
  96. #define DHCP_TAG_REQUESTED_ADDRESS 50
  97. #define DHCP_TAG_LEASE_TIME 51
  98. #define DHCP_TAG_OPTION_OVERLOAD 52
  99. #define DHCP_TAG_MESSAGE_TYPE 53
  100. #define DHCP_TAG_SERVER_IDENTIFIER 54
  101. #define DHCP_TAG_PARAMETER_REQUEST_LIST 55
  102. #define DHCP_TAG_ERROR_MESSAGE 56
  103. #define DHCP_TAG_MAXIMUM_MESSAGE_SIZE 57
  104. #define DHCP_TAG_RENEWAL_TIME 58
  105. #define DHCP_TAG_REBINDING_TIME 59
  106. #define DHCP_TAG_VENDOR_CLASS 60
  107. #define DHCP_TAG_CLIENT_IDENTIFIER 61
  108. #define DHCP_TAG_DYNAMIC_DNS 81
  109. #define DHCP_TAG_END 255
  110. //
  111. // Enumeration: DHCP_OPTION_INDEX
  112. //
  113. // The following enumerates the options of interest to the DHCP allocator.
  114. // The enumeration aids in the processing of the options.
  115. // (See 'DhcpExtractOptionsFromMessage').
  116. //
  117. typedef enum {
  118. DhcpOptionClientIdentifier,
  119. DhcpOptionMessageType,
  120. DhcpOptionRequestedAddress,
  121. DhcpOptionParameterRequestList,
  122. DhcpOptionErrorMessage,
  123. DhcpOptionDynamicDns,
  124. DhcpOptionHostName,
  125. DhcpOptionCount
  126. } DHCP_OPTION_INDEX;
  127. //
  128. // DHCP message type values
  129. //
  130. #define DHCP_MESSAGE_BOOTP 0
  131. #define DHCP_MESSAGE_DISCOVER 1
  132. #define DHCP_MESSAGE_OFFER 2
  133. #define DHCP_MESSAGE_REQUEST 3
  134. #define DHCP_MESSAGE_DECLINE 4
  135. #define DHCP_MESSAGE_ACK 5
  136. #define DHCP_MESSAGE_NAK 6
  137. #define DHCP_MESSAGE_RELEASE 7
  138. #define DHCP_MESSAGE_INFORM 8
  139. //
  140. // IP/1394 support (RFC 2855)
  141. //
  142. #define IP1394_HTYPE 0x18
  143. //
  144. // FUNCTION DECLARATIONS
  145. //
  146. ULONG
  147. DhcpExtractOptionsFromMessage(
  148. PDHCP_HEADER Headerp,
  149. ULONG MessageSize,
  150. DHCP_OPTION UNALIGNED* OptionArray[]
  151. );
  152. VOID
  153. DhcpProcessBootpMessage(
  154. PDHCP_INTERFACE Interfacep,
  155. PNH_BUFFER Bufferp,
  156. DHCP_OPTION UNALIGNED* OptionArray[]
  157. );
  158. VOID
  159. DhcpProcessDiscoverMessage(
  160. PDHCP_INTERFACE Interfacep,
  161. PNH_BUFFER Bufferp,
  162. DHCP_OPTION UNALIGNED* OptionArray[]
  163. );
  164. VOID
  165. DhcpProcessInformMessage(
  166. PDHCP_INTERFACE Interfacep,
  167. PNH_BUFFER Bufferp,
  168. DHCP_OPTION UNALIGNED* OptionArray[]
  169. );
  170. VOID
  171. DhcpProcessMessage(
  172. PDHCP_INTERFACE Interfacep,
  173. PNH_BUFFER Bufferp
  174. );
  175. VOID
  176. DhcpProcessRequestMessage(
  177. PDHCP_INTERFACE Interfacep,
  178. PNH_BUFFER Bufferp,
  179. DHCP_OPTION UNALIGNED* OptionArray[]
  180. );
  181. ULONG
  182. DhcpWriteClientRequestMessage(
  183. PDHCP_INTERFACE Interfacep,
  184. PDHCP_BINDING Binding
  185. );
  186. #endif // _NATHLP_DHCPMSG_H_