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.

dhcp.h 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. #ifndef _IPXE_DHCP_H
  2. #define _IPXE_DHCP_H
  3. /** @file
  4. *
  5. * Dynamic Host Configuration Protocol
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #include <stdarg.h>
  11. #include <ipxe/in.h>
  12. #include <ipxe/list.h>
  13. #include <ipxe/refcnt.h>
  14. #include <ipxe/tables.h>
  15. #include <ipxe/uuid.h>
  16. #include <ipxe/netdevice.h>
  17. #include <ipxe/uaccess.h>
  18. struct interface;
  19. struct dhcp_options;
  20. struct dhcp_packet;
  21. /** BOOTP/DHCP server port */
  22. #define BOOTPS_PORT 67
  23. /** BOOTP/DHCP client port */
  24. #define BOOTPC_PORT 68
  25. /** PXE server port */
  26. #define PXE_PORT 4011
  27. /** Construct a tag value for an encapsulated option
  28. *
  29. * This tag value can be passed to Etherboot functions when searching
  30. * for DHCP options in order to search for a tag within an
  31. * encapsulated options block.
  32. */
  33. #define DHCP_ENCAP_OPT( encapsulator, encapsulated ) \
  34. ( ( (encapsulator) << 8 ) | (encapsulated) )
  35. /** Extract encapsulating option block tag from encapsulated tag value */
  36. #define DHCP_ENCAPSULATOR( encap_opt ) ( (encap_opt) >> 8 )
  37. /** Extract encapsulated option tag from encapsulated tag value */
  38. #define DHCP_ENCAPSULATED( encap_opt ) ( (encap_opt) & 0xff )
  39. /** Option is encapsulated */
  40. #define DHCP_IS_ENCAP_OPT( opt ) DHCP_ENCAPSULATOR( opt )
  41. /**
  42. * @defgroup dhcpopts DHCP option tags
  43. * @{
  44. */
  45. /** Padding
  46. *
  47. * This tag does not have a length field; it is always only a single
  48. * byte in length.
  49. */
  50. #define DHCP_PAD 0
  51. /** Minimum normal DHCP option */
  52. #define DHCP_MIN_OPTION 1
  53. /** Subnet mask */
  54. #define DHCP_SUBNET_MASK 1
  55. /** Routers */
  56. #define DHCP_ROUTERS 3
  57. /** DNS servers */
  58. #define DHCP_DNS_SERVERS 6
  59. /** Syslog servers */
  60. #define DHCP_LOG_SERVERS 7
  61. /** Host name */
  62. #define DHCP_HOST_NAME 12
  63. /** Domain name */
  64. #define DHCP_DOMAIN_NAME 15
  65. /** Root path */
  66. #define DHCP_ROOT_PATH 17
  67. /** Vendor encapsulated options */
  68. #define DHCP_VENDOR_ENCAP 43
  69. /** PXE boot server discovery control */
  70. #define DHCP_PXE_DISCOVERY_CONTROL DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 6 )
  71. /** PXE boot server discovery control bits */
  72. enum dhcp_pxe_discovery_control {
  73. /** Inhibit broadcast discovery */
  74. PXEBS_NO_BROADCAST = 1,
  75. /** Inhibit multicast discovery */
  76. PXEBS_NO_MULTICAST = 2,
  77. /** Accept only servers in DHCP_PXE_BOOT_SERVERS list */
  78. PXEBS_NO_UNKNOWN_SERVERS = 4,
  79. /** Skip discovery if filename present */
  80. PXEBS_SKIP = 8,
  81. };
  82. /** PXE boot server multicast address */
  83. #define DHCP_PXE_BOOT_SERVER_MCAST DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 7 )
  84. /** PXE boot servers */
  85. #define DHCP_PXE_BOOT_SERVERS DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 8 )
  86. /** PXE boot server */
  87. struct dhcp_pxe_boot_server {
  88. /** "Type" */
  89. uint16_t type;
  90. /** Number of IPv4 addresses */
  91. uint8_t num_ip;
  92. /** IPv4 addresses */
  93. struct in_addr ip[0];
  94. } __attribute__ (( packed ));
  95. /** PXE boot menu */
  96. #define DHCP_PXE_BOOT_MENU DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 9 )
  97. /** PXE boot menu */
  98. struct dhcp_pxe_boot_menu {
  99. /** "Type" */
  100. uint16_t type;
  101. /** Description length */
  102. uint8_t desc_len;
  103. /** Description */
  104. char desc[0];
  105. } __attribute__ (( packed ));
  106. /** PXE boot menu prompt */
  107. #define DHCP_PXE_BOOT_MENU_PROMPT DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 10 )
  108. /** PXE boot menu prompt */
  109. struct dhcp_pxe_boot_menu_prompt {
  110. /** Timeout
  111. *
  112. * A value of 0 means "time out immediately and select first
  113. * boot item, without displaying the prompt". A value of 255
  114. * means "display menu immediately with no timeout". Any
  115. * other value means "display prompt, wait this many seconds
  116. * for keypress, if key is F8, display menu, otherwise select
  117. * first boot item".
  118. */
  119. uint8_t timeout;
  120. /** Prompt to press F8 */
  121. char prompt[0];
  122. } __attribute__ (( packed ));
  123. /** PXE boot menu item */
  124. #define DHCP_PXE_BOOT_MENU_ITEM DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 71 )
  125. /** PXE boot menu item */
  126. struct dhcp_pxe_boot_menu_item {
  127. /** "Type"
  128. *
  129. * This field actually identifies the specific boot server (or
  130. * cluster of boot servers offering identical boot files).
  131. */
  132. uint16_t type;
  133. /** "Layer"
  134. *
  135. * Just don't ask.
  136. */
  137. uint16_t layer;
  138. } __attribute__ (( packed ));
  139. /** Requested IP address */
  140. #define DHCP_REQUESTED_ADDRESS 50
  141. /** Lease time */
  142. #define DHCP_LEASE_TIME 51
  143. /** Option overloading
  144. *
  145. * The value of this option is the bitwise-OR of zero or more
  146. * DHCP_OPTION_OVERLOAD_XXX constants.
  147. */
  148. #define DHCP_OPTION_OVERLOAD 52
  149. /** The "file" field is overloaded to contain extra DHCP options */
  150. #define DHCP_OPTION_OVERLOAD_FILE 1
  151. /** The "sname" field is overloaded to contain extra DHCP options */
  152. #define DHCP_OPTION_OVERLOAD_SNAME 2
  153. /** DHCP message type */
  154. #define DHCP_MESSAGE_TYPE 53
  155. #define DHCPNONE 0
  156. #define DHCPDISCOVER 1
  157. #define DHCPOFFER 2
  158. #define DHCPREQUEST 3
  159. #define DHCPDECLINE 4
  160. #define DHCPACK 5
  161. #define DHCPNAK 6
  162. #define DHCPRELEASE 7
  163. #define DHCPINFORM 8
  164. /** DHCP server identifier */
  165. #define DHCP_SERVER_IDENTIFIER 54
  166. /** Parameter request list */
  167. #define DHCP_PARAMETER_REQUEST_LIST 55
  168. /** Maximum DHCP message size */
  169. #define DHCP_MAX_MESSAGE_SIZE 57
  170. /** Vendor class identifier */
  171. #define DHCP_VENDOR_CLASS_ID 60
  172. /** Client identifier */
  173. #define DHCP_CLIENT_ID 61
  174. /** Client identifier */
  175. struct dhcp_client_id {
  176. /** Link-layer protocol */
  177. uint8_t ll_proto;
  178. /** Link-layer address */
  179. uint8_t ll_addr[MAX_LL_ADDR_LEN];
  180. } __attribute__ (( packed ));
  181. /** TFTP server name
  182. *
  183. * This option replaces the fixed "sname" field, when that field is
  184. * used to contain overloaded options.
  185. */
  186. #define DHCP_TFTP_SERVER_NAME 66
  187. /** Bootfile name
  188. *
  189. * This option replaces the fixed "file" field, when that field is
  190. * used to contain overloaded options.
  191. */
  192. #define DHCP_BOOTFILE_NAME 67
  193. /** User class identifier */
  194. #define DHCP_USER_CLASS_ID 77
  195. /** Client system architecture */
  196. #define DHCP_CLIENT_ARCHITECTURE 93
  197. /** DHCP client architecture */
  198. struct dhcp_client_architecture {
  199. uint16_t arch;
  200. } __attribute__ (( packed ));
  201. /** DHCP client architecture values
  202. *
  203. * These are defined by the PXE specification and redefined by
  204. * RFC4578.
  205. */
  206. enum dhcp_client_architecture_values {
  207. /** Intel x86 PC */
  208. DHCP_CLIENT_ARCHITECTURE_X86 = 0x0000,
  209. /** NEC/PC98 */
  210. DHCP_CLIENT_ARCHITECTURE_PC98 = 0x0001,
  211. /** EFI Itanium */
  212. DHCP_CLIENT_ARCHITECTURE_IA64 = 0x0002,
  213. /** DEC Alpha */
  214. DHCP_CLIENT_ARCHITECTURE_ALPHA = 0x0003,
  215. /** Arc x86 */
  216. DHCP_CLIENT_ARCHITECTURE_ARCX86 = 0x0004,
  217. /** Intel Lean Client */
  218. DHCP_CLIENT_ARCHITECTURE_LC = 0x0005,
  219. /** EFI IA32 */
  220. DHCP_CLIENT_ARCHITECTURE_IA32 = 0x0006,
  221. /** EFI BC */
  222. DHCP_CLIENT_ARCHITECTURE_EFI = 0x0007,
  223. /** EFI Xscale */
  224. DHCP_CLIENT_ARCHITECTURE_XSCALE = 0x0008,
  225. /** EFI x86-64 */
  226. DHCP_CLIENT_ARCHITECTURE_X86_64 = 0x0009,
  227. };
  228. /** Client network device interface */
  229. #define DHCP_CLIENT_NDI 94
  230. /** UUID client identifier */
  231. #define DHCP_CLIENT_UUID 97
  232. /** UUID client identifier */
  233. struct dhcp_client_uuid {
  234. /** Identifier type */
  235. uint8_t type;
  236. /** UUID */
  237. union uuid uuid;
  238. } __attribute__ (( packed ));
  239. #define DHCP_CLIENT_UUID_TYPE 0
  240. /** DNS domain search list */
  241. #define DHCP_DOMAIN_SEARCH 119
  242. /** Etherboot-specific encapsulated options
  243. *
  244. * This encapsulated options field is used to contain all options
  245. * specific to Etherboot (i.e. not assigned by IANA or other standards
  246. * bodies).
  247. */
  248. #define DHCP_EB_ENCAP 175
  249. /** Priority of this options block
  250. *
  251. * This is a signed 8-bit integer field indicating the priority of
  252. * this block of options. It can be used to specify the relative
  253. * priority of multiple option blocks (e.g. options from non-volatile
  254. * storage versus options from a DHCP server).
  255. */
  256. #define DHCP_EB_PRIORITY DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x01 )
  257. /** "Your" IP address
  258. *
  259. * This option is used internally to contain the value of the "yiaddr"
  260. * field, in order to provide a consistent approach to storing and
  261. * processing options. It should never be present in a DHCP packet.
  262. */
  263. #define DHCP_EB_YIADDR DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x02 )
  264. /** "Server" IP address
  265. *
  266. * This option is used internally to contain the value of the "siaddr"
  267. * field, in order to provide a consistent approach to storing and
  268. * processing options. It should never be present in a DHCP packet.
  269. */
  270. #define DHCP_EB_SIADDR DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x03 )
  271. /** Keep SAN drive registered
  272. *
  273. * If set to a non-zero value, iPXE will not detach any SAN drive
  274. * after failing to boot from it. (This option is required in order
  275. * to perform an installation direct to an iSCSI target.)
  276. */
  277. #define DHCP_EB_KEEP_SAN DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x08 )
  278. /** Skip booting from SAN drive
  279. *
  280. * If set to a non-zero value, iPXE will skip booting from any SAN
  281. * drive. (This option is sometimes required in conjunction with @c
  282. * DHCP_EB_KEEP_SAN in order to perform an installation direct to an
  283. * iSCSI target.)
  284. */
  285. #define DHCP_EB_SKIP_SAN_BOOT DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x09 )
  286. /*
  287. * Tags in the range 0x10-0x4f are reserved for feature markers
  288. *
  289. */
  290. /** Scriptlet
  291. *
  292. * If a scriptlet exists, it will be executed in place of the usual
  293. * call to autoboot()
  294. */
  295. #define DHCP_EB_SCRIPTLET DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x51 )
  296. /** Encrypted syslog server */
  297. #define DHCP_EB_SYSLOGS_SERVER DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x55 )
  298. /** Trusted root certficate fingerprints */
  299. #define DHCP_EB_TRUST DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x5a )
  300. /** Client certficate */
  301. #define DHCP_EB_CERT DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x5b )
  302. /** Client private key */
  303. #define DHCP_EB_KEY DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x5c )
  304. /** Cross-signed certificate source */
  305. #define DHCP_EB_CROSS_CERT DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x5d )
  306. /** Skip PXE DHCP protocol extensions such as ProxyDHCP
  307. *
  308. * If set to a non-zero value, iPXE will not wait for ProxyDHCP offers
  309. * and will ignore any PXE-specific DHCP options that it receives.
  310. */
  311. #define DHCP_EB_NO_PXEDHCP DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xb0 )
  312. /** Network device descriptor
  313. *
  314. * Byte 0 is the bus type ID; remaining bytes depend on the bus type.
  315. *
  316. * PCI devices:
  317. * Byte 0 : 1 (PCI)
  318. * Byte 1 : PCI vendor ID MSB
  319. * Byte 2 : PCI vendor ID LSB
  320. * Byte 3 : PCI device ID MSB
  321. * Byte 4 : PCI device ID LSB
  322. */
  323. #define DHCP_EB_BUS_ID DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xb1 )
  324. /** Network device descriptor */
  325. struct dhcp_netdev_desc {
  326. /** Bus type ID */
  327. uint8_t type;
  328. /** Vendor ID */
  329. uint16_t vendor;
  330. /** Device ID */
  331. uint16_t device;
  332. } __attribute__ (( packed ));
  333. /** Use cached network settings (obsolete; do not reuse this value) */
  334. #define DHCP_EB_USE_CACHED DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xb2 )
  335. /** BIOS drive number
  336. *
  337. * This is the drive number for a drive emulated via INT 13. 0x80 is
  338. * the first hard disk, 0x81 is the second hard disk, etc.
  339. */
  340. #define DHCP_EB_BIOS_DRIVE DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xbd )
  341. /** Username
  342. *
  343. * This will be used as the username for any required authentication.
  344. * It is expected that this option's value will be held in
  345. * non-volatile storage, rather than transmitted as part of a DHCP
  346. * packet.
  347. */
  348. #define DHCP_EB_USERNAME DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xbe )
  349. /** Password
  350. *
  351. * This will be used as the password for any required authentication.
  352. * It is expected that this option's value will be held in
  353. * non-volatile storage, rather than transmitted as part of a DHCP
  354. * packet.
  355. */
  356. #define DHCP_EB_PASSWORD DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xbf )
  357. /** Reverse username
  358. *
  359. * This will be used as the reverse username (i.e. the username
  360. * provided by the server) for any required authentication. It is
  361. * expected that this option's value will be held in non-volatile
  362. * storage, rather than transmitted as part of a DHCP packet.
  363. */
  364. #define DHCP_EB_REVERSE_USERNAME DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xc0 )
  365. /** Reverse password
  366. *
  367. * This will be used as the reverse password (i.e. the password
  368. * provided by the server) for any required authentication. It is
  369. * expected that this option's value will be held in non-volatile
  370. * storage, rather than transmitted as part of a DHCP packet.
  371. */
  372. #define DHCP_EB_REVERSE_PASSWORD DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xc1 )
  373. /** User ID
  374. *
  375. * This will be used as the user id for AUTH_SYS based authentication in NFS.
  376. */
  377. #define DHCP_EB_UID DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xc2 )
  378. /** Group ID
  379. *
  380. * This will be used as the group id for AUTH_SYS based authentication in NFS.
  381. */
  382. #define DHCP_EB_GID DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xc3 )
  383. /** iPXE version number */
  384. #define DHCP_EB_VERSION DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xeb )
  385. /** iSCSI primary target IQN */
  386. #define DHCP_ISCSI_PRIMARY_TARGET_IQN 201
  387. /** iSCSI secondary target IQN */
  388. #define DHCP_ISCSI_SECONDARY_TARGET_IQN 202
  389. /** iSCSI initiator IQN */
  390. #define DHCP_ISCSI_INITIATOR_IQN 203
  391. /** Maximum normal DHCP option */
  392. #define DHCP_MAX_OPTION 254
  393. /** End of options
  394. *
  395. * This tag does not have a length field; it is always only a single
  396. * byte in length.
  397. */
  398. #define DHCP_END 255
  399. /** @} */
  400. /** Construct a DHCP option from a list of bytes */
  401. #define DHCP_OPTION( ... ) VA_ARG_COUNT ( __VA_ARGS__ ), __VA_ARGS__
  402. /** Construct a DHCP option from a list of characters */
  403. #define DHCP_STRING( ... ) DHCP_OPTION ( __VA_ARGS__ )
  404. /** Construct a byte-valued DHCP option */
  405. #define DHCP_BYTE( value ) DHCP_OPTION ( value )
  406. /** Construct a word-valued DHCP option */
  407. #define DHCP_WORD( value ) DHCP_OPTION ( ( ( (value) >> 8 ) & 0xff ), \
  408. ( ( (value) >> 0 ) & 0xff ) )
  409. /** Construct a dword-valued DHCP option */
  410. #define DHCP_DWORD( value ) DHCP_OPTION ( ( ( (value) >> 24 ) & 0xff ), \
  411. ( ( (value) >> 16 ) & 0xff ), \
  412. ( ( (value) >> 8 ) & 0xff ), \
  413. ( ( (value) >> 0 ) & 0xff ) )
  414. /** Construct a DHCP encapsulated options field */
  415. #define DHCP_ENCAP( ... ) DHCP_OPTION ( __VA_ARGS__, DHCP_END )
  416. /**
  417. * A DHCP option
  418. *
  419. * DHCP options consist of a mandatory tag, a length field that is
  420. * mandatory for all options except @c DHCP_PAD and @c DHCP_END, and a
  421. * payload.
  422. */
  423. struct dhcp_option {
  424. /** Tag
  425. *
  426. * Must be a @c DHCP_XXX value.
  427. */
  428. uint8_t tag;
  429. /** Length
  430. *
  431. * This is the length of the data field (i.e. excluding the
  432. * tag and length fields). For the two tags @c DHCP_PAD and
  433. * @c DHCP_END, the length field is implicitly zero and is
  434. * also missing, i.e. these DHCP options are only a single
  435. * byte in length.
  436. */
  437. uint8_t len;
  438. /** Option data */
  439. uint8_t data[0];
  440. } __attribute__ (( packed ));
  441. /**
  442. * Length of a DHCP option header
  443. *
  444. * The header is the portion excluding the data, i.e. the tag and the
  445. * length.
  446. */
  447. #define DHCP_OPTION_HEADER_LEN ( offsetof ( struct dhcp_option, data ) )
  448. /** Maximum length for a single DHCP option */
  449. #define DHCP_MAX_LEN 0xff
  450. /**
  451. * A DHCP header
  452. *
  453. */
  454. struct dhcphdr {
  455. /** Operation
  456. *
  457. * This must be either @c BOOTP_REQUEST or @c BOOTP_REPLY.
  458. */
  459. uint8_t op;
  460. /** Hardware address type
  461. *
  462. * This is an ARPHRD_XXX constant. Note that ARPHRD_XXX
  463. * constants are nominally 16 bits wide; this could be
  464. * considered to be a bug in the BOOTP/DHCP specification.
  465. */
  466. uint8_t htype;
  467. /** Hardware address length */
  468. uint8_t hlen;
  469. /** Number of hops from server */
  470. uint8_t hops;
  471. /** Transaction ID */
  472. uint32_t xid;
  473. /** Seconds since start of acquisition */
  474. uint16_t secs;
  475. /** Flags */
  476. uint16_t flags;
  477. /** "Client" IP address
  478. *
  479. * This is filled in if the client already has an IP address
  480. * assigned and can respond to ARP requests.
  481. */
  482. struct in_addr ciaddr;
  483. /** "Your" IP address
  484. *
  485. * This is the IP address assigned by the server to the client.
  486. */
  487. struct in_addr yiaddr;
  488. /** "Server" IP address
  489. *
  490. * This is the IP address of the next server to be used in the
  491. * boot process.
  492. */
  493. struct in_addr siaddr;
  494. /** "Gateway" IP address
  495. *
  496. * This is the IP address of the DHCP relay agent, if any.
  497. */
  498. struct in_addr giaddr;
  499. /** Client hardware address */
  500. uint8_t chaddr[16];
  501. /** Server host name (null terminated)
  502. *
  503. * This field may be overridden and contain DHCP options
  504. */
  505. char sname[64];
  506. /** Boot file name (null terminated)
  507. *
  508. * This field may be overridden and contain DHCP options
  509. */
  510. char file[128];
  511. /** DHCP magic cookie
  512. *
  513. * Must have the value @c DHCP_MAGIC_COOKIE.
  514. */
  515. uint32_t magic;
  516. /** DHCP options
  517. *
  518. * Variable length; extends to the end of the packet. Minimum
  519. * length (for the sake of sanity) is 1, to allow for a single
  520. * @c DHCP_END tag.
  521. */
  522. uint8_t options[0];
  523. };
  524. /** Opcode for a request from client to server */
  525. #define BOOTP_REQUEST 1
  526. /** Opcode for a reply from server to client */
  527. #define BOOTP_REPLY 2
  528. /** BOOTP reply must be broadcast
  529. *
  530. * Clients that cannot accept unicast BOOTP replies must set this
  531. * flag.
  532. */
  533. #define BOOTP_FL_BROADCAST 0x8000
  534. /** DHCP magic cookie */
  535. #define DHCP_MAGIC_COOKIE 0x63825363UL
  536. /** DHCP minimum packet length
  537. *
  538. * This is the mandated minimum packet length that a DHCP participant
  539. * must be prepared to receive.
  540. */
  541. #define DHCP_MIN_LEN 552
  542. /** Settings block name used for DHCP responses */
  543. #define DHCP_SETTINGS_NAME "dhcp"
  544. /** Settings block name used for ProxyDHCP responses */
  545. #define PROXYDHCP_SETTINGS_NAME "proxydhcp"
  546. /** Setting block name used for BootServerDHCP responses */
  547. #define PXEBS_SETTINGS_NAME "pxebs"
  548. extern uint32_t dhcp_last_xid;
  549. extern int dhcp_create_packet ( struct dhcp_packet *dhcppkt,
  550. struct net_device *netdev, uint8_t msgtype,
  551. uint32_t xid, const void *options,
  552. size_t options_len, void *data,
  553. size_t max_len );
  554. extern int dhcp_create_request ( struct dhcp_packet *dhcppkt,
  555. struct net_device *netdev,
  556. unsigned int msgtype, uint32_t xid,
  557. struct in_addr ciaddr,
  558. void *data, size_t max_len );
  559. extern int start_dhcp ( struct interface *job, struct net_device *netdev );
  560. extern int start_pxebs ( struct interface *job, struct net_device *netdev,
  561. unsigned int pxe_type );
  562. #endif /* _IPXE_DHCP_H */