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.

407 lines
10 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  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. #define MDHCP_SERVER_IP_ADDRESS 0x0100efef // 239.239.0.1
  34. //
  35. // hardware types.
  36. //
  37. #define HARDWARE_TYPE_NONE 0 // used for non-hardware type client id
  38. #define HARDWARE_TYPE_10MB_EITHERNET 1
  39. #define HARDWARE_TYPE_IEEE_802 6
  40. #define HARDWARE_ARCNET 7
  41. #define HARDWARE_PPP 8
  42. //
  43. // Client-server protoocol reserved ports
  44. //
  45. #define DHCP_CLIENT_PORT 68
  46. #define DHCP_SERVR_PORT 67
  47. //
  48. // DHCP BROADCAST flag.
  49. //
  50. #define DHCP_BROADCAST 0x8000
  51. #define DHCP_NO_BROADCAST 0x0000
  52. // MDHCP flag
  53. #define DHCP_MBIT 0x4000
  54. #define IS_MDHCP_MESSAGE( _msg ) ( _I_ntohs((_msg)->Reserved) & DHCP_MBIT ? TRUE : FALSE )
  55. #define MDHCP_MESSAGE( _msg ) ( (_msg)->Reserved |= htons(DHCP_MBIT) )
  56. #define CLASSD_NET_ADDR(a) ( (a & 0xf0) == 0xe0)
  57. #define CLASSD_HOST_ADDR(a) ((a & 0xf0000000) == 0xe0000000)
  58. #define DHCP_MESSAGE_SIZE 576
  59. #define DHCP_SEND_MESSAGE_SIZE 548
  60. #define BOOTP_MESSAGE_SIZE 300 // the options field for bootp is 64 bytes.
  61. //
  62. // The amount of time to wait for a DHCP response after a request
  63. // has been sent.
  64. //
  65. #if !DBG
  66. #define WAIT_FOR_RESPONSE_TIME 5
  67. #else
  68. #define WAIT_FOR_RESPONSE_TIME 10
  69. #endif
  70. //
  71. // DHCP Operations
  72. //
  73. #define BOOT_REQUEST 1
  74. #define BOOT_REPLY 2
  75. //
  76. // DHCP Standard Options.
  77. //
  78. #define OPTION_PAD 0
  79. #define OPTION_SUBNET_MASK 1
  80. #define OPTION_TIME_OFFSET 2
  81. #define OPTION_ROUTER_ADDRESS 3
  82. #define OPTION_TIME_SERVERS 4
  83. #define OPTION_IEN116_NAME_SERVERS 5
  84. #define OPTION_DOMAIN_NAME_SERVERS 6
  85. #define OPTION_LOG_SERVERS 7
  86. #define OPTION_COOKIE_SERVERS 8
  87. #define OPTION_LPR_SERVERS 9
  88. #define OPTION_IMPRESS_SERVERS 10
  89. #define OPTION_RLP_SERVERS 11
  90. #define OPTION_HOST_NAME 12
  91. #define OPTION_BOOT_FILE_SIZE 13
  92. #define OPTION_MERIT_DUMP_FILE 14
  93. #define OPTION_DOMAIN_NAME 15
  94. #define OPTION_SWAP_SERVER 16
  95. #define OPTION_ROOT_DISK 17
  96. #define OPTION_EXTENSIONS_PATH 18
  97. //
  98. // IP layer parameters - per host
  99. //
  100. #define OPTION_BE_A_ROUTER 19
  101. #define OPTION_NON_LOCAL_SOURCE_ROUTING 20
  102. #define OPTION_POLICY_FILTER_FOR_NLSR 21
  103. #define OPTION_MAX_REASSEMBLY_SIZE 22
  104. #define OPTION_DEFAULT_TTL 23
  105. #define OPTION_PMTU_AGING_TIMEOUT 24
  106. #define OPTION_PMTU_PLATEAU_TABLE 25
  107. //
  108. // Link layer parameters - per interface.
  109. //
  110. #define OPTION_MTU 26
  111. #define OPTION_ALL_SUBNETS_MTU 27
  112. #define OPTION_BROADCAST_ADDRESS 28
  113. #define OPTION_PERFORM_MASK_DISCOVERY 29
  114. #define OPTION_BE_A_MASK_SUPPLIER 30
  115. #define OPTION_PERFORM_ROUTER_DISCOVERY 31
  116. #define OPTION_ROUTER_SOLICITATION_ADDR 32
  117. #define OPTION_STATIC_ROUTES 33
  118. #define OPTION_TRAILERS 34
  119. #define OPTION_ARP_CACHE_TIMEOUT 35
  120. #define OPTION_ETHERNET_ENCAPSULATION 36
  121. //
  122. // TCP Paramters - per host
  123. //
  124. #define OPTION_TTL 37
  125. #define OPTION_KEEP_ALIVE_INTERVAL 38
  126. #define OPTION_KEEP_ALIVE_DATA_SIZE 39
  127. //
  128. // Application Layer Parameters
  129. //
  130. #define OPTION_NETWORK_INFO_SERVICE_DOM 40
  131. #define OPTION_NETWORK_INFO_SERVERS 41
  132. #define OPTION_NETWORK_TIME_SERVERS 42
  133. //
  134. // Vender specific information option
  135. //
  136. #define OPTION_VENDOR_SPEC_INFO 43
  137. //
  138. // NetBIOS over TCP/IP Name server option
  139. //
  140. #define OPTION_NETBIOS_NAME_SERVER 44
  141. #define OPTION_NETBIOS_DATAGRAM_SERVER 45
  142. #define OPTION_NETBIOS_NODE_TYPE 46
  143. #define OPTION_NETBIOS_SCOPE_OPTION 47
  144. //
  145. // X Window System Options.
  146. //
  147. #define OPTION_XWINDOW_FONT_SERVER 48
  148. #define OPTION_XWINDOW_DISPLAY_MANAGER 49
  149. //
  150. // Other extensions
  151. //
  152. #define OPTION_REQUESTED_ADDRESS 50
  153. #define OPTION_LEASE_TIME 51
  154. #define OPTION_OK_TO_OVERLAY 52
  155. #define OPTION_MESSAGE_TYPE 53
  156. #define OPTION_SERVER_IDENTIFIER 54
  157. #define OPTION_PARAMETER_REQUEST_LIST 55
  158. #define OPTION_MESSAGE 56
  159. #define OPTION_MESSAGE_LENGTH 57
  160. #define OPTION_RENEWAL_TIME 58 // T1
  161. #define OPTION_REBIND_TIME 59 // T2
  162. #define OPTION_CLIENT_CLASS_INFO 60
  163. #define OPTION_CLIENT_ID 61
  164. #define OPTION_TFTP_SERVER_NAME 66
  165. #define OPTION_BOOTFILE_NAME 67
  166. //
  167. // user class id
  168. //
  169. #define OPTION_USER_CLASS 77
  170. //
  171. // Dynamic DNS Stuff. Tells if we should do both A+PTR updates?
  172. //
  173. #define OPTION_DYNDNS_BOTH 81
  174. // Multicast options.
  175. #define OPTION_MCAST_SCOPE_ID 101
  176. #define OPTION_MCAST_LEASE_START 102
  177. #define OPTION_MCAST_TTL 103
  178. #define OPTION_CLIENT_PORT 105
  179. #define OPTION_MCAST_SCOPE_LIST 107
  180. // special option to extend options
  181. #define OPTION_LARGE_OPTION 127
  182. #define OPTION_WPAD_URL 252
  183. #define OPTION_END 255
  184. // default mcast_ttl value.
  185. #define DEFAULT_MCAST_TTL 32
  186. //
  187. // Different option values for the DYNDNS_BOTH option ...
  188. //
  189. #define DYNDNS_REGISTER_AT_CLIENT 0 // Client will do both registrations
  190. #define DYNDNS_REGISTER_AT_SERVER 1 // Server will do registrations
  191. #define DYNDNS_DOWNLEVEL_CLIENT 3 // arbitraty # diff from above
  192. //
  193. // Microsoft-specific options
  194. //
  195. #define OPTION_MSFT_DSDOMAINNAME_REQ 94 // send me your DS Domain name
  196. #define OPTION_MSFT_DSDOMAINNAME_RESP 95 // sending my DS Domain name
  197. #define OPTION_MSFT_CONTINUED 250 // the previous option is being continued..
  198. //
  199. // DHCP Message types
  200. //
  201. #define DHCP_DISCOVER_MESSAGE 1
  202. #define DHCP_OFFER_MESSAGE 2
  203. #define DHCP_REQUEST_MESSAGE 3
  204. #define DHCP_DECLINE_MESSAGE 4
  205. #define DHCP_ACK_MESSAGE 5
  206. #define DHCP_NACK_MESSAGE 6
  207. #define DHCP_RELEASE_MESSAGE 7
  208. #define DHCP_INFORM_MESSAGE 8
  209. #define DHCP_MAGIC_COOKIE_BYTE1 99
  210. #define DHCP_MAGIC_COOKIE_BYTE2 130
  211. #define DHCP_MAGIC_COOKIE_BYTE3 83
  212. #define DHCP_MAGIC_COOKIE_BYTE4 99
  213. #define BOOT_FILE_SIZE 128
  214. #define BOOT_SERVER_SIZE 64
  215. #define BOOT_FILE_SIZE_W ( BOOT_FILE_SIZE * sizeof( WCHAR ))
  216. #define BOOT_SERVER_SIZE_W ( BOOT_SERVER_SIZE * sizeof( WCHAR ))
  217. //
  218. // DHCP APP names - used to indentify to the eventlogger.
  219. //
  220. #define DHCP_EVENT_CLIENT TEXT("Dhcp")
  221. #define DHCP_EVENT_SERVER TEXT("DhcpServer")
  222. typedef struct _OPTION {
  223. BYTE OptionType;
  224. BYTE OptionLength;
  225. BYTE OptionValue[1];
  226. } OPTION, *POPTION, *LPOPTION;
  227. //
  228. // A DHCP message buffer
  229. //
  230. #pragma pack(1) /* Assume byte packing */
  231. typedef struct _DHCP_MESSAGE {
  232. BYTE Operation;
  233. BYTE HardwareAddressType;
  234. BYTE HardwareAddressLength;
  235. BYTE HopCount;
  236. DWORD TransactionID;
  237. WORD SecondsSinceBoot;
  238. WORD Reserved;
  239. DHCP_IP_ADDRESS ClientIpAddress;
  240. DHCP_IP_ADDRESS YourIpAddress;
  241. DHCP_IP_ADDRESS BootstrapServerAddress;
  242. DHCP_IP_ADDRESS RelayAgentIpAddress;
  243. BYTE HardwareAddress[16];
  244. BYTE HostName[ BOOT_SERVER_SIZE ];
  245. BYTE BootFileName[BOOT_FILE_SIZE];
  246. OPTION Option;
  247. } DHCP_MESSAGE, *PDHCP_MESSAGE, *LPDHCP_MESSAGE;
  248. #pragma pack()
  249. #define DHCP_MESSAGE_FIXED_PART_SIZE \
  250. (sizeof(DHCP_MESSAGE) - sizeof(OPTION))
  251. #define DHCP_MIN_SEND_RECV_PK_SIZE \
  252. (DHCP_MESSAGE_FIXED_PART_SIZE + 64)
  253. //
  254. // JET - DHCP database constants.
  255. //
  256. #define DB_TABLE_SIZE 10 // table size in 4K pages.
  257. #define DB_TABLE_DENSITY 80 // page density
  258. #define DB_LANGID 0x0409 // language id
  259. #define DB_CP 1252 // code page
  260. #if DBG
  261. //
  262. // debug functions.
  263. //
  264. #ifdef CHICAGO // No Tracing available on CHICAGO
  265. #define DhcpPrintTrace
  266. #endif
  267. //#define IF_DEBUG(flag) if (DhcpGlobalDebugFlag & (DEBUG_ ## flag))
  268. #define DhcpPrint(_x_) DEBUG_PRINT(UTIL,INFO,_x_)
  269. #define Trace DhcpPrintTrace
  270. #ifndef CHICAGO
  271. VOID
  272. DhcpPrintTrace(
  273. IN LPSTR Format,
  274. ...
  275. );
  276. #endif
  277. #if DBG
  278. /*
  279. VOID
  280. //extern "C"
  281. DhcpPrintRoutine(
  282. IN DWORD DebugFlag,
  283. IN LPSTR Format,
  284. ...
  285. )
  286. {
  287. #define MAX_PRINTF_LEN 1024 // Arbitrary.
  288. va_list arglist;
  289. char OutputBuffer[MAX_PRINTF_LEN];
  290. ULONG length = 0;
  291. //
  292. // Put a the information requested by the caller onto the line
  293. //
  294. va_start(arglist, Format);
  295. length += (ULONG) vsprintf(&OutputBuffer[length], Format, arglist);
  296. va_end(arglist);
  297. //DhcpAssert(length <= MAX_PRINTF_LEN);
  298. //
  299. // Output to the debug terminal,
  300. //
  301. printf( "%s", OutputBuffer);
  302. }
  303. */
  304. #endif // DBG
  305. #else
  306. //#define IF_DEBUG(flag) if (FALSE)
  307. #define DhcpPrint(_x_)
  308. #define Trace (void)
  309. #endif // DBG
  310. #define OpenDriver DhcpOpenDriver
  311. #endif // _DHCP_