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.

578 lines
16 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, *PDATE_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 MAXINT_PTR // time_t is int_ptr
  32. #define INFINIT_LEASE 0xFFFFFFFF // in secs. (unsigned int.)
  33. // MDHCP server well known address. Relative "1" assignment in IPv4 local scope.
  34. /* FROM RFC 2365
  35. The high order /24 in every scoped region is reserved for relative
  36. assignments. A relative assignment is an integer offset from highest
  37. address in the scope and represents a 32-bit address (for IPv4). For
  38. example, in the Local Scope defined above, 239.255.255.0/24 is
  39. reserved for relative allocations. The de-facto relative assignment
  40. "0", (i.e., 239.255.255.255 in the Local Scope) currently exists for
  41. SAP [SAP]. The next relative assignment, "1", corresponds to the
  42. address 239.255.255.254 in the Local Scope. The rest of a scoped
  43. region below the reserved /24 is available for dynamic assignment
  44. (presumably by an address allocation protocol).
  45. */
  46. #define MADCAP_SERVER_IP_ADDRESS 0xfeffffef // 239.255.255.254
  47. //
  48. // hardware types.
  49. //
  50. #define HARDWARE_TYPE_NONE 0 // used for non-hardware type client id
  51. #define HARDWARE_TYPE_10MB_EITHERNET 1
  52. #define HARDWARE_TYPE_IEEE_802 6
  53. #define HARDWARE_ARCNET 7
  54. #define HARDWARE_PPP 8
  55. #define HARDWARE_1394 24
  56. //
  57. // Client-server protoocol reserved ports
  58. //
  59. #define DHCP_CLIENT_PORT 68
  60. #define DHCP_SERVR_PORT 67
  61. #define MADCAP_SERVER_PORT 2535
  62. //
  63. // DHCP BROADCAST flag.
  64. //
  65. #define DHCP_BROADCAST 0x8000
  66. #define DHCP_NO_BROADCAST 0x0000
  67. // MDHCP flag
  68. #define DHCP_MBIT 0x4000
  69. #define IS_MDHCP_MESSAGE( _msg ) ( ntohs((_msg)->Reserved) & DHCP_MBIT ? TRUE : FALSE )
  70. #define MDHCP_MESSAGE( _msg ) ( (_msg)->Reserved |= htons(DHCP_MBIT) )
  71. #define CLASSD_NET_ADDR(a) ((a & 0xf0) == 0xe0)
  72. #define CLASSD_HOST_ADDR(a) ((a & 0xf0000000) == 0xe0000000)
  73. #define CLASSE_HOST_ADDR(a) ((a & 0xf0000000) == 0xf0000000)
  74. #define CLASSE_NET_ADDR(a) ((a & 0xf0) == 0xf0)
  75. #define DHCP_MESSAGE_SIZE 576
  76. #define DHCP_RECV_MESSAGE_SIZE 4096
  77. #define DHCP_SEND_MESSAGE_SIZE 1024
  78. #define BOOTP_MESSAGE_SIZE 300 // the options field for bootp is 64 bytes.
  79. //
  80. // The amount of time to wait for a DHCP response after a request
  81. // has been sent.
  82. //
  83. #if !DBG
  84. #define WAIT_FOR_RESPONSE_TIME 5
  85. #else
  86. #define WAIT_FOR_RESPONSE_TIME 10
  87. #endif
  88. //
  89. // DHCP Operations
  90. //
  91. #define BOOT_REQUEST 1
  92. #define BOOT_REPLY 2
  93. //
  94. // DHCP Standard Options.
  95. //
  96. #define OPTION_PAD 0
  97. #define OPTION_SUBNET_MASK 1
  98. #define OPTION_TIME_OFFSET 2
  99. #define OPTION_ROUTER_ADDRESS 3
  100. #define OPTION_TIME_SERVERS 4
  101. #define OPTION_IEN116_NAME_SERVERS 5
  102. #define OPTION_DOMAIN_NAME_SERVERS 6
  103. #define OPTION_LOG_SERVERS 7
  104. #define OPTION_COOKIE_SERVERS 8
  105. #define OPTION_LPR_SERVERS 9
  106. #define OPTION_IMPRESS_SERVERS 10
  107. #define OPTION_RLP_SERVERS 11
  108. #define OPTION_HOST_NAME 12
  109. #define OPTION_BOOT_FILE_SIZE 13
  110. #define OPTION_MERIT_DUMP_FILE 14
  111. #define OPTION_DOMAIN_NAME 15
  112. #define OPTION_SWAP_SERVER 16
  113. #define OPTION_ROOT_DISK 17
  114. #define OPTION_EXTENSIONS_PATH 18
  115. //
  116. // IP layer parameters - per host
  117. //
  118. #define OPTION_BE_A_ROUTER 19
  119. #define OPTION_NON_LOCAL_SOURCE_ROUTING 20
  120. #define OPTION_POLICY_FILTER_FOR_NLSR 21
  121. #define OPTION_MAX_REASSEMBLY_SIZE 22
  122. #define OPTION_DEFAULT_TTL 23
  123. #define OPTION_PMTU_AGING_TIMEOUT 24
  124. #define OPTION_PMTU_PLATEAU_TABLE 25
  125. //
  126. // Link layer parameters - per interface.
  127. //
  128. #define OPTION_MTU 26
  129. #define OPTION_ALL_SUBNETS_MTU 27
  130. #define OPTION_BROADCAST_ADDRESS 28
  131. #define OPTION_PERFORM_MASK_DISCOVERY 29
  132. #define OPTION_BE_A_MASK_SUPPLIER 30
  133. #define OPTION_PERFORM_ROUTER_DISCOVERY 31
  134. #define OPTION_ROUTER_SOLICITATION_ADDR 32
  135. #define OPTION_STATIC_ROUTES 33
  136. #define OPTION_TRAILERS 34
  137. #define OPTION_ARP_CACHE_TIMEOUT 35
  138. #define OPTION_ETHERNET_ENCAPSULATION 36
  139. //
  140. // TCP Paramters - per host
  141. //
  142. #define OPTION_TTL 37
  143. #define OPTION_KEEP_ALIVE_INTERVAL 38
  144. #define OPTION_KEEP_ALIVE_DATA_SIZE 39
  145. //
  146. // Application Layer Parameters
  147. //
  148. #define OPTION_NETWORK_INFO_SERVICE_DOM 40
  149. #define OPTION_NETWORK_INFO_SERVERS 41
  150. #define OPTION_NETWORK_TIME_SERVERS 42
  151. //
  152. // Vender specific information option
  153. //
  154. #define OPTION_VENDOR_SPEC_INFO 43
  155. //
  156. // NetBIOS over TCP/IP Name server option
  157. //
  158. #define OPTION_NETBIOS_NAME_SERVER 44
  159. #define OPTION_NETBIOS_DATAGRAM_SERVER 45
  160. #define OPTION_NETBIOS_NODE_TYPE 46
  161. #define OPTION_NETBIOS_SCOPE_OPTION 47
  162. //
  163. // X Window System Options.
  164. //
  165. #define OPTION_XWINDOW_FONT_SERVER 48
  166. #define OPTION_XWINDOW_DISPLAY_MANAGER 49
  167. //
  168. // Other extensions
  169. //
  170. #define OPTION_REQUESTED_ADDRESS 50
  171. #define OPTION_LEASE_TIME 51
  172. #define OPTION_OK_TO_OVERLAY 52
  173. #define OPTION_MESSAGE_TYPE 53
  174. #define OPTION_SERVER_IDENTIFIER 54
  175. #define OPTION_PARAMETER_REQUEST_LIST 55
  176. #define OPTION_MESSAGE 56
  177. #define OPTION_MESSAGE_LENGTH 57
  178. #define OPTION_RENEWAL_TIME 58 // T1
  179. #define OPTION_REBIND_TIME 59 // T2
  180. #define OPTION_CLIENT_CLASS_INFO 60
  181. #define OPTION_CLIENT_ID 61
  182. #define OPTION_TFTP_SERVER_NAME 66
  183. #define OPTION_BOOTFILE_NAME 67
  184. //
  185. // user class id
  186. //
  187. #define OPTION_USER_CLASS 77
  188. //
  189. // Dynamic DNS Stuff. Tells if we should do both A+PTR updates?
  190. //
  191. #define OPTION_DYNDNS_BOTH 81
  192. //
  193. // used by binl
  194. //
  195. #define OPTION_NETWORK_INTERFACE_TYPE 91
  196. #define OPTION_SYSTEM_ARCHITECTURE 93
  197. #define OPTION_CLIENT_GUID 97
  198. // Multicast options.
  199. #define OPTION_MCAST_SCOPE_ID 101
  200. #define OPTION_MCAST_LEASE_START 102
  201. #define OPTION_MCAST_TTL 103
  202. #define OPTION_CLIENT_PORT 105
  203. #define OPTION_MCAST_SCOPE_LIST 107
  204. // disable autoconfiguration
  205. #define OPTION_IETF_AUTOCONF 116
  206. // special option to extend options
  207. #define OPTION_LARGE_OPTION 127
  208. #define OPTION_CLASSLESS_ROUTES 249
  209. #define OPTION_END 255
  210. // MADCAP OPTIONS
  211. #define MADCAP_OPTION_END 0
  212. #define MADCAP_OPTION_LEASE_TIME 1
  213. #define MADCAP_OPTION_SERVER_ID 2
  214. #define MADCAP_OPTION_LEASE_ID 3
  215. #define MADCAP_OPTION_MCAST_SCOPE 4
  216. #define MADCAP_OPTION_REQUEST_LIST 5
  217. #define MADCAP_OPTION_START_TIME 6
  218. #define MADCAP_OPTION_ADDR_COUNT 7
  219. #define MADCAP_OPTION_REQUESTED_LANG 8
  220. #define MADCAP_OPTION_MCAST_SCOPE_LIST 9
  221. #define MADCAP_OPTION_ADDR_LIST 10
  222. #define MADCAP_OPTION_TIME 11
  223. #define MADCAP_OPTION_FEATURE_LIST 12
  224. #define MADCAP_OPTION_RETRY_TIME 13
  225. #define MADCAP_OPTION_MIN_LEASE_TIME 14
  226. #define MADCAP_OPTION_MAX_START_TIME 15
  227. #define MADCAP_OPTION_ERROR 16
  228. // update the total whenever changes
  229. #define MADCAP_OPTION_TOTAL 17
  230. #define MADCAP_OPTION_NONE 0xffff
  231. // MADCAP error option codes
  232. #define MADCAP_NAK_REQ_NOT_COMPLETED 0
  233. #define MADCAP_NAK_INVALID_REQ 1
  234. #define MADCAP_NAK_CLOCK_SKEW 2
  235. #define MADCAP_NAK_INVALID_LEASE_ID 3
  236. #define MADCAP_NAK_UNSUPPORTED_FEATURE 4
  237. //
  238. // MADCAP Message types
  239. //
  240. #define MADCAP_DISCOVER_MESSAGE 1
  241. #define MADCAP_OFFER_MESSAGE 2
  242. #define MADCAP_REQUEST_MESSAGE 3
  243. #define MADCAP_RENEW_MESSAGE 4
  244. #define MADCAP_ACK_MESSAGE 5
  245. #define MADCAP_NACK_MESSAGE 6
  246. #define MADCAP_RELEASE_MESSAGE 7
  247. #define MADCAP_INFORM_MESSAGE 8
  248. // update the total when above changes
  249. #define MADCAP_TOTAL_MESSAGE 9
  250. // MADCAP version constants
  251. #define MADCAP_VERSION 0
  252. enum {
  253. MADCAP_ADDR_FAMILY_V4 = 1,
  254. MADCAP_ADDR_FAMILY_V6
  255. };
  256. // The following definations specify how the options are
  257. // formatted based on different versions and protocols
  258. enum {
  259. PROTO_DHCP,
  260. PROTO_MADCAP_V4,
  261. PROTO_MADCAP_V6
  262. };
  263. typedef struct _OPTION_VERSION {
  264. WORD Proto;
  265. WORD Version;
  266. } OPTION_VERSION, *POPTION_VERSION;
  267. #define OPT_VER_DHCP {PROTO_DHCP, 1 }
  268. #define OPT_VER_MADCAP_V4 {PROTO_MADCAP_V4, 0 }
  269. #define OPT_VER_MADCAP_V6 {PROTO_MADCAP_V6, 0 }
  270. // default mcast_ttl value.
  271. #define DEFAULT_MCAST_TTL 32
  272. //
  273. // Different option values for the DYNDNS_BOTH option ...
  274. //
  275. #define DYNDNS_S_BIT 0x01
  276. #define DYNDNS_O_BIT 0x02
  277. #define DYNDNS_E_BIT 0x04
  278. #define IS_CLIENT_DOING_A_AND_PTR(X) (((X)&DYNDNS_S_BIT)== 0)
  279. #define DYNDNS_REGISTER_AT_CLIENT 0 // Client will do both registrations
  280. #define DYNDNS_REGISTER_AT_SERVER 1 // Server will do registrations
  281. #define DYNDNS_DOWNLEVEL_CLIENT 0xFFFF // arbitraty # diff from above
  282. //
  283. // Microsoft-specific options
  284. //
  285. #define OPTION_MSFT_DSDOMAINNAME_REQ 94 // send me your DS Domain name
  286. #define OPTION_MSFT_DSDOMAINNAME_RESP 95 // sending my DS Domain name
  287. #define OPTION_MSFT_CONTINUED 250 // the previous option is being continued..
  288. #define OPTION_MSFT_AUTOCONF 251 // enable disable autoconf
  289. #define OPTION_MSFT_IE_PROXY 252 // IE5 proxy <string type>
  290. #define OPTION_MSFT_SERVER_APPL 253 // has a struct.
  291. #define OPTION_MSFT_VENDOR_NETBIOSLESS 1 // vendor option # 1
  292. #define OPTION_MSFT_VENDOR_FEATURELIST 2 // vendor option # 2
  293. #define BIT_RELEASE_ON_SHUTDOWN 0x01 // release on shutdown bit in feature list
  294. #define OPTION_MSFT_VENDOR_METRIC_BASE 3 // default gateway base metric.
  295. #define AUTOCONF_ENABLED 1
  296. #define AUTOCONF_DISABLED 0
  297. //
  298. // DHCP Message types
  299. //
  300. #define DHCP_DISCOVER_MESSAGE 1
  301. #define DHCP_OFFER_MESSAGE 2
  302. #define DHCP_REQUEST_MESSAGE 3
  303. #define DHCP_DECLINE_MESSAGE 4
  304. #define DHCP_ACK_MESSAGE 5
  305. #define DHCP_NACK_MESSAGE 6
  306. #define DHCP_RELEASE_MESSAGE 7
  307. #define DHCP_INFORM_MESSAGE 8
  308. #define DHCP_MAGIC_COOKIE_BYTE1 99
  309. #define DHCP_MAGIC_COOKIE_BYTE2 130
  310. #define DHCP_MAGIC_COOKIE_BYTE3 83
  311. #define DHCP_MAGIC_COOKIE_BYTE4 99
  312. #define BOOT_FILE_SIZE 128
  313. #define BOOT_SERVER_SIZE 64
  314. #define BOOT_FILE_SIZE_W ( BOOT_FILE_SIZE * sizeof( WCHAR ))
  315. #define BOOT_SERVER_SIZE_W ( BOOT_SERVER_SIZE * sizeof( WCHAR ))
  316. //
  317. // DHCP APP names - used to indentify to the eventlogger.
  318. //
  319. #define DHCP_EVENT_CLIENT TEXT("Dhcp")
  320. #define DHCP_EVENT_SERVER TEXT("DhcpServer")
  321. typedef struct _OPTION {
  322. BYTE OptionType;
  323. BYTE OptionLength;
  324. BYTE OptionValue[1];
  325. } OPTION, *POPTION, *LPOPTION;
  326. typedef struct _WIDE_OPTION {
  327. WORD OptionType;
  328. WORD OptionLength;
  329. BYTE OptionValue[1];
  330. } WIDE_OPTION, *PWIDE_OPTION, *LPWIDE_OPTION;
  331. //
  332. // A DHCP message buffer
  333. //
  334. #pragma pack(1) /* Assume byte packing */
  335. typedef struct _DHCP_MESSAGE {
  336. BYTE Operation;
  337. BYTE HardwareAddressType;
  338. BYTE HardwareAddressLength;
  339. BYTE HopCount;
  340. DWORD TransactionID;
  341. WORD SecondsSinceBoot;
  342. WORD Reserved;
  343. DHCP_IP_ADDRESS ClientIpAddress;
  344. DHCP_IP_ADDRESS YourIpAddress;
  345. DHCP_IP_ADDRESS BootstrapServerAddress;
  346. DHCP_IP_ADDRESS RelayAgentIpAddress;
  347. BYTE HardwareAddress[16];
  348. BYTE HostName[ BOOT_SERVER_SIZE ];
  349. BYTE BootFileName[BOOT_FILE_SIZE];
  350. OPTION Option;
  351. } DHCP_MESSAGE, *PDHCP_MESSAGE, *LPDHCP_MESSAGE;
  352. typedef struct _MADCAP_MESSAGE {
  353. BYTE Version;
  354. BYTE MessageType;
  355. WORD AddressFamily;
  356. DWORD TransactionID;
  357. // DHCP_IP_ADDRESS ClientIpAddress;
  358. // DHCP_IP_ADDRESS YourIpAddress;
  359. WIDE_OPTION Option;
  360. } MADCAP_MESSAGE, *PMADCAP_MESSAGE, *LPMADCAP_MESSAGE;
  361. #pragma pack()
  362. #define DHCP_MESSAGE_FIXED_PART_SIZE \
  363. (sizeof(DHCP_MESSAGE) - sizeof(OPTION))
  364. #define MADCAP_MESSAGE_FIXED_PART_SIZE \
  365. (sizeof(MADCAP_MESSAGE) - sizeof (WIDE_OPTION))
  366. #define DHCP_MIN_SEND_RECV_PK_SIZE \
  367. (DHCP_MESSAGE_FIXED_PART_SIZE + 64)
  368. //
  369. // Per message structure... Most of the structures here point within the
  370. // message.
  371. typedef struct _DHCP_SERVER_OPTIONS {
  372. BYTE *MessageType;
  373. DHCP_IP_ADDRESS UNALIGNED *SubnetMask;
  374. DHCP_IP_ADDRESS UNALIGNED *RequestedAddress;
  375. DWORD UNALIGNED *RequestLeaseTime;
  376. BYTE *OverlayFields;
  377. DHCP_IP_ADDRESS UNALIGNED *RouterAddress;
  378. DHCP_IP_ADDRESS UNALIGNED *Server;
  379. BYTE *ParameterRequestList;
  380. DWORD ParameterRequestListLength;
  381. CHAR *MachineName;
  382. DWORD MachineNameLength;
  383. BYTE ClientHardwareAddressType;
  384. BYTE ClientHardwareAddressLength;
  385. BYTE *ClientHardwareAddress;
  386. CHAR *ClassIdentifier;
  387. DWORD ClassIdentifierLength;
  388. BYTE *VendorClass;
  389. DWORD VendorClassLength;
  390. DWORD DNSFlags;
  391. DWORD DNSNameLength;
  392. LPBYTE DNSName;
  393. BOOLEAN DSDomainNameRequested;
  394. CHAR *DSDomainName;
  395. DWORD DSDomainNameLen;
  396. USHORT SystemArchitecture;
  397. DWORD SystemArchitectureLength;
  398. CHAR *NetworkInterfaceType;
  399. DWORD NetworkInterfaceTypeLength;
  400. CHAR *Guid;
  401. DWORD GuidLength;
  402. } DHCP_SERVER_OPTIONS, *LPDHCP_SERVER_OPTIONS;
  403. typedef struct _MADCAP_SERVER_OPTIONS {
  404. BYTE UNALIGNED *AddrRangeList;
  405. WORD AddrRangeListSize;
  406. DWORD UNALIGNED *RequestLeaseTime;
  407. DWORD UNALIGNED *LeaseStartTime;
  408. DHCP_IP_ADDRESS UNALIGNED *Server;
  409. BYTE *RequestList;
  410. WORD RequestListLength;
  411. DWORD UNALIGNED *ScopeId;
  412. CHAR *Guid;
  413. WORD GuidLength;
  414. WORD UNALIGNED *MinAddrCount;
  415. WORD UNALIGNED *AddrCount;
  416. BYTE *RequestLang;
  417. WORD RequestLangLength;
  418. DWORD UNALIGNED *Time;
  419. WORD UNALIGNED *Features[3];
  420. WORD FeatureCount[3];
  421. DWORD UNALIGNED *RetryTime;
  422. DWORD UNALIGNED *MinLeaseTime;
  423. DWORD UNALIGNED *MaxStartTime;
  424. BOOL OptPresent[MADCAP_OPTION_TOTAL];
  425. } MADCAP_SERVER_OPTIONS, *LPMADCAP_SERVER_OPTIONS;
  426. // the indices for Features array above
  427. enum {
  428. SUPPORTED_FEATURES, REQUESTED_FEATURES, REQUIRED_FEATURES
  429. };
  430. //
  431. // JET - DHCP database constants.
  432. //
  433. #define DB_TABLE_SIZE 10 // table size in 4K pages.
  434. #define DB_TABLE_DENSITY 80 // page density
  435. #define DB_LANGID 0x0409 // language id
  436. #define DB_CP 1252 // code page
  437. #if DBG
  438. //
  439. // debug functions.
  440. //
  441. #ifdef CHICAGO // No Tracing available on CHICAGO
  442. #define DhcpPrintTrace
  443. #endif
  444. #define IF_DEBUG(flag) if (DhcpGlobalDebugFlag & (DEBUG_ ## flag))
  445. #define DhcpPrint(_x_) DhcpPrintRoutine _x_
  446. #define Trace DhcpPrintTrace
  447. #ifndef CHICAGO
  448. VOID
  449. DhcpPrintTrace(
  450. IN LPSTR Format,
  451. ...
  452. );
  453. #endif
  454. VOID
  455. DhcpPrintRoutine(
  456. IN DWORD DebugFlag,
  457. IN LPSTR Format,
  458. ...
  459. );
  460. #else
  461. #define IF_DEBUG(flag) if (FALSE)
  462. #define DhcpPrint(_x_)
  463. #define Trace (void)
  464. #endif // DBG
  465. #define OpenDriver DhcpOpenDriver
  466. #endif // _DHCP_