iPXE
|
Dynamic Host Configuration Protocol for IPv6. More...
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/interface.h>
#include <ipxe/xfer.h>
#include <ipxe/iobuf.h>
#include <ipxe/open.h>
#include <ipxe/netdevice.h>
#include <ipxe/settings.h>
#include <ipxe/retry.h>
#include <ipxe/timer.h>
#include <ipxe/in.h>
#include <ipxe/crc32.h>
#include <ipxe/errortab.h>
#include <ipxe/ipv6.h>
#include <ipxe/dhcparch.h>
#include <ipxe/dhcpv6.h>
Go to the source code of this file.
Data Structures | |
struct | dhcpv6_option_list |
A DHCPv6 option list. More... | |
struct | dhcpv6_settings |
A DHCPv6 settings block. More... | |
struct | dhcpv6_session_state |
A DHCPv6 session state. More... | |
struct | dhcpv6_session |
A DHCPv6 session. More... | |
Macros | |
#define | EPROTO_UNSPECFAIL __einfo_error ( EINFO_EPROTO_UNSPECFAIL ) |
#define | EINFO_EPROTO_UNSPECFAIL __einfo_uniqify ( EINFO_EPROTO, 1, "Unspecified server failure" ) |
#define | EPROTO_NOADDRSAVAIL __einfo_error ( EINFO_EPROTO_NOADDRSAVAIL ) |
#define | EINFO_EPROTO_NOADDRSAVAIL __einfo_uniqify ( EINFO_EPROTO, 2, "No addresses available" ) |
#define | EPROTO_NOBINDING __einfo_error ( EINFO_EPROTO_NOBINDING ) |
#define | EINFO_EPROTO_NOBINDING __einfo_uniqify ( EINFO_EPROTO, 3, "Client record unavailable" ) |
#define | EPROTO_NOTONLINK __einfo_error ( EINFO_EPROTO_NOTONLINK ) |
#define | EINFO_EPROTO_NOTONLINK __einfo_uniqify ( EINFO_EPROTO, 4, "Prefix not on link" ) |
#define | EPROTO_USEMULTICAST __einfo_error ( EINFO_EPROTO_USEMULTICAST ) |
#define | EINFO_EPROTO_USEMULTICAST __einfo_uniqify ( EINFO_EPROTO, 5, "Use multicast address" ) |
#define | EPROTO_STATUS(status) |
Enumerations | |
enum | dhcpv6_session_state_flags { DHCPV6_TX_IA_NA = 0x01, DHCPV6_TX_IAADDR = 0x02, DHCPV6_RX_RECORD_SERVER_ID = 0x04, DHCPV6_RX_RECORD_IAADDR = 0x08 } |
DHCPv6 session state flags. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static const union dhcpv6_any_option * | dhcpv6_option (struct dhcpv6_option_list *options, unsigned int code) |
Find DHCPv6 option. More... | |
static int | dhcpv6_check_duid (struct dhcpv6_option_list *options, unsigned int code, const void *expected, size_t len) |
Check DHCPv6 client or server identifier. More... | |
static int | dhcpv6_status_code (struct dhcpv6_option_list *options) |
Get DHCPv6 status code. More... | |
static int | dhcpv6_iaaddr (struct dhcpv6_option_list *options, uint32_t iaid, struct in6_addr *address) |
Get DHCPv6 identity association address. More... | |
static int | dhcpv6_applies (struct settings *settings __unused, const struct setting *setting) |
Check applicability of DHCPv6 setting. More... | |
static int | dhcpv6_fetch_lease (struct dhcpv6_settings *dhcpv6set, void *data, size_t len) |
Fetch value of DHCPv6 leased address. More... | |
static int | dhcpv6_fetch (struct settings *settings, struct setting *setting, void *data, size_t len) |
Fetch value of DHCPv6 setting. More... | |
static int | dhcpv6_register (struct in6_addr *lease, struct dhcpv6_option_list *options, struct settings *parent) |
Register DHCPv6 options as network device settings. More... | |
static const char * | dhcpv6_type_name (unsigned int type) |
Name a DHCPv6 packet type. More... | |
static void | dhcpv6_free (struct refcnt *refcnt) |
Free DHCPv6 session. More... | |
static void | dhcpv6_finished (struct dhcpv6_session *dhcpv6, int rc) |
Terminate DHCPv6 session. More... | |
static void | dhcpv6_set_state (struct dhcpv6_session *dhcpv6, struct dhcpv6_session_state *state) |
Transition to new DHCPv6 session state. More... | |
static size_t | dhcpv6_user_class (void *data, size_t len) |
Get DHCPv6 user class. More... | |
static int | dhcpv6_tx (struct dhcpv6_session *dhcpv6) |
Transmit current request. More... | |
static void | dhcpv6_timer_expired (struct retry_timer *timer, int fail) |
Handle timer expiry. More... | |
static int | dhcpv6_rx (struct dhcpv6_session *dhcpv6, struct io_buffer *iobuf, struct xfer_metadata *meta) |
Receive new data. More... | |
int | start_dhcpv6 (struct interface *job, struct net_device *netdev, int stateful) |
Start DHCPv6. More... | |
const struct setting filename6_setting | __setting (SETTING_BOOT, filename) |
Boot filename setting. More... | |
const struct setting dnssl6_setting | __setting (SETTING_IP_EXTRA, dnssl) |
DNS search list setting. More... | |
Variables | |
struct errortab dhcpv6_errors [] | __errortab |
Human-readable error messages. More... | |
static struct settings_operations | dhcpv6_settings_operations |
DHCPv6 settings operations. More... | |
static uint8_t | dhcpv6_request_options_data [] |
Raw option data for options common to all DHCPv6 requests. More... | |
static struct dhcpv6_session_state | dhcpv6_request |
DHCPv6 request state. More... | |
static struct dhcpv6_session_state | dhcpv6_solicit |
DHCPv6 solicitation state. More... | |
static struct dhcpv6_session_state | dhcpv6_information_request |
DHCPv6 information request state. More... | |
static struct interface_operation | dhcpv6_job_op [] |
DHCPv6 job control interface operations. More... | |
static struct interface_descriptor | dhcpv6_job_desc |
DHCPv6 job control interface descriptor. More... | |
static struct interface_operation | dhcpv6_xfer_op [] |
DHCPv6 data transfer interface operations. More... | |
static struct interface_descriptor | dhcpv6_xfer_desc |
DHCPv6 data transfer interface descriptor. More... | |
Dynamic Host Configuration Protocol for IPv6.
Definition in file dhcpv6.c.
#define EPROTO_UNSPECFAIL __einfo_error ( EINFO_EPROTO_UNSPECFAIL ) |
#define EINFO_EPROTO_UNSPECFAIL __einfo_uniqify ( EINFO_EPROTO, 1, "Unspecified server failure" ) |
#define EPROTO_NOADDRSAVAIL __einfo_error ( EINFO_EPROTO_NOADDRSAVAIL ) |
#define EINFO_EPROTO_NOADDRSAVAIL __einfo_uniqify ( EINFO_EPROTO, 2, "No addresses available" ) |
#define EPROTO_NOBINDING __einfo_error ( EINFO_EPROTO_NOBINDING ) |
#define EINFO_EPROTO_NOBINDING __einfo_uniqify ( EINFO_EPROTO, 3, "Client record unavailable" ) |
#define EPROTO_NOTONLINK __einfo_error ( EINFO_EPROTO_NOTONLINK ) |
#define EINFO_EPROTO_NOTONLINK __einfo_uniqify ( EINFO_EPROTO, 4, "Prefix not on link" ) |
#define EPROTO_USEMULTICAST __einfo_error ( EINFO_EPROTO_USEMULTICAST ) |
#define EINFO_EPROTO_USEMULTICAST __einfo_uniqify ( EINFO_EPROTO, 5, "Use multicast address" ) |
#define EPROTO_STATUS | ( | status | ) |
DHCPv6 session state flags.
Definition at line 456 of file dhcpv6.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Find DHCPv6 option.
options | DHCPv6 option list |
code | Option code |
option | DHCPv6 option, or NULL if not found |
Definition at line 100 of file dhcpv6.c.
References code, data_len, htons, ntohs, NULL, and options.
Referenced by dhcpv6_check_duid(), dhcpv6_fetch(), dhcpv6_iaaddr(), dhcpv6_rx(), and dhcpv6_status_code().
|
static |
Check DHCPv6 client or server identifier.
options | DHCPv6 option list |
code | Option code |
expected | Expected value |
len | Length of expected value |
rc | Return status code |
Definition at line 137 of file dhcpv6.c.
References code, dhcpv6_option(), dhcpv6_duid_option::duid, EINVAL, ENOENT, len, memcmp(), ntohs, and options.
Referenced by dhcpv6_rx().
|
static |
Get DHCPv6 status code.
options | DHCPv6 option list |
rc | Return status code |
Definition at line 166 of file dhcpv6.c.
References dhcpv6_option(), DHCPV6_STATUS_CODE, EINVAL, EPROTO_STATUS, dhcpv6_status_code_option::header, dhcpv6_option::len, ntohs, options, status, and dhcpv6_status_code_option::status.
Referenced by dhcpv6_iaaddr(), and dhcpv6_rx().
|
static |
Get DHCPv6 identity association address.
options | DHCPv6 option list |
iaid | Identity association ID |
address | IPv6 address to fill in |
rc | Return status code |
Definition at line 198 of file dhcpv6.c.
References address, dhcpv6_iaaddr_option::address, dhcpv6_option_list::data, DHCPV6_IA_NA, DHCPV6_IAADDR, dhcpv6_option(), dhcpv6_status_code(), EINVAL, ENOENT, dhcpv6_ia_na_option::header, dhcpv6_iaaddr_option::header, htonl, dhcpv6_ia_na_option::iaid, len, dhcpv6_option::len, dhcpv6_option_list::len, memcpy(), ntohs, offsetof, dhcpv6_ia_na_option::options, dhcpv6_iaaddr_option::options, options, rc, and typeof().
Referenced by dhcpv6_rx().
|
static |
Check applicability of DHCPv6 setting.
settings | Settings block |
setting | Setting |
applies | Setting applies within this settings block |
Definition at line 282 of file dhcpv6.c.
References dhcpv6_scope, setting::scope, and setting_cmp().
|
static |
Fetch value of DHCPv6 leased address.
dhcpset | DHCPv6 settings |
data | Buffer to fill with setting data |
len | Length of buffer |
len | Length of setting data, or negative error |
Definition at line 297 of file dhcpv6.c.
References data, ENOENT, IN6_IS_ADDR_UNSPECIFIED, lease, dhcpv6_settings::lease, len, and memcpy().
Referenced by dhcpv6_fetch().
|
static |
Fetch value of DHCPv6 setting.
settings | Settings block |
setting | Setting to fetch |
data | Buffer to fill with setting data |
len | Length of buffer |
len | Length of setting data, or negative error |
Definition at line 322 of file dhcpv6.c.
References container_of, data, dhcpv6_fetch_lease(), dhcpv6_option(), ENOENT, len, memcpy(), ntohs, dhcpv6_settings::options, setting_cmp(), and setting::tag.
|
static |
Register DHCPv6 options as network device settings.
lease | DHCPv6 leased address |
options | DHCPv6 option list |
parent | Parent settings block |
rc | Return status code |
Definition at line 361 of file dhcpv6.c.
References data, dhcpv6_option_list::data, dhcpv6_scope, DHCPV6_SETTINGS_NAME, dhcpv6_settings_operations, ENOMEM, IPV6_ORDER_DHCPV6, lease, dhcpv6_settings::lease, len, dhcpv6_option_list::len, memcpy(), NULL, dhcpv6_settings::options, options, settings::order, rc, ref_init, ref_put, dhcpv6_settings::refcnt, register_settings(), dhcpv6_settings::settings, settings_init(), and zalloc().
Referenced by dhcpv6_rx().
|
static |
Name a DHCPv6 packet type.
type | DHCPv6 packet type |
name | DHCPv6 packet type name |
Definition at line 428 of file dhcpv6.c.
References DHCPV6_ADVERTISE, DHCPV6_INFORMATION_REQUEST, DHCPV6_REPLY, DHCPV6_REQUEST, DHCPV6_SOLICIT, snprintf(), and type.
Referenced by dhcpv6_rx(), and dhcpv6_set_state().
|
static |
Free DHCPv6 session.
refcnt | Reference count |
Definition at line 533 of file dhcpv6.c.
References container_of, free, dhcpv6_session::netdev, netdev_put(), and dhcpv6_session::server_duid.
Referenced by start_dhcpv6().
|
static |
Terminate DHCPv6 session.
dhcpv6 | DHCPv6 session |
rc | Reason for close |
Definition at line 548 of file dhcpv6.c.
References intf_shutdown(), dhcpv6_session::job, rc, stop_timer(), dhcpv6_session::timer, and dhcpv6_session::xfer.
Referenced by dhcpv6_rx(), dhcpv6_timer_expired(), and start_dhcpv6().
|
static |
Transition to new DHCPv6 session state.
dhcpv6 | DHCPv6 session |
state | New session state |
Definition at line 564 of file dhcpv6.c.
References DBGC, dhcpv6_type_name(), ETIMEDOUT, net_device::name, dhcpv6_session::netdev, dhcpv6_session::rc, start_timer_nodelay(), state, dhcpv6_session::state, and dhcpv6_session::timer.
Referenced by dhcpv6_rx(), and start_dhcpv6().
|
static |
Get DHCPv6 user class.
data | Data buffer |
len | Length of data buffer |
len | Length of user class |
Definition at line 587 of file dhcpv6.c.
References data, fetch_raw_setting(), len, memcpy(), and NULL.
Referenced by dhcpv6_tx().
|
static |
Transmit current request.
dhcpv6 | DHCPv6 session |
rc | Return status code |
Definition at line 609 of file dhcpv6.c.
References dhcpv6_iaaddr_option::address, assert(), dhcpv6_session::client_duid, dhcpv6_option::code, currticks(), DBGC, DHCPV6_CLIENT_ID, DHCPV6_ELAPSED_TIME, DHCPV6_IA_NA, DHCPV6_IAADDR, dhcpv6_request_options_data, DHCPV6_SERVER_ID, DHCPV6_TX_IA_NA, DHCPV6_TX_IAADDR, DHCPV6_USER_CLASS, dhcpv6_user_class(), dhcpv6_duid_option::duid, dhcpv6_elapsed_time_option::elapsed, ENOMEM, dhcpv6_session_state::flags, dhcpv6_duid_option::header, dhcpv6_ia_na_option::header, dhcpv6_iaaddr_option::header, dhcpv6_elapsed_time_option::header, dhcpv6_user_class_option::header, htonl, htons, dhcpv6_ia_na_option::iaid, dhcpv6_session::iaid, iob_len(), iob_put, dhcpv6_session::lease, dhcpv6_option::len, dhcpv6_user_class::len, memcpy(), net_device::name, dhcpv6_session::netdev, NULL, dhcpv6_ia_na_option::options, options, dhcpv6_iaaddr_option::preferred, rc, dhcpv6_ia_na_option::rebind, dhcpv6_ia_na_option::renew, dhcpv6_session::server_duid, dhcpv6_session::server_duid_len, dhcpv6_session::start, dhcpv6_session::state, strerror(), dhcpv6_user_class::string, TICKS_PER_SEC, dhcpv6_session_state::tx_type, dhcpv6_user_class_option::user_class, dhcpv6_iaaddr_option::valid, dhcpv6_session::xfer, xfer_alloc_iob(), xfer_deliver_iob(), dhcpv6_session::xid, and dhcphdr::xid.
Referenced by dhcpv6_timer_expired().
|
static |
Handle timer expiry.
timer | Retransmission timer |
fail | Failure indicator |
Definition at line 739 of file dhcpv6.c.
References container_of, dhcpv6_finished(), dhcpv6_tx(), dhcpv6_session::rc, start_timer(), and dhcpv6_session::timer.
Referenced by start_dhcpv6().
|
static |
Receive new data.
dhcpv6 | DHCPv6 session |
iobuf | I/O buffer |
meta | Data transfer metadata |
rc | Return status code |
Definition at line 764 of file dhcpv6.c.
References AF_INET6, assert(), dhcpv6_session::client_duid, io_buffer::data, DBGC, dhcpv6_check_duid(), DHCPV6_CLIENT_ID, dhcpv6_finished(), dhcpv6_iaaddr(), dhcpv6_option(), dhcpv6_register(), DHCPV6_RX_RECORD_IAADDR, DHCPV6_RX_RECORD_SERVER_ID, DHCPV6_SERVER_ID, dhcpv6_set_state(), dhcpv6_status_code(), dhcpv6_type_name(), done, EINVAL, ENOMEM, ENOTTY, dhcpv6_session_state::flags, free_iob(), dhcpv6_session::iaid, inet6_ntoa(), iob_len(), dhcpv6_session::lease, malloc(), memcpy(), meta(), net_device::name, dhcpv6_session::netdev, netdev_settings(), dhcpv6_session_state::next, ntohs, NULL, offsetof, options, dhcphdr::options, settings::parent, rc, dhcpv6_session::rc, dhcpv6_session_state::rx_type, dhcpv6_session::server_duid, dhcpv6_session::server_duid_len, src, dhcpv6_session::state, strerror(), and typeof().
int start_dhcpv6 | ( | struct interface * | job, |
struct net_device * | netdev, | ||
int | stateful | ||
) |
Start DHCPv6.
job | Job control interface |
netdev | Network device |
stateful | Perform stateful address autoconfiguration |
rc | Return status code |
Definition at line 921 of file dhcpv6.c.
References AF_INET6, dhcpv6_session::client_duid, crc32_le(), currticks(), DBGC, DHCPV6_CLIENT_PORT, DHCPV6_DUID_UUID, dhcpv6_finished(), dhcpv6_free(), dhcpv6_information_request, dhcpv6_job_desc, DHCPV6_SERVER_PORT, dhcpv6_set_state(), dhcpv6_solicit, dhcpv6_timer_expired(), dhcpv6_xfer_desc, ENOMEM, fetch_uuid_setting(), htons, dhcpv6_session::iaid, intf_init(), intf_plug_plug(), ipv6_all_dhcp_relay_and_servers(), dhcpv6_session::job, len, net_device::ll_addr, ll_protocol::ll_addr_len, net_device::ll_protocol, memcpy(), memset(), net_device::name, netdev, dhcpv6_session::netdev, netdev_get(), NULL, random(), rc, ref_init, ref_put, dhcpv6_session::refcnt, sa, net_device::scope_id, sin6, SOCK_DGRAM, dhcpv6_session::start, strerror(), dhcpv6_session::timer, dhcpv6_duid_uuid::type, dhcpv6_duid_uuid::uuid, dhcpv6_session::xfer, xfer_open_socket(), dhcpv6_session::xid, and zalloc().
Referenced by ipv6conf_rx_router_advertisement().
const struct setting filename6_setting __setting | ( | SETTING_BOOT | , |
filename | |||
) |
Boot filename setting.
const struct setting dnssl6_setting __setting | ( | SETTING_IP_EXTRA | , |
dnssl | |||
) |
DNS search list setting.
struct errortab dhcpv6_errors [] __errortab |
Human-readable error messages.
|
static |
DHCPv6 settings operations.
Definition at line 348 of file dhcpv6.c.
Referenced by dhcpv6_register().
|
static |
Raw option data for options common to all DHCPv6 requests.
Definition at line 404 of file dhcpv6.c.
Referenced by dhcpv6_tx().
|
static |
DHCPv6 request state.
|
static |
DHCPv6 solicitation state.
Definition at line 477 of file dhcpv6.c.
Referenced by start_dhcpv6().
|
static |
DHCPv6 information request state.
Definition at line 486 of file dhcpv6.c.
Referenced by start_dhcpv6().
|
static |
DHCPv6 job control interface operations.
|
static |
DHCPv6 job control interface descriptor.
Definition at line 901 of file dhcpv6.c.
Referenced by start_dhcpv6().
|
static |
DHCPv6 data transfer interface operations.
|
static |
DHCPv6 data transfer interface descriptor.
Definition at line 910 of file dhcpv6.c.
Referenced by start_dhcpv6().