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