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.

346 lines
8.5 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1994 - 1998
  3. Module Name:
  4. dhcp.h
  5. Abstract:
  6. This module defines the DHCP server service definitions and structures.
  7. Author:
  8. Manny Weiser (mannyw) 11-Aug-1992
  9. Revision History:
  10. Madan Appiah (madana) 10-Oct-1993
  11. --*/
  12. #ifndef _DHCP_
  13. #define _DHCP_
  14. #define WS_VERSION_REQUIRED MAKEWORD( 1, 1)
  15. //
  16. // update dhcpapi.h also if you modify the following three typedefs.
  17. //
  18. typedef DWORD DHCP_IP_ADDRESS, *PDHCP_IP_ADDRESS, *LPDHCP_IP_ADDRESS;
  19. typedef DWORD DHCP_OPTION_ID;
  20. typedef struct _DATE_TIME {
  21. DWORD dwLowDateTime;
  22. DWORD dwHighDateTime;
  23. } DATE_TIME, *LPDATE_TIME;
  24. #define DHCP_DATE_TIME_ZERO_HIGH 0
  25. #define DHCP_DATE_TIME_ZERO_LOW 0
  26. #define DHCP_DATE_TIME_INFINIT_HIGH 0x7FFFFFFF
  27. #define DHCP_DATE_TIME_INFINIT_LOW 0xFFFFFFFF
  28. #define DOT_IP_ADDR_SIZE 16 // XXX.XXX.XXX.XXX + '\0'
  29. #define NO_DHCP_IP_ADDRESS ((DHCP_IP_ADDRESS)-1)
  30. #define DHCP_IP_KEY_LEN 32 //arbitary size.
  31. #define INFINIT_TIME 0x7FFFFFFF // time_t is int
  32. #define INFINIT_LEASE 0xFFFFFFFF // in secs. (unsigned int.)
  33. //
  34. // hardware types.
  35. //
  36. #define HARDWARE_TYPE_10MB_EITHERNET 1
  37. #define HARDWARE_TYPE_IEEE_802 6
  38. #define HARDWARE_ARCNET 7
  39. #define HARDWARE_PPP 8
  40. //
  41. // Client-server protoocol reserved ports
  42. //
  43. #define DHCP_CLIENT_PORT 68
  44. #define DHCP_SERVR_PORT 67
  45. //
  46. // DHCP BROADCAST flag.
  47. //
  48. #define DHCP_BROADCAST 0x8000
  49. #define DHCP_NO_BROADCAST 0x0000
  50. #define DHCP_MESSAGE_SIZE 576
  51. #define DHCP_SEND_MESSAGE_SIZE 548
  52. #define BOOTP_MESSAGE_SIZE 300 // the options field for bootp is 64 bytes.
  53. //
  54. // The amount of time to wait for a DHCP response after a request
  55. // has been sent.
  56. //
  57. #if !DBG
  58. #define WAIT_FOR_RESPONSE_TIME 5
  59. #else
  60. #define WAIT_FOR_RESPONSE_TIME 10
  61. #endif
  62. //
  63. // DHCP Operations
  64. //
  65. #define BOOT_REQUEST 1
  66. #define BOOT_REPLY 2
  67. //
  68. // DHCP Standard Options.
  69. //
  70. #define OPTION_PAD 0
  71. #define OPTION_SUBNET_MASK 1
  72. #define OPTION_TIME_OFFSET 2
  73. #define OPTION_ROUTER_ADDRESS 3
  74. #define OPTION_TIME_SERVERS 4
  75. #define OPTION_IEN116_NAME_SERVERS 5
  76. #define OPTION_DOMAIN_NAME_SERVERS 6
  77. #define OPTION_LOG_SERVERS 7
  78. #define OPTION_COOKIE_SERVERS 8
  79. #define OPTION_LPR_SERVERS 9
  80. #define OPTION_IMPRESS_SERVERS 10
  81. #define OPTION_RLP_SERVERS 11
  82. #define OPTION_HOST_NAME 12
  83. #define OPTION_BOOT_FILE_SIZE 13
  84. #define OPTION_MERIT_DUMP_FILE 14
  85. #define OPTION_DOMAIN_NAME 15
  86. #define OPTION_SWAP_SERVER 16
  87. #define OPTION_ROOT_DISK 17
  88. #define OPTION_EXTENSIONS_PATH 18
  89. //
  90. // IP layer parameters - per host
  91. //
  92. #define OPTION_BE_A_ROUTER 19
  93. #define OPTION_NON_LOCAL_SOURCE_ROUTING 20
  94. #define OPTION_POLICY_FILTER_FOR_NLSR 21
  95. #define OPTION_MAX_REASSEMBLY_SIZE 22
  96. #define OPTION_DEFAULT_TTL 23
  97. #define OPTION_PMTU_AGING_TIMEOUT 24
  98. #define OPTION_PMTU_PLATEAU_TABLE 25
  99. //
  100. // Link layer parameters - per interface.
  101. //
  102. #define OPTION_MTU 26
  103. #define OPTION_ALL_SUBNETS_MTU 27
  104. #define OPTION_BROADCAST_ADDRESS 28
  105. #define OPTION_PERFORM_MASK_DISCOVERY 29
  106. #define OPTION_BE_A_MASK_SUPPLIER 30
  107. #define OPTION_PERFORM_ROUTER_DISCOVERY 31
  108. #define OPTION_ROUTER_SOLICITATION_ADDR 32
  109. #define OPTION_STATIC_ROUTES 33
  110. #define OPTION_TRAILERS 34
  111. #define OPTION_ARP_CACHE_TIMEOUT 35
  112. #define OPTION_ETHERNET_ENCAPSULATION 36
  113. //
  114. // TCP Paramters - per host
  115. //
  116. #define OPTION_TTL 37
  117. #define OPTION_KEEP_ALIVE_INTERVAL 38
  118. #define OPTION_KEEP_ALIVE_DATA_SIZE 39
  119. //
  120. // Application Layer Parameters
  121. //
  122. #define OPTION_NETWORK_INFO_SERVICE_DOM 40
  123. #define OPTION_NETWORK_INFO_SERVERS 41
  124. #define OPTION_NETWORK_TIME_SERVERS 42
  125. //
  126. // Vender specific information option
  127. //
  128. #define OPTION_VENDOR_SPEC_INFO 43
  129. //
  130. // NetBIOS over TCP/IP Name server option
  131. //
  132. #define OPTION_NETBIOS_NAME_SERVER 44
  133. #define OPTION_NETBIOS_DATAGRAM_SERVER 45
  134. #define OPTION_NETBIOS_NODE_TYPE 46
  135. #define OPTION_NETBIOS_SCOPE_OPTION 47
  136. //
  137. // X Window System Options.
  138. //
  139. #define OPTION_XWINDOW_FONT_SERVER 48
  140. #define OPTION_XWINDOW_DISPLAY_MANAGER 49
  141. //
  142. // Other extensions
  143. //
  144. #define OPTION_REQUESTED_ADDRESS 50
  145. #define OPTION_LEASE_TIME 51
  146. #define OPTION_OK_TO_OVERLAY 52
  147. #define OPTION_MESSAGE_TYPE 53
  148. #define OPTION_SERVER_IDENTIFIER 54
  149. #define OPTION_PARAMETER_REQUEST_LIST 55
  150. #define OPTION_MESSAGE 56
  151. #define OPTION_MESSAGE_LENGTH 57
  152. #define OPTION_RENEWAL_TIME 58 // T1
  153. #define OPTION_REBIND_TIME 59 // T2
  154. #define OPTION_CLIENT_CLASS_INFO 60
  155. #define OPTION_CLIENT_ID 61
  156. #define OPTION_TFTP_SERVER_NAME 66
  157. #define OPTION_BOOTFILE_NAME 67
  158. //
  159. // Dynamic DNS Stuff. Tells if we should do both A+PTR updates?
  160. //
  161. #define OPTION_DYNDNS_BOTH 81
  162. #define OPTION_END 255
  163. //
  164. // Different option values for the DYNDNS_BOTH option ...
  165. //
  166. #define DYNDNS_REGISTER_AT_CLIENT 0 // Client will do both registrations
  167. #define DYNDNS_REGISTER_AT_SERVER 1 // Server will do registrations
  168. #define DYNDNS_DOWNLEVEL_CLIENT 3 // arbitraty # diff from above
  169. //
  170. // Microsoft-specific options
  171. //
  172. #define OPTION_MSFT_DSDOMAINNAME_REQ 94 // send me your DS Domain name
  173. #define OPTION_MSFT_DSDOMAINNAME_RESP 95 // sending my DS Domain name
  174. //
  175. // DHCP Message types
  176. //
  177. #define DHCP_DISCOVER_MESSAGE 1
  178. #define DHCP_OFFER_MESSAGE 2
  179. #define DHCP_REQUEST_MESSAGE 3
  180. #define DHCP_DECLINE_MESSAGE 4
  181. #define DHCP_ACK_MESSAGE 5
  182. #define DHCP_NACK_MESSAGE 6
  183. #define DHCP_RELEASE_MESSAGE 7
  184. #define DHCP_INFORM_MESSAGE 8
  185. #define DHCP_MAGIC_COOKIE_BYTE1 99
  186. #define DHCP_MAGIC_COOKIE_BYTE2 130
  187. #define DHCP_MAGIC_COOKIE_BYTE3 83
  188. #define DHCP_MAGIC_COOKIE_BYTE4 99
  189. #define BOOT_FILE_SIZE 128
  190. #define BOOT_SERVER_SIZE 64
  191. #define BOOT_FILE_SIZE_W ( BOOT_FILE_SIZE * sizeof( WCHAR ))
  192. #define BOOT_SERVER_SIZE_W ( BOOT_SERVER_SIZE * sizeof( WCHAR ))
  193. //
  194. // DHCP APP names - used to indentify to the eventlogger.
  195. //
  196. #define DHCP_EVENT_CLIENT TEXT("Dhcp")
  197. #define DHCP_EVENT_SERVER TEXT("DhcpServer")
  198. typedef struct _OPTION {
  199. BYTE OptionType;
  200. BYTE OptionLength;
  201. BYTE OptionValue[1];
  202. } OPTION, *POPTION, *LPOPTION;
  203. //
  204. // A DHCP message buffer
  205. //
  206. #pragma pack(1) /* Assume byte packing */
  207. typedef struct _DHCP_MESSAGE {
  208. BYTE Operation;
  209. BYTE HardwareAddressType;
  210. BYTE HardwareAddressLength;
  211. BYTE HopCount;
  212. DWORD TransactionID;
  213. WORD SecondsSinceBoot;
  214. WORD Reserved;
  215. DHCP_IP_ADDRESS ClientIpAddress;
  216. DHCP_IP_ADDRESS YourIpAddress;
  217. DHCP_IP_ADDRESS BootstrapServerAddress;
  218. DHCP_IP_ADDRESS RelayAgentIpAddress;
  219. BYTE HardwareAddress[16];
  220. BYTE HostName[ BOOT_SERVER_SIZE ];
  221. BYTE BootFileName[BOOT_FILE_SIZE];
  222. OPTION Option;
  223. } DHCP_MESSAGE, *PDHCP_MESSAGE, *LPDHCP_MESSAGE;
  224. #pragma pack()
  225. #define DHCP_MESSAGE_FIXED_PART_SIZE \
  226. (sizeof(DHCP_MESSAGE) - sizeof(OPTION))
  227. #define DHCP_MIN_SEND_RECV_PK_SIZE \
  228. (DHCP_MESSAGE_FIXED_PART_SIZE + 64)
  229. //
  230. // JET - DHCP database constants.
  231. //
  232. #define DB_TABLE_SIZE 10 // table size in 4K pages.
  233. #define DB_TABLE_DENSITY 80 // page density
  234. #define DB_LANGID 0x0409 // language id
  235. #define DB_CP 1252 // code page
  236. #if DBG
  237. //
  238. // debug functions.
  239. //
  240. #ifdef CHICAGO // No Tracing available on CHICAGO
  241. #define DhcpPrintTrace
  242. #endif
  243. #define IF_DEBUG(flag) if (DhcpGlobalDebugFlag & (DEBUG_ ## flag))
  244. #define DhcpPrint(_x_) DhcpPrintRoutine _x_
  245. #define Trace DhcpPrintTrace
  246. #ifndef CHICAGO
  247. VOID
  248. DhcpPrintTrace(
  249. IN LPSTR Format,
  250. ...
  251. );
  252. #endif
  253. VOID
  254. DhcpPrintRoutine(
  255. IN DWORD DebugFlag,
  256. IN LPSTR Format,
  257. ...
  258. );
  259. #else
  260. #define IF_DEBUG(flag) if (FALSE)
  261. #define DhcpPrint(_x_)
  262. #define Trace (void)
  263. #endif // DBG
  264. #endif // _DHCP_