david/ipxe
Archived
1
0
This repository has been archived on 2020-12-06. You can view files and clone it, but cannot push or open issues or pull requests.
ipxe/src/include/gpxe/dhcp.h

88 lines
2.1 KiB
C
Raw Normal View History

#ifndef _GPXE_DHCP_H
#define _GPXE_DHCP_H
/** @file
*
* Dynamic Host Configuration Protocol
*
*/
#include <stdint.h>
#include <gpxe/list.h>
/** Construct a tag value for an encapsulated option
*
* This tag value can be passed to Etherboot functions when searching
* for DHCP options in order to search for a tag within an
* encapsulated options block.
*/
#define DHCP_ENCAP_OPT( encapsulator, encapsulated ) \
( ( (encapsulator) << 8 ) | (encapsulated) )
/** Extract encapsulating option block tag from encapsulated tag value */
#define DHCP_ENCAPSULATOR( encap_opt ) ( (encap_opt) >> 8 )
/** Extract encapsulated option tag from encapsulated tag value */
#define DHCP_ENCAPSULATED( encap_opt ) ( (encap_opt) & 0xff )
/**
* @defgroup dhcpopts DHCP option tags
* @{
*/
#define DHCP_PAD 0
#define DHCP_END 255
#define DHCP_EB_ENCAP 175
#define DHCP_EB_PRIORITY DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 1 )
/** @} */
/**
* A DHCP option
*
* DHCP options consist of a mandatory tag, a length field that is
* mandatory for all options except @c DHCP_PAD and @c DHCP_END, and a
* payload.
*/
struct dhcp_option {
/** Tag
*
* Must be a @c DHCP_XXX value.
*/
uint8_t tag;
/** Length
*
* This is the length of the data field (i.e. excluding the
* tag and length fields). For the two tags @c DHCP_PAD and
* @c DHCP_END, the length field is implicitly zero and is
* also missing, i.e. these DHCP options are only a single
* byte in length.
*/
uint8_t len;
/** Option data
*
* Interpretation of the content is entirely dependent upon
* the tag. For fields containing a multi-byte integer, the
* field is defined to be in network-endian order (unless you
* are Intel and feel like violating the spec for fun).
*/
union {
uint8_t byte;
uint16_t word;
uint32_t dword;
uint8_t bytes[0];
} data;
} __attribute__ (( packed ));
/** A DHCP options block */
struct dhcp_option_block {
/** List of option blocks */
struct list_head list;
/** Option block raw data */
void *data;
/** Option block length */
size_t len;
};
#endif /* _GPXE_DHCP_H */