iPXE
|
Dynamic Host Configuration Protocol. More...
#include <stdint.h>
#include <stdarg.h>
#include <ipxe/in.h>
#include <ipxe/list.h>
#include <ipxe/refcnt.h>
#include <ipxe/tables.h>
#include <ipxe/uuid.h>
#include <ipxe/netdevice.h>
#include <ipxe/uaccess.h>
Go to the source code of this file.
Data Structures | |
struct | dhcp_pxe_boot_server |
PXE boot server. More... | |
struct | dhcp_pxe_boot_menu |
PXE boot menu. More... | |
struct | dhcp_pxe_boot_menu_prompt |
PXE boot menu prompt. More... | |
struct | dhcp_pxe_boot_menu_item |
PXE boot menu item. More... | |
struct | dhcp_client_id |
Client identifier. More... | |
struct | dhcp_client_architecture |
DHCP client architecture. More... | |
struct | dhcp_client_uuid |
UUID client identifier. More... | |
struct | dhcp_netdev_desc |
Network device descriptor. More... | |
struct | dhcp_option |
A DHCP option. More... | |
struct | dhcphdr |
A DHCP header. More... | |
Macros | |
#define | BOOTPS_PORT 67 |
BOOTP/DHCP server port. More... | |
#define | BOOTPC_PORT 68 |
BOOTP/DHCP client port. More... | |
#define | PXE_PORT 4011 |
PXE server port. More... | |
#define | DHCP_ENCAP_OPT(encapsulator, encapsulated) ( ( (encapsulator) << 8 ) | (encapsulated) ) |
Construct a tag value for an encapsulated option. More... | |
#define | DHCP_ENCAPSULATOR(encap_opt) ( (encap_opt) >> 8 ) |
Extract encapsulating option block tag from encapsulated tag value. More... | |
#define | DHCP_ENCAPSULATED(encap_opt) ( (encap_opt) & 0xff ) |
Extract encapsulated option tag from encapsulated tag value. More... | |
#define | DHCP_IS_ENCAP_OPT(opt) DHCP_ENCAPSULATOR( opt ) |
Option is encapsulated. More... | |
#define | DHCP_PAD 0 |
Padding. More... | |
#define | DHCP_MIN_OPTION 1 |
Minimum normal DHCP option. More... | |
#define | DHCP_SUBNET_MASK 1 |
Subnet mask. More... | |
#define | DHCP_ROUTERS 3 |
Routers. More... | |
#define | DHCP_DNS_SERVERS 6 |
DNS servers. More... | |
#define | DHCP_LOG_SERVERS 7 |
Syslog servers. More... | |
#define | DHCP_HOST_NAME 12 |
Host name. More... | |
#define | DHCP_DOMAIN_NAME 15 |
Domain name. More... | |
#define | DHCP_ROOT_PATH 17 |
Root path. More... | |
#define | DHCP_MTU 26 |
Maximum transmission unit. More... | |
#define | DHCP_NTP_SERVERS 42 |
NTP servers. More... | |
#define | DHCP_VENDOR_ENCAP 43 |
Vendor encapsulated options. More... | |
#define | DHCP_PXE_DISCOVERY_CONTROL DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 6 ) |
PXE boot server discovery control. More... | |
#define | DHCP_PXE_BOOT_SERVER_MCAST DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 7 ) |
PXE boot server multicast address. More... | |
#define | DHCP_PXE_BOOT_SERVERS DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 8 ) |
PXE boot servers. More... | |
#define | DHCP_PXE_BOOT_MENU DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 9 ) |
PXE boot menu. More... | |
#define | DHCP_PXE_BOOT_MENU_PROMPT DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 10 ) |
PXE boot menu prompt. More... | |
#define | DHCP_PXE_BOOT_MENU_ITEM DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 71 ) |
PXE boot menu item. More... | |
#define | DHCP_REQUESTED_ADDRESS 50 |
Requested IP address. More... | |
#define | DHCP_LEASE_TIME 51 |
Lease time. More... | |
#define | DHCP_OPTION_OVERLOAD 52 |
Option overloading. More... | |
#define | DHCP_OPTION_OVERLOAD_FILE 1 |
The "file" field is overloaded to contain extra DHCP options. More... | |
#define | DHCP_OPTION_OVERLOAD_SNAME 2 |
The "sname" field is overloaded to contain extra DHCP options. More... | |
#define | DHCP_MESSAGE_TYPE 53 |
DHCP message type. More... | |
#define | DHCPNONE 0 |
#define | DHCPDISCOVER 1 |
#define | DHCPOFFER 2 |
#define | DHCPREQUEST 3 |
#define | DHCPDECLINE 4 |
#define | DHCPACK 5 |
#define | DHCPNAK 6 |
#define | DHCPRELEASE 7 |
#define | DHCPINFORM 8 |
#define | DHCP_SERVER_IDENTIFIER 54 |
DHCP server identifier. More... | |
#define | DHCP_PARAMETER_REQUEST_LIST 55 |
Parameter request list. More... | |
#define | DHCP_MAX_MESSAGE_SIZE 57 |
Maximum DHCP message size. More... | |
#define | DHCP_VENDOR_CLASS_ID 60 |
Vendor class identifier. More... | |
#define | DHCP_VENDOR_PXECLIENT(arch, ndi) |
Vendor class identifier for PXE clients. More... | |
#define | DHCP_VENDOR_PXECLIENT_ARCH(arch) |
Vendor class identifier architecture for PXE clients. More... | |
#define | DHCP_VENDOR_PXECLIENT_UNDI(type, major, minor) |
Vendor class identifier UNDI version for PXE clients. More... | |
#define | DHCP_VENDOR_PXECLIENT_UNDI_VERSION(version) |
#define | DHCP_CLIENT_ID 61 |
Client identifier. More... | |
#define | DHCP_TFTP_SERVER_NAME 66 |
TFTP server name. More... | |
#define | DHCP_BOOTFILE_NAME 67 |
Bootfile name. More... | |
#define | DHCP_USER_CLASS_ID 77 |
User class identifier. More... | |
#define | DHCP_CLIENT_ARCHITECTURE 93 |
Client system architecture. More... | |
#define | DHCP_CLIENT_NDI 94 |
Client network device interface. More... | |
#define | DHCP_CLIENT_UUID 97 |
UUID client identifier. More... | |
#define | DHCP_CLIENT_UUID_TYPE 0 |
#define | DHCP_DOMAIN_SEARCH 119 |
DNS domain search list. More... | |
#define | DHCP_EB_ENCAP 175 |
Etherboot-specific encapsulated options. More... | |
#define | DHCP_EB_PRIORITY DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x01 ) |
Priority of this options block. More... | |
#define | DHCP_EB_YIADDR DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x02 ) |
"Your" IP address More... | |
#define | DHCP_EB_SIADDR DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x03 ) |
"Server" IP address More... | |
#define | DHCP_EB_KEEP_SAN DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x08 ) |
Keep SAN drive registered. More... | |
#define | DHCP_EB_SKIP_SAN_BOOT DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x09 ) |
Skip booting from SAN drive. More... | |
#define | DHCP_EB_SCRIPTLET DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x51 ) |
Scriptlet. More... | |
#define | DHCP_EB_SYSLOGS_SERVER DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x55 ) |
Encrypted syslog server. More... | |
#define | DHCP_EB_TRUST DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x5a ) |
Trusted root certficate fingerprints. More... | |
#define | DHCP_EB_CERT DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x5b ) |
Client certficate. More... | |
#define | DHCP_EB_KEY DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x5c ) |
Client private key. More... | |
#define | DHCP_EB_CROSS_CERT DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0x5d ) |
Cross-signed certificate source. More... | |
#define | DHCP_EB_NO_PXEDHCP DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xb0 ) |
Skip PXE DHCP protocol extensions such as ProxyDHCP. More... | |
#define | DHCP_EB_BUS_ID DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xb1 ) |
Network device descriptor. More... | |
#define | DHCP_EB_USE_CACHED DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xb2 ) |
Use cached network settings (obsolete; do not reuse this value) More... | |
#define | DHCP_EB_SAN_RETRY DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xbb ) |
SAN retry count. More... | |
#define | DHCP_EB_SAN_FILENAME DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xbc ) |
SAN filename. More... | |
#define | DHCP_EB_SAN_DRIVE DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xbd ) |
SAN drive number. More... | |
#define | DHCP_EB_USERNAME DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xbe ) |
Username. More... | |
#define | DHCP_EB_PASSWORD DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xbf ) |
Password. More... | |
#define | DHCP_EB_REVERSE_USERNAME DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xc0 ) |
Reverse username. More... | |
#define | DHCP_EB_REVERSE_PASSWORD DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xc1 ) |
Reverse password. More... | |
#define | DHCP_EB_UID DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xc2 ) |
User ID. More... | |
#define | DHCP_EB_GID DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xc3 ) |
Group ID. More... | |
#define | DHCP_EB_VERSION DHCP_ENCAP_OPT ( DHCP_EB_ENCAP, 0xeb ) |
iPXE version number More... | |
#define | DHCP_ISCSI_PRIMARY_TARGET_IQN 201 |
iSCSI primary target IQN More... | |
#define | DHCP_ISCSI_SECONDARY_TARGET_IQN 202 |
iSCSI secondary target IQN More... | |
#define | DHCP_ISCSI_INITIATOR_IQN 203 |
iSCSI initiator IQN More... | |
#define | DHCP_MAX_OPTION 254 |
Maximum normal DHCP option. More... | |
#define | DHCP_END 255 |
End of options. More... | |
#define | DHCP_OPTION(...) VA_ARG_COUNT ( __VA_ARGS__ ), __VA_ARGS__ |
Construct a DHCP option from a list of bytes. More... | |
#define | DHCP_STRING(...) DHCP_OPTION ( __VA_ARGS__ ) |
Construct a DHCP option from a list of characters. More... | |
#define | DHCP_BYTE(value) DHCP_OPTION ( value ) |
Construct a byte-valued DHCP option. More... | |
#define | DHCP_WORD(value) |
Construct a word-valued DHCP option. More... | |
#define | DHCP_DWORD(value) |
Construct a dword-valued DHCP option. More... | |
#define | DHCP_ENCAP(...) DHCP_OPTION ( __VA_ARGS__, DHCP_END ) |
Construct a DHCP encapsulated options field. More... | |
#define | DHCP_OPTION_HEADER_LEN ( offsetof ( struct dhcp_option, data ) ) |
Length of a DHCP option header. More... | |
#define | DHCP_MAX_LEN 0xff |
Maximum length for a single DHCP option. More... | |
#define | BOOTP_REQUEST 1 |
Opcode for a request from client to server. More... | |
#define | BOOTP_REPLY 2 |
Opcode for a reply from server to client. More... | |
#define | BOOTP_FL_BROADCAST 0x8000 |
BOOTP reply must be broadcast. More... | |
#define | DHCP_MAGIC_COOKIE 0x63825363UL |
DHCP magic cookie. More... | |
#define | DHCP_MIN_LEN 552 |
DHCP minimum packet length. More... | |
#define | DHCP_SETTINGS_NAME "dhcp" |
Settings block name used for DHCP responses. More... | |
#define | PROXYDHCP_SETTINGS_NAME "proxydhcp" |
Settings block name used for ProxyDHCP responses. More... | |
#define | PXEBS_SETTINGS_NAME "pxebs" |
Setting block name used for BootServerDHCP responses. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
int | dhcp_create_packet (struct dhcp_packet *dhcppkt, struct net_device *netdev, uint8_t msgtype, uint32_t xid, const void *options, size_t options_len, void *data, size_t max_len) |
Create a DHCP packet. More... | |
int | dhcp_create_request (struct dhcp_packet *dhcppkt, struct net_device *netdev, unsigned int msgtype, uint32_t xid, struct in_addr ciaddr, void *data, size_t max_len) |
Create DHCP request packet. More... | |
int | start_dhcp (struct interface *job, struct net_device *netdev) |
Start DHCP state machine on a network device. More... | |
int | start_pxebs (struct interface *job, struct net_device *netdev, unsigned int pxe_type) |
Start PXE Boot Server Discovery on a network device. More... | |
Variables | |
uint32_t | dhcp_last_xid |
Most recent DHCP transaction ID. More... | |
Dynamic Host Configuration Protocol.
Definition in file dhcp.h.
#define DHCP_ENCAP_OPT | ( | encapsulator, | |
encapsulated | |||
) | ( ( (encapsulator) << 8 ) | (encapsulated) ) |
#define DHCP_ENCAPSULATOR | ( | encap_opt | ) | ( (encap_opt) >> 8 ) |
#define DHCP_ENCAPSULATED | ( | encap_opt | ) | ( (encap_opt) & 0xff ) |
#define DHCP_IS_ENCAP_OPT | ( | opt | ) | DHCP_ENCAPSULATOR( opt ) |
#define DHCP_OPTION | ( | ... | ) | VA_ARG_COUNT ( __VA_ARGS__ ), __VA_ARGS__ |
#define DHCP_STRING | ( | ... | ) | DHCP_OPTION ( __VA_ARGS__ ) |
#define DHCP_BYTE | ( | value | ) | DHCP_OPTION ( value ) |
#define DHCP_WORD | ( | value | ) |
Construct a word-valued DHCP option.
#define DHCP_DWORD | ( | value | ) |
Construct a dword-valued DHCP option.
#define DHCP_ENCAP | ( | ... | ) | DHCP_OPTION ( __VA_ARGS__, DHCP_END ) |
#define DHCP_OPTION_HEADER_LEN ( offsetof ( struct dhcp_option, data ) ) |
#define DHCP_MAX_LEN 0xff |
#define BOOTP_REQUEST 1 |
#define BOOTP_REPLY 2 |
#define BOOTP_FL_BROADCAST 0x8000 |
#define DHCP_MIN_LEN 552 |
#define DHCP_SETTINGS_NAME "dhcp" |
#define PROXYDHCP_SETTINGS_NAME "proxydhcp" |
#define PXEBS_SETTINGS_NAME "pxebs" |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
int dhcp_create_packet | ( | struct dhcp_packet * | dhcppkt, |
struct net_device * | netdev, | ||
uint8_t | msgtype, | ||
uint32_t | xid, | ||
const void * | options, | ||
size_t | options_len, | ||
void * | data, | ||
size_t | max_len | ||
) |
Create a DHCP packet.
dhcppkt | DHCP packet structure to fill in |
netdev | Network device |
msgtype | DHCP message type |
xid | Transaction ID (in network-endian order) |
options | Initial options to include (or NULL) |
options_len | Length of initial options |
data | Buffer for DHCP packet |
max_len | Size of DHCP packet buffer |
rc | Return status code |
Creates a DHCP packet in the specified buffer, and initialise a DHCP packet structure.
Definition at line 944 of file dhcp.c.
References BOOTP_FL_BROADCAST, dhcphdr::chaddr, data, DHCP_MAGIC_COOKIE, DHCP_MESSAGE_TYPE, dhcp_op, dhcppkt_init(), dhcppkt_store(), ENOSPC, ll_protocol::flags, dhcphdr::flags, dhcphdr::hlen, htonl, htons, dhcphdr::htype, ipv4_has_any_addr(), net_device::ll_addr, ll_protocol::ll_addr_len, LL_NAME_ONLY, ll_protocol::ll_proto, net_device::ll_protocol, dhcphdr::magic, memcpy(), memset(), netdev, ntohs, dhcphdr::op, options, dhcphdr::options, rc, and dhcphdr::xid.
Referenced by create_fakedhcpack(), create_fakepxebsack(), and dhcp_create_request().
int dhcp_create_request | ( | struct dhcp_packet * | dhcppkt, |
struct net_device * | netdev, | ||
unsigned int | msgtype, | ||
uint32_t | xid, | ||
struct in_addr | ciaddr, | ||
void * | data, | ||
size_t | max_len | ||
) |
Create DHCP request packet.
dhcppkt | DHCP packet structure to fill in |
netdev | Network device |
msgtype | DHCP message type |
xid | Transaction ID (in network-endian order) |
ciaddr | Client IP address |
data | Buffer for DHCP packet |
max_len | Size of DHCP packet buffer |
rc | Return status code |
Creates a DHCP request packet in the specified buffer, and initialise a DHCP packet structure.
Definition at line 1007 of file dhcp.c.
References assert(), dhcphdr::ciaddr, data, DBG, DHCP_CLIENT_ID, DHCP_CLIENT_UUID, DHCP_CLIENT_UUID_TYPE, dhcp_create_packet(), DHCP_EB_BUS_ID, DHCP_EB_ENCAP, DHCP_FEATURES, dhcp_request_options_data, dhcp_request_settings, dhcp_packet::dhcphdr, dhcppkt_store(), fetch_raw_setting(), fetch_raw_setting_copy(), fetch_uuid_setting(), free, len, dhcp_client_id::ll_addr, net_device::ll_addr, ll_protocol::ll_addr_len, ll_protocol::ll_proto, dhcp_client_id::ll_proto, net_device::ll_protocol, memcpy(), setting::name, netdev, netdev_settings(), ntohs, NULL, raw, rc, strerror(), table_num_entries, table_start, setting::tag, dhcp_client_uuid::type, dhcp_client_uuid::uuid, and uuid_mangle().
Referenced by create_fakedhcpdiscover(), and dhcp_tx().
int start_dhcp | ( | struct interface * | job, |
struct net_device * | netdev | ||
) |
Start DHCP state machine on a network device.
job | Job control interface |
netdev | Network device |
rc | Return status code |
Starts DHCP on the specified network device. If successful, the DHCPACK (and ProxyDHCPACK, if applicable) will be registered as option sources.
Definition at line 1357 of file dhcp.c.
References AF_INET, BOOTPC_PORT, dhcp_finished(), dhcp_free(), dhcp_job_desc, dhcp_last_xid, dhcp_peer, dhcp_set_state(), dhcp_state_discover, dhcp_timer_expired(), dhcp_xfer_desc, ENOMEM, htons, intf_init(), intf_plug_plug(), dhcp_session::job, dhcp_session::local, netdev, dhcp_session::netdev, netdev_get(), random(), rc, ref_init, ref_put, dhcp_session::refcnt, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_DGRAM, dhcp_session::timer, dhcp_session::xfer, xfer_open_socket(), dhcp_session::xid, and zalloc().
int start_pxebs | ( | struct interface * | job, |
struct net_device * | netdev, | ||
unsigned int | pxe_type | ||
) |
Start PXE Boot Server Discovery on a network device.
job | Job control interface |
netdev | Network device |
pxe_type | PXE server type |
rc | Return status code |
Starts PXE Boot Server Discovery on the specified network device. If successful, the Boot Server ACK will be registered as an option source.
Definition at line 1447 of file dhcp.c.
References AF_INET, BOOTPC_PORT, cpu_to_le16, DBGC, dhcp_finished(), dhcp_free(), dhcp_job_desc, dhcp_peer, DHCP_PXE_BOOT_SERVER_MCAST, DHCP_PXE_BOOT_SERVERS, DHCP_PXE_DISCOVERY_CONTROL, dhcp_set_state(), dhcp_state_pxebs, dhcp_timer_expired(), dhcp_xfer_desc, EINVAL, ENOMEM, fetch_ipv4_setting(), fetch_raw_setting(), fetch_uintz_setting(), htons, INADDR_BROADCAST, inet_ntoa(), intf_init(), intf_plug_plug(), ip, dhcp_session::job, dhcp_session::local, netdev, dhcp_session::netdev, netdev_get(), netdev_settings(), NULL, dhcp_session::pxe_accept, dhcp_session::pxe_attempt, dhcp_session::pxe_type, pxebs_list(), PXEBS_NO_BROADCAST, PXEBS_NO_MULTICAST, PXEBS_NO_UNKNOWN_SERVERS, rc, ref_init, ref_put, dhcp_session::refcnt, in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_DGRAM, setting::tag, dhcp_session::timer, dhcp_session::xfer, xfer_open_socket(), and zalloc().
Referenced by pxebs().
uint32_t dhcp_last_xid |
Most recent DHCP transaction ID.
This is exposed for use by the fakedhcp code when reconstructing DHCP packets for PXE NBPs.
Definition at line 124 of file dhcp.c.
Referenced by create_fakedhcpack(), create_fakedhcpdiscover(), create_fakepxebsack(), and start_dhcp().