58 return (
in->s_addr ? sizeof ( *
in ) : 0 );
95 #define DHCP_PACKET_FIELD( _tag, _field, _used_len ) { \ 97 .offset = offsetof ( struct dhcphdr, _field ), \ 98 .len = sizeof ( ( ( struct dhcphdr * ) 0 )->_field ), \ 99 .used_len = _used_len, \ 165 const void *
data,
size_t len ) {
199 size_t field_len = 0;
204 field_len = field->
used_len ( field_data, field->
len );
209 if (
len > field_len )
252 const void *
data,
size_t len ) {
static int dhcppkt_applies(struct dhcp_packet *dhcppkt __unused, unsigned int tag)
Check applicability of DHCP setting.
static struct dhcp_packet_field * find_dhcp_packet_field(unsigned int tag)
Find DHCP packet field corresponding to settings tag number.
Dynamic Host Configuration Protocol.
struct refcnt refcnt
Reference counter.
void dhcpopt_init(struct dhcp_options *options, void *data, size_t alloc_len, int(*realloc)(struct dhcp_options *options, size_t len))
Initialise prepopulated block of DHCP options.
#define ref_init(refcnt, free)
Initialise a reference counter.
static int dhcppkt_settings_applies(struct settings *settings, const struct setting *setting)
Check applicability of DHCP setting.
static struct dhcp_packet_field dhcp_packet_fields[]
Dedicated fields within a DHCP packet.
static int dhcppkt_settings_fetch(struct settings *settings, struct setting *setting, void *data, size_t len)
Fetch value of DHCP setting.
uint8_t options[0]
DHCP options.
#define offsetof(type, field)
Get offset of a field within a structure.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static void settings_init(struct settings *settings, struct settings_operations *op, struct refcnt *refcnt, const struct settings_scope *default_scope)
Initialise a settings block.
static size_t used_len_ipv4(const void *data, size_t len __unused)
Calculate used length of an IPv4 field within a DHCP packet.
#define DHCP_PACKET_FIELD(_tag, _field, _used_len)
Declare a dedicated field within a DHCP packet.
struct dhcp_options options
DHCP options.
uint64_t tag
Setting tag, if applicable.
static size_t used_len_string(const void *data, size_t len)
Calculate used length of a string field within a DHCP packet.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static void * dhcp_packet_field(struct dhcphdr *dhcphdr, struct dhcp_packet_field *field)
Get address of a DHCP packet field.
#define container_of(ptr, type, field)
Get containing structure.
#define __unused
Declare a variable or data structure as unused.
int dhcppkt_fetch(struct dhcp_packet *dhcppkt, unsigned int tag, void *data, size_t len)
Fetch value of DHCP packet setting.
int dhcppkt_store(struct dhcp_packet *dhcppkt, unsigned int tag, const void *data, size_t len)
Store value of DHCP packet setting.
Settings block operations.
size_t strnlen(const char *src, size_t max)
Get length of string.
struct settings settings
Settings interface.
int dhcpopt_no_realloc(struct dhcp_options *options, size_t len)
Refuse to reallocate DHCP option block.
Network device management.
void dhcppkt_init(struct dhcp_packet *dhcppkt, struct dhcphdr *data, size_t len)
Initialise DHCP packet.
#define ENOSPC
No space left on device.
struct dhcphdr * dhcphdr
The DHCP packet contents.
static struct settings_operations dhcppkt_settings_operations
DHCP settings operations.
#define DHCP_EB_SIADDR
"Server" IP address
#define DHCP_EB_YIADDR
"Your" IP address
uint8_t data[48]
Additional event data.
int dhcpopt_store(struct dhcp_options *options, unsigned int tag, const void *data, size_t len)
Store value of DHCP option setting.
#define DHCP_BOOTFILE_NAME
Bootfile name.
int(* applies)(struct settings *settings, const struct setting *setting)
Check applicability of setting.
size_t(* used_len)(const void *data, size_t len)
Calculate used length of field.
int dhcpopt_fetch(struct dhcp_options *options, unsigned int tag, void *data, size_t len)
Fetch value of DHCP option setting.
uint16_t offset
Offset within DHCP packet.
static int dhcppkt_settings_store(struct settings *settings, const struct setting *setting, const void *data, size_t len)
Store value of DHCP setting.
A dedicated field within a DHCP packet.
unsigned int tag
Settings tag number.
#define DHCP_TFTP_SERVER_NAME
TFTP server name.
const struct settings_scope * scope
Setting scope (or NULL)
uint64_t tag
Identity tag.
uint16_t len
Length of field.
#define NULL
NULL pointer (VOID *)
int dhcpopt_applies(unsigned int tag)
Check applicability of DHCP option setting.
void * memset(void *dest, int character, size_t len) __nonnull