51 for ( i = 0 ; i < nvo->
len ; i++ ) {
70 DBGC ( nvo,
"NVO %p could not allocate %zd bytes\n",
112 DBGC ( nvo,
"NVO %p could not resize to %zd bytes: %s\n",
135 if ( nvo->
len == 0 ) {
136 DBGC ( nvo,
"NVO %p is empty; skipping load\n", nvo );
142 nvo->
len ) ) != 0 ) {
143 DBGC ( nvo,
"NVO %p could not read %zd bytes at %#04x: %s\n",
152 if ( (
nvo_checksum ( nvo ) != 0 ) || ( options_data[0] == 0 ) ) {
153 DBGC ( nvo,
"NVO %p has checksum %02x and initial byte %02x; " 162 DBGC ( nvo,
"NVO %p loaded from non-volatile storage\n", nvo );
182 nvo->
len ) ) != 0 ) {
183 DBGC ( nvo,
"NVO %p could not write %zd bytes at %#04x: %s\n",
188 DBGC ( nvo,
"NVO %p saved to non-volatile storage\n", nvo );
216 const void *
data,
size_t len ) {
224 DBGC ( nvo,
"NVO %p could not store %zd bytes: %s\n",
309 DBGC ( nvo,
"NVO %p registered\n", nvo );
327 DBGC ( nvo,
"NVO %p unregistered\n", nvo );
struct dhcp_options dhcpopts
DHCP options block.
struct arbelprm_rc_send_wqe rc
Dynamic Host Configuration Protocol.
uint8_t checksum
Checksum.
int nvo_applies(struct settings *settings __unused, const struct setting *setting)
Check applicability of NVO setting.
void unregister_settings(struct settings *settings)
Unregister settings block.
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.
A non-volatile storage device.
uint64_t address
Base address.
int register_nvo(struct nvo_block *nvo, struct settings *parent)
Register non-volatile stored options.
int nvs_write(struct nvs_device *nvs, unsigned int address, const void *data, size_t len)
Write to non-volatile storage device.
static void settings_init(struct settings *settings, struct settings_operations *op, struct refcnt *refcnt, const struct settings_scope *default_scope)
Initialise a settings block.
void * data
Option-containing data.
uint64_t tag
Setting tag, if applicable.
size_t alloc_len
Option block allocated length.
#define ENOMEM
Not enough space.
#define container_of(ptr, type, field)
Get containing structure.
#define __unused
Declare a variable or data structure as unused.
static int nvo_realloc_dhcpopt(struct dhcp_options *options, size_t len)
Reallocate non-volatile stored options DHCP option block.
void unregister_nvo(struct nvo_block *nvo)
Unregister non-volatile stored options.
static int nvo_fetch(struct settings *settings, struct setting *setting, void *data, size_t len)
Fetch value of NVO setting.
Non-volatile stored options.
struct nvs_device * nvs
Underlying non-volatile storage device.
char * strerror(int errno)
Retrieve string representation of error number.
A block of non-volatile stored options.
void nvo_init(struct nvo_block *nvo, struct nvs_device *nvs, size_t address, size_t len, int(*resize)(struct nvo_block *nvo, size_t len), struct refcnt *refcnt)
Initialise non-volatile stored options.
int(* resize)(struct nvo_block *nvo, size_t len)
Resize non-volatile stored option block.
Settings block operations.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
int dhcpopt_no_realloc(struct dhcp_options *options, size_t len)
Refuse to reallocate DHCP option block.
struct settings settings
Settings block.
unsigned int address
Address within NVS device.
static int nvo_store(struct settings *settings, const struct setting *setting, const void *data, size_t len)
Store value of NVO setting.
static int nvo_realloc(struct nvo_block *nvo, size_t len)
Reallocate non-volatile stored options block.
void * data
Option block raw data.
static int nvo_load(struct nvo_block *nvo)
Load non-volatile stored options from non-volatile storage device.
void dhcpopt_update_used_len(struct dhcp_options *options)
Recalculate length of DHCP options block.
static int nvo_save(struct nvo_block *nvo)
Save non-volatile stored options back to non-volatile storage device.
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.
static unsigned int nvo_checksum(struct nvo_block *nvo)
Calculate checksum over non-volatile stored options.
void * realloc(void *old_ptr, size_t new_size)
Reallocate memory.
int nvs_read(struct nvs_device *nvs, unsigned int address, void *data, size_t len)
Read from non-volatile storage device.
int(* applies)(struct settings *settings, const struct setting *setting)
Check applicability of setting.
#define NVO_SETTINGS_NAME
Name of non-volatile options settings block.
int register_settings(struct settings *settings, struct settings *parent, const char *name)
Register settings block.
int dhcpopt_fetch(struct dhcp_options *options, unsigned int tag, void *data, size_t len)
Fetch value of DHCP option setting.
static struct settings_operations nvo_settings_operations
NVO settings operations.
const struct settings_scope * scope
Setting scope (or NULL)
size_t len
Length of options data.
#define NULL
NULL pointer (VOID *)
int dhcpopt_applies(unsigned int tag)
Check applicability of DHCP option setting.
size_t used_len
Option block used length.
void * memset(void *dest, int character, size_t len) __nonnull