iPXE
Data Structures | Macros | Enumerations | Functions | Variables
settings.c File Reference

Configuration settings. More...

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <byteswap.h>
#include <errno.h>
#include <assert.h>
#include <time.h>
#include <ipxe/in.h>
#include <ipxe/ip.h>
#include <ipxe/ipv6.h>
#include <ipxe/vsprintf.h>
#include <ipxe/dhcp.h>
#include <ipxe/uuid.h>
#include <ipxe/uri.h>
#include <ipxe/base16.h>
#include <ipxe/base64.h>
#include <ipxe/pci.h>
#include <ipxe/init.h>
#include <ipxe/version.h>
#include <ipxe/settings.h>

Go to the source code of this file.

Data Structures

struct  generic_setting
 A generic setting. More...
 
struct  autovivified_settings
 Autovivified settings block. More...
 

Macros

#define settings_root   generic_settings_root.settings
 Root settings block. More...
 
#define SETTING_TYPE_UINT_NAME(index)   setting_type_int_name[index]
 Get unsigned integer setting type name. More...
 
#define SETTING_TYPE_INT_NAME(index)   ( setting_type_int_name[index] + 1 )
 Get signed integer setting type name. More...
 
#define SETTING_TYPE_INT(index)
 Define a signed integer setting type. More...
 
#define SETTING_TYPE_UINT(index)
 Define an unsigned integer setting type. More...
 

Enumerations

enum  setting_type_int_index { SETTING_TYPE_INT8 = 0, SETTING_TYPE_INT16 = 1, SETTING_TYPE_INT32 = 2 }
 Integer setting type indices. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void * generic_setting_name (struct generic_setting *generic)
 Get generic setting name. More...
 
static void * generic_setting_data (struct generic_setting *generic)
 Get generic setting data. More...
 
static struct generic_settingfind_generic_setting (struct generic_settings *generics, const struct setting *setting)
 Find generic setting. More...
 
int generic_settings_store (struct settings *settings, const struct setting *setting, const void *data, size_t len)
 Store value of generic setting. More...
 
int generic_settings_fetch (struct settings *settings, struct setting *setting, void *data, size_t len)
 Fetch value of generic setting. More...
 
void generic_settings_clear (struct settings *settings)
 Clear generic settings block. More...
 
static void autovivified_settings_free (struct refcnt *refcnt)
 Free autovivified settings block. More...
 
struct settingsfind_child_settings (struct settings *parent, const char *name)
 Find child settings block. More...
 
struct settingsautovivify_child_settings (struct settings *parent, const char *name)
 Find or create child settings block. More...
 
const char * settings_name (struct settings *settings)
 Return settings block name. More...
 
static struct settingsparse_settings_name (const char *name, get_child_settings_t get_child)
 Parse settings block name. More...
 
struct settingsfind_settings (const char *name)
 Find settings block. More...
 
static int apply_settings (void)
 Apply all settings. More...
 
static void reprioritise_settings (struct settings *settings)
 Reprioritise settings. More...
 
int register_settings (struct settings *settings, struct settings *parent, const char *name)
 Register settings block. More...
 
void unregister_settings (struct settings *settings)
 Unregister settings block. More...
 
struct settingssettings_target (struct settings *settings)
 Redirect to target settings block. More...
 
int setting_applies (struct settings *settings, const struct setting *setting)
 Check applicability of setting. More...
 
static const struct settingapplicable_setting (struct settings *settings, const struct setting *setting)
 Find setting applicable to settings block, if any. More...
 
int store_setting (struct settings *settings, const struct setting *setting, const void *data, size_t len)
 Store value of setting. More...
 
int fetch_setting (struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void *data, size_t len)
 Fetch setting. More...
 
static int fetch_setting_alloc (struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void **data, void *(*alloc)(size_t len))
 Fetch allocated copy of setting. More...
 
int fetch_setting_copy (struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void **data)
 Fetch copy of setting. More...
 
int fetch_raw_setting (struct settings *settings, const struct setting *setting, void *data, size_t len)
 Fetch value of setting. More...
 
int fetch_raw_setting_copy (struct settings *settings, const struct setting *setting, void **data)
 Fetch value of setting. More...
 
int fetch_string_setting (struct settings *settings, const struct setting *setting, char *data, size_t len)
 Fetch value of string setting. More...
 
static void * fetch_string_setting_copy_alloc (size_t len)
 Allocate memory for copy of string setting. More...
 
int fetch_string_setting_copy (struct settings *settings, const struct setting *setting, char **data)
 Fetch value of string setting. More...
 
int fetch_ipv4_array_setting (struct settings *settings, const struct setting *setting, struct in_addr *inp, unsigned int count)
 Fetch value of IPv4 address setting. More...
 
int fetch_ipv4_setting (struct settings *settings, const struct setting *setting, struct in_addr *inp)
 Fetch value of IPv4 address setting. More...
 
int fetch_ipv6_array_setting (struct settings *settings, const struct setting *setting, struct in6_addr *inp, unsigned int count)
 Fetch value of IPv6 address setting. More...
 
int fetch_ipv6_setting (struct settings *settings, const struct setting *setting, struct in6_addr *inp)
 Fetch value of IPv6 address setting. More...
 
static int numeric_setting_value (int is_signed, const void *raw, size_t len, unsigned long *value)
 Extract numeric value of setting. More...
 
int fetch_numeric_setting (struct settings *settings, const struct setting *setting, unsigned long *value, int is_signed)
 Fetch value of numeric setting. More...
 
int fetch_int_setting (struct settings *settings, const struct setting *setting, long *value)
 Fetch value of signed integer setting. More...
 
int fetch_uint_setting (struct settings *settings, const struct setting *setting, unsigned long *value)
 Fetch value of unsigned integer setting. More...
 
long fetch_intz_setting (struct settings *settings, const struct setting *setting)
 Fetch value of signed integer setting, or zero. More...
 
unsigned long fetch_uintz_setting (struct settings *settings, const struct setting *setting)
 Fetch value of unsigned integer setting, or zero. More...
 
int fetch_uuid_setting (struct settings *settings, const struct setting *setting, union uuid *uuid)
 Fetch value of UUID setting. More...
 
void clear_settings (struct settings *settings)
 Clear settings block. More...
 
int setting_cmp (const struct setting *a, const struct setting *b)
 Compare two settings. More...
 
int setting_format (const struct setting_type *type, const void *raw, size_t raw_len, char *buf, size_t len)
 Format setting value as a string. More...
 
int setting_parse (const struct setting_type *type, const char *value, void *buf, size_t len)
 Parse formatted string to setting value. More...
 
int setting_numerate (const struct setting_type *type, const void *raw, size_t raw_len, unsigned long *value)
 Convert setting value to number. More...
 
int setting_denumerate (const struct setting_type *type, unsigned long value, void *buf, size_t len)
 Convert number to setting value. More...
 
int fetchf_setting (struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, char *buf, size_t len)
 Fetch formatted value of setting. More...
 
int fetchf_setting_copy (struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, char **value)
 Fetch copy of formatted value of setting. More...
 
int storef_setting (struct settings *settings, const struct setting *setting, const char *value)
 Store formatted value of setting. More...
 
int fetchn_setting (struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, unsigned long *value)
 Fetch numeric value of setting. More...
 
int storen_setting (struct settings *settings, const struct setting *setting, unsigned long value)
 Store numeric value of setting. More...
 
struct settingfind_setting (const char *name)
 Find predefined setting. More...
 
static uint64_t parse_setting_tag (const char *name)
 Parse setting name as tag number. More...
 
static const struct setting_typefind_setting_type (const char *name)
 Find setting type. More...
 
int parse_setting_name (char *name, get_child_settings_t get_child, struct settings **settings, struct setting *setting)
 Parse setting name. More...
 
int setting_name (struct settings *settings, const struct setting *setting, char *buf, size_t len)
 Return full setting name. More...
 
static int parse_string_setting (const struct setting_type *type __unused, const char *value, void *buf, size_t len)
 Parse string setting value. More...
 
static int format_string_setting (const struct setting_type *type __unused, const void *raw, size_t raw_len, char *buf, size_t len)
 Format string setting value. More...
 
static int parse_uristring_setting (const struct setting_type *type __unused, const char *value, void *buf, size_t len)
 Parse URI-encoded string setting value. More...
 
static int format_uristring_setting (const struct setting_type *type __unused, const void *raw, size_t raw_len, char *buf, size_t len)
 Format URI-encoded string setting value. More...
 
__weak int parse_ipv4_setting (const struct setting_type *type __unused, const char *value __unused, void *buf __unused, size_t len __unused)
 Parse IPv4 address setting value (when IPv4 support is not present) More...
 
__weak int format_ipv4_setting (const struct setting_type *type __unused, const void *raw __unused, size_t raw_len __unused, char *buf __unused, size_t len __unused)
 Format IPv4 address setting value (when IPv4 support is not present) More...
 
__weak int parse_ipv6_setting (const struct setting_type *type __unused, const char *value __unused, void *buf __unused, size_t len __unused)
 Parse IPv6 address setting value (when IPv6 support is not present) More...
 
__weak int format_ipv6_setting (const struct setting_type *type __unused, const void *raw __unused, size_t raw_len __unused, char *buf __unused, size_t len __unused)
 Format IPv6 address setting value (when IPv6 support is not present) More...
 
static unsigned int setting_type_int_index (const struct setting_type *type)
 Get integer setting type index. More...
 
static unsigned int setting_type_int_width (const struct setting_type *type)
 Get integer setting type width. More...
 
static int setting_type_int_is_signed (const struct setting_type *type)
 Get integer setting type signedness. More...
 
static int denumerate_int_setting (const struct setting_type *type, unsigned long value, void *buf, size_t len)
 Convert number to setting value. More...
 
static int numerate_int_setting (const struct setting_type *type, const void *raw, size_t raw_len, unsigned long *value)
 Convert setting value to number. More...
 
static int parse_int_setting (const struct setting_type *type, const char *value, void *buf, size_t len)
 Parse integer setting value. More...
 
static int format_int_setting (const struct setting_type *type, const void *raw, size_t raw_len, char *buf, size_t len)
 Format signed integer setting value. More...
 
static int format_uint_setting (const struct setting_type *type, const void *raw, size_t raw_len, char *buf, size_t len)
 Format unsigned integer setting value. More...
 
static int parse_hex_setting (const struct setting_type *type __unused, const char *value, void *buf, size_t len)
 Parse hex string setting value (using colon delimiter) More...
 
static int format_hex_colon_setting (const struct setting_type *type __unused, const void *raw, size_t raw_len, char *buf, size_t len)
 Format hex string setting value (using colon delimiter) More...
 
static int parse_hex_hyphen_setting (const struct setting_type *type __unused, const char *value, void *buf, size_t len)
 Parse hex string setting value (using hyphen delimiter) More...
 
static int format_hex_hyphen_setting (const struct setting_type *type __unused, const void *raw, size_t raw_len, char *buf, size_t len)
 Format hex string setting value (using hyphen delimiter) More...
 
static int parse_hex_raw_setting (const struct setting_type *type __unused, const char *value, void *buf, size_t len)
 Parse hex string setting value (using no delimiter) More...
 
static int format_hex_raw_setting (const struct setting_type *type __unused, const void *raw, size_t raw_len, char *buf, size_t len)
 Format hex string setting value (using no delimiter) More...
 
static int parse_base64_setting (const struct setting_type *type __unused, const char *value, void *buf, size_t len)
 Parse Base64-encoded setting value. More...
 
static int format_base64_setting (const struct setting_type *type __unused, const void *raw, size_t raw_len, char *buf, size_t len)
 Format Base64-encoded setting value. More...
 
static int format_uuid_setting (const struct setting_type *type __unused, const void *raw, size_t raw_len, char *buf, size_t len)
 Format UUID setting value. More...
 
static int format_busdevfn_setting (const struct setting_type *type __unused, const void *raw, size_t raw_len, char *buf, size_t len)
 Format PCI bus:dev.fn setting value. More...
 
char * expand_settings (const char *string)
 Expand variables within string. More...
 
const struct setting hostname_setting __setting (SETTING_HOST, hostname)
 Hostname setting. More...
 
const struct setting domain_setting __setting (SETTING_IP_EXTRA, domain)
 Domain name setting. More...
 
const struct setting next_server_setting __setting (SETTING_BOOT, next-server)
 TFTP server setting. More...
 
const struct setting filename_setting __setting (SETTING_BOOT, filename)
 Filename setting. More...
 
const struct setting root_path_setting __setting (SETTING_SANBOOT, root-path)
 Root path setting. More...
 
const struct setting san_filename_setting __setting (SETTING_SANBOOT, san-filename)
 SAN filename setting. More...
 
const struct setting username_setting __setting (SETTING_AUTH, username)
 Username setting. More...
 
const struct setting password_setting __setting (SETTING_AUTH, password)
 Password setting. More...
 
const struct setting priority_setting __setting (SETTING_MISC, priority)
 Priority setting. More...
 
const struct setting user_class_setting __setting (SETTING_HOST_EXTRA, user-class)
 DHCP user class setting. More...
 
const struct setting vendor_class_setting __setting (SETTING_HOST_EXTRA, vendor-class)
 DHCP vendor class setting. More...
 
static int errno_fetch (void *data, size_t len)
 Fetch error number setting. More...
 
const struct setting errno_setting __setting (SETTING_MISC, errno)
 Error number setting. More...
 
static int buildarch_fetch (void *data, size_t len)
 Fetch build architecture setting. More...
 
const struct setting buildarch_setting __setting (SETTING_MISC, buildarch)
 Build architecture setting. More...
 
static int platform_fetch (void *data, size_t len)
 Fetch platform setting. More...
 
const struct setting platform_setting __setting (SETTING_MISC, platform)
 Platform setting. More...
 
static int version_fetch (void *data, size_t len)
 Fetch version setting. More...
 
const struct setting version_setting __setting (SETTING_MISC, version)
 Version setting. More...
 
static int unixtime_fetch (void *data, size_t len)
 Fetch current time setting. More...
 
const struct setting unixtime_setting __setting (SETTING_MISC, unixtime)
 Current time setting. More...
 
static int builtin_fetch (struct settings *settings __unused, struct setting *setting, void *data, size_t len)
 Fetch built-in setting. More...
 
static int builtin_applies (struct settings *settings __unused, const struct setting *setting)
 Check applicability of built-in setting. More...
 
static void builtin_init (void)
 Initialise built-in settings. More...
 
struct init_fn builtin_init_fn __init_fn (INIT_NORMAL)
 Built-in settings initialiser. More...
 

Variables

struct settings_operations generic_settings_operations
 Generic settings operations. More...
 
struct generic_settings generic_settings_root
 Root generic settings block. More...
 
const struct setting_type setting_type_string __setting_type
 A string setting type. More...
 
const struct settings_scope dhcpv6_scope
 IPv6 settings scope. More...
 
static const char setting_type_int_name [][8]
 Integer setting type names. More...
 
const struct settings_scope builtin_scope
 Built-in setting scope. More...
 
struct builtin_setting errno_builtin_setting __builtin_setting
 Error number built-in setting. More...
 
static struct settings_operations builtin_settings_operations
 Built-in settings operations. More...
 
static struct settings builtin_settings
 Built-in settings. More...
 

Detailed Description

Configuration settings.

Definition in file settings.c.

Macro Definition Documentation

◆ settings_root

#define settings_root   generic_settings_root.settings

Root settings block.

Definition at line 249 of file settings.c.

◆ SETTING_TYPE_UINT_NAME

#define SETTING_TYPE_UINT_NAME (   index)    setting_type_int_name[index]

Get unsigned integer setting type name.

Parameters
indexInteger setting type index
Return values
nameSetting type name

Definition at line 1831 of file settings.c.

◆ SETTING_TYPE_INT_NAME

#define SETTING_TYPE_INT_NAME (   index)    ( setting_type_int_name[index] + 1 )

Get signed integer setting type name.

Parameters
indexInteger setting type index
Return values
nameSetting type name

Definition at line 1839 of file settings.c.

◆ SETTING_TYPE_INT

#define SETTING_TYPE_INT (   index)
Value:
{ \
.parse = parse_int_setting, \
.format = format_int_setting, \
.denumerate = denumerate_int_setting, \
.numerate = numerate_int_setting, \
}
static int numerate_int_setting(const struct setting_type *type, const void *raw, size_t raw_len, unsigned long *value)
Convert setting value to number.
Definition: settings.c:1909
static int parse_int_setting(const struct setting_type *type, const char *value, void *buf, size_t len)
Parse integer setting value.
Definition: settings.c:1933
static int format_int_setting(const struct setting_type *type, const void *raw, size_t raw_len, char *buf, size_t len)
Format signed integer setting value.
Definition: settings.c:1956
static int denumerate_int_setting(const struct setting_type *type, unsigned long value, void *buf, size_t len)
Convert number to setting value.
Definition: settings.c:1883
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define SETTING_TYPE_INT_NAME(index)
Get signed integer setting type name.
Definition: settings.c:1839

Define a signed integer setting type.

Parameters
indexInteger setting type index
Return values
typeSetting type

Definition at line 2000 of file settings.c.

◆ SETTING_TYPE_UINT

#define SETTING_TYPE_UINT (   index)
Value:
{ \
.parse = parse_int_setting, \
.format = format_uint_setting, \
.denumerate = denumerate_int_setting, \
.numerate = numerate_int_setting, \
}
static int numerate_int_setting(const struct setting_type *type, const void *raw, size_t raw_len, unsigned long *value)
Convert setting value to number.
Definition: settings.c:1909
static int parse_int_setting(const struct setting_type *type, const char *value, void *buf, size_t len)
Parse integer setting value.
Definition: settings.c:1933
#define SETTING_TYPE_UINT_NAME(index)
Get unsigned integer setting type name.
Definition: settings.c:1831
static int denumerate_int_setting(const struct setting_type *type, unsigned long value, void *buf, size_t len)
Convert number to setting value.
Definition: settings.c:1883
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
static int format_uint_setting(const struct setting_type *type, const void *raw, size_t raw_len, char *buf, size_t len)
Format unsigned integer setting value.
Definition: settings.c:1980

Define an unsigned integer setting type.

Parameters
indexInteger setting type index
Return values
typeSetting type

Definition at line 2014 of file settings.c.

Enumeration Type Documentation

◆ setting_type_int_index

Integer setting type indices.

These indexes are defined such that (1<<index) gives the width of the integer, in bytes.

Enumerator
SETTING_TYPE_INT8 
SETTING_TYPE_INT16 
SETTING_TYPE_INT32 

Definition at line 1804 of file settings.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ generic_setting_name()

static void* generic_setting_name ( struct generic_setting generic)
inlinestatic

Get generic setting name.

Parameters
genericGeneric setting
Return values
nameGeneric setting name

Definition at line 83 of file settings.c.

83  {
84  return ( ( ( void * ) generic ) + sizeof ( *generic ) );
85 }

Referenced by generic_settings_store().

◆ generic_setting_data()

static void* generic_setting_data ( struct generic_setting generic)
inlinestatic

Get generic setting data.

Parameters
genericGeneric setting
Return values
dataGeneric setting data

Definition at line 93 of file settings.c.

93  {
94  return ( ( ( void * ) generic ) + sizeof ( *generic ) +
95  generic->name_len );
96 }
struct arbelprm_event_queue_entry generic
Definition: arbel.h:11

References generic.

Referenced by generic_settings_fetch(), and generic_settings_store().

◆ find_generic_setting()

static struct generic_setting* find_generic_setting ( struct generic_settings generics,
const struct setting setting 
)
static

Find generic setting.

Parameters
genericsGeneric settings block
settingSetting to find
Return values
genericGeneric setting, or NULL

Definition at line 106 of file settings.c.

107  {
108  struct generic_setting *generic;
109 
110  list_for_each_entry ( generic, &generics->list, list ) {
111  if ( setting_cmp ( &generic->setting, setting ) == 0 )
112  return generic;
113  }
114  return NULL;
115 }
struct arbelprm_event_queue_entry generic
Definition: arbel.h:11
struct list_head list
List of generic settings.
Definition: settings.c:68
struct list_head list
List of generic settings.
Definition: settings.h:302
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
A generic setting.
Definition: settings.c:66
A setting.
Definition: settings.h:23
int setting_cmp(const struct setting *a, const struct setting *b)
Compare two settings.
Definition: settings.c:1124
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References generic, generic_settings::list, generic_setting::list, list_for_each_entry, NULL, and setting_cmp().

Referenced by generic_settings_fetch(), and generic_settings_store().

◆ generic_settings_store()

int generic_settings_store ( struct settings settings,
const struct setting setting,
const void *  data,
size_t  len 
)

Store value of generic setting.

Parameters
settingsSettings block
settingSetting to store
dataSetting data, or NULL to clear setting
lenLength of setting data
Return values
rcReturn status code

Definition at line 126 of file settings.c.

128  {
129  struct generic_settings *generics =
131  struct generic_setting *old;
132  struct generic_setting *new = NULL;
133  size_t name_len;
134 
135  /* Identify existing generic setting, if any */
136  old = find_generic_setting ( generics, setting );
137 
138  /* Create new generic setting, if required */
139  if ( len ) {
140  /* Allocate new generic setting */
141  name_len = ( strlen ( setting->name ) + 1 );
142  new = zalloc ( sizeof ( *new ) + name_len + len );
143  if ( ! new )
144  return -ENOMEM;
145 
146  /* Populate new generic setting */
147  new->name_len = name_len;
148  new->data_len = len;
149  memcpy ( &new->setting, setting, sizeof ( new->setting ) );
150  new->setting.name = generic_setting_name ( new );
151  memcpy ( generic_setting_name ( new ),
152  setting->name, name_len );
153  memcpy ( generic_setting_data ( new ), data, len );
154  }
155 
156  /* Delete existing generic setting, if any */
157  if ( old ) {
158  list_del ( &old->list );
159  free ( old );
160  }
161 
162  /* Add new setting to list, if any */
163  if ( new )
164  list_add ( &new->list, &generics->list );
165 
166  return 0;
167 }
size_t name_len
Size of setting name.
Definition: settings.c:72
static struct generic_setting * find_generic_setting(struct generic_settings *generics, const struct setting *setting)
Find generic setting.
Definition: settings.c:106
static void * generic_setting_name(struct generic_setting *generic)
Get generic setting name.
Definition: settings.c:83
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
int old
Definition: bitops.h:64
const char * name
Name.
Definition: settings.h:28
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define ENOMEM
Not enough space.
Definition: errno.h:534
struct list_head list
List of generic settings.
Definition: settings.h:302
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
A generic setting.
Definition: settings.c:66
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
size_t strlen(const char *src)
Get length of string.
Definition: string.c:228
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
static void * generic_setting_data(struct generic_setting *generic)
Get generic setting data.
Definition: settings.c:93
A generic settings block.
Definition: settings.h:298
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References container_of, data, ENOMEM, find_generic_setting(), free, generic_setting_data(), generic_setting_name(), len, generic_settings::list, list_add, list_del, memcpy(), setting::name, generic_setting::name_len, NULL, old, strlen(), and zalloc().

Referenced by netdev_store().

◆ generic_settings_fetch()

int generic_settings_fetch ( struct settings settings,
struct setting setting,
void *  data,
size_t  len 
)

Fetch value of generic setting.

Parameters
settingsSettings block
settingSetting to fetch
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 178 of file settings.c.

180  {
181  struct generic_settings *generics =
183  struct generic_setting *generic;
184 
185  /* Find generic setting */
186  generic = find_generic_setting ( generics, setting );
187  if ( ! generic )
188  return -ENOENT;
189 
190  /* Copy out generic setting data */
191  if ( len > generic->data_len )
192  len = generic->data_len;
193  memcpy ( data, generic_setting_data ( generic ), len );
194 
195  /* Set setting type, if not yet specified */
196  if ( ! setting->type )
197  setting->type = generic->setting.type;
198 
199  return generic->data_len;
200 }
static struct generic_setting * find_generic_setting(struct generic_settings *generics, const struct setting *setting)
Find generic setting.
Definition: settings.c:106
#define ENOENT
No such file or directory.
Definition: errno.h:514
struct arbelprm_event_queue_entry generic
Definition: arbel.h:11
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
const struct setting_type * type
Setting type.
Definition: settings.h:36
A generic setting.
Definition: settings.c:66
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
static void * generic_setting_data(struct generic_setting *generic)
Get generic setting data.
Definition: settings.c:93
A generic settings block.
Definition: settings.h:298
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References container_of, data, ENOENT, find_generic_setting(), generic, generic_setting_data(), len, memcpy(), and setting::type.

Referenced by netdev_fetch().

◆ generic_settings_clear()

void generic_settings_clear ( struct settings settings)

Clear generic settings block.

Parameters
settingsSettings block

Definition at line 207 of file settings.c.

207  {
208  struct generic_settings *generics =
210  struct generic_setting *generic;
211  struct generic_setting *tmp;
212 
213  list_for_each_entry_safe ( generic, tmp, &generics->list, list ) {
214  list_del ( &generic->list );
215  free ( generic );
216  }
217  assert ( list_empty ( &generics->list ) );
218 }
struct arbelprm_event_queue_entry generic
Definition: arbel.h:11
struct list_head list
List of generic settings.
Definition: settings.c:68
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct list_head list
List of generic settings.
Definition: settings.h:302
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:447
A generic setting.
Definition: settings.c:66
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
uint8_t * tmp
Definition: entropy.h:156
A settings block.
Definition: settings.h:132
A generic settings block.
Definition: settings.h:298

References assert(), container_of, free, generic, generic_settings::list, generic_setting::list, list_del, list_empty, list_for_each_entry_safe, and tmp.

Referenced by autovivified_settings_free(), and netdev_clear().

◆ autovivified_settings_free()

static void autovivified_settings_free ( struct refcnt refcnt)
static

Free autovivified settings block.

Parameters
refcntReference count

Definition at line 264 of file settings.c.

264  {
265  struct autovivified_settings *autovivified =
267 
268  generic_settings_clear ( &autovivified->generic.settings );
269  free ( autovivified );
270 }
Autovivified settings block.
Definition: settings.c:252
void generic_settings_clear(struct settings *settings)
Clear generic settings block.
Definition: settings.c:207
A reference counter.
Definition: refcnt.h:26
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct settings settings
Settings block.
Definition: settings.h:300
struct generic_settings generic
Generic settings block.
Definition: settings.c:256

References container_of, free, autovivified_settings::generic, generic_settings_clear(), and generic_settings::settings.

Referenced by autovivify_child_settings().

◆ find_child_settings()

struct settings* find_child_settings ( struct settings parent,
const char *  name 
)

Find child settings block.

Parameters
parentParent settings block
nameName within this parent
Return values
settingsSettings block, or NULL

Definition at line 279 of file settings.c.

280  {
281  struct settings *settings;
282 
283  /* Find target parent settings block */
285 
286  /* Treat empty name as meaning "this block" */
287  if ( ! *name )
288  return parent;
289 
290  /* Look for child with matching name */
292  if ( strcmp ( settings->name, name ) == 0 )
293  return settings_target ( settings );
294  }
295 
296  return NULL;
297 }
const char * name
Definition: ath9k_hw.c:1984
struct settings * parent
Parent settings block.
Definition: settings.h:138
struct settings * settings_target(struct settings *settings)
Redirect to target settings block.
Definition: settings.c:552
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
A settings block.
Definition: settings.h:132
const char * name
Name.
Definition: settings.h:136
struct list_head siblings
Sibling settings blocks.
Definition: settings.h:140
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:172
struct list_head children
Child settings blocks.
Definition: settings.h:142
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References settings::children, list_for_each_entry, settings::name, name, NULL, settings_target(), and strcmp().

Referenced by autovivify_child_settings(), efi_snp_hii_settings(), expand_settings(), find_settings(), parse_existing_setting(), and register_settings().

◆ autovivify_child_settings()

struct settings* autovivify_child_settings ( struct settings parent,
const char *  name 
)

Find or create child settings block.

Parameters
parentParent settings block
nameName within this parent
Return values
settingsSettings block, or NULL

Definition at line 306 of file settings.c.

307  {
308  struct {
309  struct autovivified_settings autovivified;
310  char name[ strlen ( name ) + 1 /* NUL */ ];
311  } *new_child;
312  struct settings *settings;
313 
314  /* Find target parent settings block */
316 
317  /* Return existing settings, if existent */
318  if ( ( settings = find_child_settings ( parent, name ) ) != NULL )
319  return settings;
320 
321  /* Create new generic settings block */
322  new_child = zalloc ( sizeof ( *new_child ) );
323  if ( ! new_child ) {
324  DBGC ( parent, "Settings %p could not create child %s\n",
325  parent, name );
326  return NULL;
327  }
328  memcpy ( new_child->name, name, sizeof ( new_child->name ) );
329  ref_init ( &new_child->autovivified.refcnt,
331  generic_settings_init ( &new_child->autovivified.generic,
332  &new_child->autovivified.refcnt );
333  settings = &new_child->autovivified.generic.settings;
334  register_settings ( settings, parent, new_child->name );
335  ref_put ( settings->refcnt );
336  return settings;
337 }
const char * name
Definition: ath9k_hw.c:1984
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
struct settings * parent
Parent settings block.
Definition: settings.h:138
static void generic_settings_init(struct generic_settings *generics, struct refcnt *refcnt)
Initialise a settings block.
Definition: settings.h:512
#define DBGC(...)
Definition: compiler.h:505
Autovivified settings block.
Definition: settings.c:252
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct settings * settings_target(struct settings *settings)
Redirect to target settings block.
Definition: settings.c:552
static void autovivified_settings_free(struct refcnt *refcnt)
Free autovivified settings block.
Definition: settings.c:264
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
size_t strlen(const char *src)
Get length of string.
Definition: string.c:228
A settings block.
Definition: settings.h:132
const char * name
Name.
Definition: settings.h:136
int register_settings(struct settings *settings, struct settings *parent, const char *name)
Register settings block.
Definition: settings.c:478
struct settings * find_child_settings(struct settings *parent, const char *name)
Find child settings block.
Definition: settings.c:279
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct refcnt * refcnt
Reference counter.
Definition: settings.h:134
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References autovivified_settings_free(), DBGC, find_child_settings(), generic_settings_init(), memcpy(), settings::name, name, NULL, ref_init, ref_put, settings::refcnt, register_settings(), settings_target(), strlen(), and zalloc().

Referenced by nslookup_resolv_done(), and parse_autovivified_setting().

◆ settings_name()

const char* settings_name ( struct settings settings)

Return settings block name.

Parameters
settingsSettings block
Return values
nameSettings block name

Definition at line 345 of file settings.c.

345  {
346  static char buf[16];
347  char tmp[ 1 /* '.' */ + sizeof ( buf ) ];
348 
349  /* Find target settings block */
351 
352  /* Construct name */
353  buf[0] = '\0';
354  tmp[0] = '\0';
355  for ( ; settings->parent ; settings = settings->parent ) {
356  memcpy ( ( tmp + 1 ), buf, ( sizeof ( tmp ) - 1 ) );
357  snprintf ( buf, sizeof ( buf ), "%s%s", settings->name, tmp );
358  tmp[0] = '.';
359  }
360  return buf;
361 }
struct settings * parent
Parent settings block.
Definition: settings.h:138
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct settings * settings_target(struct settings *settings)
Redirect to target settings block.
Definition: settings.c:552
uint8_t * tmp
Definition: entropy.h:156
A settings block.
Definition: settings.h:132
const char * name
Name.
Definition: settings.h:136
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382

References memcpy(), settings::name, settings::parent, settings_target(), snprintf(), and tmp.

Referenced by draw_title_row(), parse_setting_name(), register_settings(), setting_name(), and unregister_settings().

◆ parse_settings_name()

static struct settings* parse_settings_name ( const char *  name,
get_child_settings_t  get_child 
)
static

Parse settings block name.

Parameters
nameName
get_childFunction to find or create child settings block
Return values
settingsSettings block, or NULL

Definition at line 371 of file settings.c.

371  {
372  struct settings *settings = &settings_root;
373  char *name_copy;
374  char *subname;
375  char *remainder;
376 
377  /* Create modifiable copy of name */
378  name_copy = strdup ( name );
379  if ( ! name_copy )
380  return NULL;
381  remainder = name_copy;
382 
383  /* Parse each name component in turn */
384  while ( remainder ) {
385  subname = remainder;
386  remainder = strchr ( subname, '.' );
387  if ( remainder )
388  *(remainder++) = '\0';
389  settings = get_child ( settings, subname );
390  if ( ! settings )
391  break;
392  }
393 
394  /* Free modifiable copy of name */
395  free ( name_copy );
396 
397  return settings;
398 }
const char * name
Definition: ath9k_hw.c:1984
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
char * strchr(const char *src, int character)
Find character within a string.
Definition: string.c:256
char * strdup(const char *src)
Duplicate string.
Definition: string.c:365
A settings block.
Definition: settings.h:132
#define settings_root
Root settings block.
Definition: settings.c:249
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References free, name, NULL, settings_root, strchr(), and strdup().

Referenced by find_settings(), and parse_setting_name().

◆ find_settings()

struct settings* find_settings ( const char *  name)

Find settings block.

Parameters
nameName
Return values
settingsSettings block, or NULL

Definition at line 406 of file settings.c.

406  {
407 
409 }
const char * name
Definition: ath9k_hw.c:1984
static struct settings * parse_settings_name(const char *name, get_child_settings_t get_child)
Parse settings block name.
Definition: settings.c:371
struct settings * find_child_settings(struct settings *parent, const char *name)
Find child settings block.
Definition: settings.c:279

References find_child_settings(), name, and parse_settings_name().

Referenced by create_fakepxebsack(), parse_settings(), and pxe_menu_boot().

◆ apply_settings()

static int apply_settings ( void  )
static

Apply all settings.

Return values
rcReturn status code

Definition at line 416 of file settings.c.

416  {
417  struct settings_applicator *applicator;
418  int rc;
419 
420  /* Call all settings applicators */
422  if ( ( rc = applicator->apply() ) != 0 ) {
423  DBG ( "Could not apply settings using applicator "
424  "%p: %s\n", applicator, strerror ( rc ) );
425  return rc;
426  }
427  }
428 
429  return 0;
430 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A settings applicator.
Definition: settings.h:251
#define SETTINGS_APPLICATORS
Settings applicator table.
Definition: settings.h:260
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
int(* apply)(void)
Apply updated settings.
Definition: settings.h:256
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References settings_applicator::apply, DBG, for_each_table_entry, rc, SETTINGS_APPLICATORS, and strerror().

Referenced by register_settings(), store_setting(), and unregister_settings().

◆ reprioritise_settings()

static void reprioritise_settings ( struct settings settings)
static

Reprioritise settings.

Parameters
settingsSettings block

Reorders the settings block amongst its siblings according to its priority.

Definition at line 440 of file settings.c.

440  {
441  struct settings *parent = settings->parent;
442  long priority;
443  struct settings *tmp;
444  long tmp_priority;
445 
446  /* Stop when we reach the top of the tree */
447  if ( ! parent )
448  return;
449 
450  /* Read priority, if present */
451  priority = fetch_intz_setting ( settings, &priority_setting );
452 
453  /* Remove from siblings list */
454  list_del ( &settings->siblings );
455 
456  /* Reinsert after any existing blocks which have a higher priority */
458  tmp_priority = fetch_intz_setting ( tmp, &priority_setting );
459  if ( priority > tmp_priority )
460  break;
461  if ( settings->order > tmp->order )
462  break;
463  }
464  list_add_tail ( &settings->siblings, &tmp->siblings );
465 
466  /* Recurse up the tree */
468 }
long fetch_intz_setting(struct settings *settings, const struct setting *setting)
Fetch value of signed integer setting, or zero.
Definition: settings.c:1057
struct settings * parent
Parent settings block.
Definition: settings.h:138
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
uint8_t * tmp
Definition: entropy.h:156
static void reprioritise_settings(struct settings *settings)
Reprioritise settings.
Definition: settings.c:440
A settings block.
Definition: settings.h:132
struct list_head siblings
Sibling settings blocks.
Definition: settings.h:140
int order
Sibling ordering.
Definition: settings.h:148
uint16_t priority
Priotity.
Definition: stp.h:12
struct list_head children
Child settings blocks.
Definition: settings.h:142

References settings::children, fetch_intz_setting(), list_add_tail, list_del, list_for_each_entry, settings::order, settings::parent, priority, settings::siblings, and tmp.

Referenced by register_settings(), and store_setting().

◆ register_settings()

int register_settings ( struct settings settings,
struct settings parent,
const char *  name 
)

Register settings block.

Parameters
settingsSettings block
parentParent settings block, or NULL
nameSettings block name
Return values
rcReturn status code

Definition at line 478 of file settings.c.

479  {
480  struct settings *old_settings;
481 
482  /* Sanity check */
483  assert ( settings != NULL );
484 
485  /* Find target parent settings block */
487 
488  /* Apply settings block name */
489  settings->name = name;
490 
491  /* Remove any existing settings with the same name */
492  if ( ( old_settings = find_child_settings ( parent, settings->name ) ))
493  unregister_settings ( old_settings );
494 
495  /* Add to list of settings */
496  ref_get ( settings->refcnt );
497  ref_get ( parent->refcnt );
500  DBGC ( settings, "Settings %p (\"%s\") registered\n",
502 
503  /* Fix up settings priority */
505 
506  /* Apply potentially-updated settings */
507  apply_settings();
508 
509  return 0;
510 }
const char * name
Definition: ath9k_hw.c:1984
void unregister_settings(struct settings *settings)
Unregister settings block.
Definition: settings.c:517
struct settings * parent
Parent settings block.
Definition: settings.h:138
#define DBGC(...)
Definition: compiler.h:505
const char * settings_name(struct settings *settings)
Return settings block name.
Definition: settings.c:345
static int apply_settings(void)
Apply all settings.
Definition: settings.c:416
struct settings * settings_target(struct settings *settings)
Redirect to target settings block.
Definition: settings.c:552
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
static void reprioritise_settings(struct settings *settings)
Reprioritise settings.
Definition: settings.c:440
A settings block.
Definition: settings.h:132
const char * name
Name.
Definition: settings.h:136
struct list_head siblings
Sibling settings blocks.
Definition: settings.h:140
struct list_head children
Child settings blocks.
Definition: settings.h:142
struct settings * find_child_settings(struct settings *parent, const char *name)
Find child settings block.
Definition: settings.c:279
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct refcnt * refcnt
Reference counter.
Definition: settings.h:134

References apply_settings(), assert(), settings::children, DBGC, find_child_settings(), list_add_tail, settings::name, name, NULL, settings::parent, ref_get, settings::refcnt, reprioritise_settings(), settings_name(), settings_target(), settings::siblings, and unregister_settings().

Referenced by acpi_settings_init(), autovivify_child_settings(), builtin_init(), cachedhcp_probe(), cpuid_settings_init(), dhcp_proxy_rx(), dhcp_pxebs_rx(), dhcp_request_rx(), dhcpv6_register(), guestinfo_init(), guestinfo_net_probe(), ipv6_register_settings(), memmap_settings_init(), ndp_register_settings(), netdev_redirect_settings_init(), pci_settings_init(), phantom_probe(), register_netdev(), register_nvo(), settings_test_exec(), and smbios_init().

◆ unregister_settings()

void unregister_settings ( struct settings settings)

Unregister settings block.

Parameters
settingsSettings block

Definition at line 517 of file settings.c.

517  {
518  struct settings *child;
519 
520  /* Unregister child settings */
521  while ( ( child = list_first_entry ( &settings->children,
522  struct settings, siblings ) ) ) {
523  unregister_settings ( child );
524  }
525 
526  DBGC ( settings, "Settings %p (\"%s\") unregistered\n",
528 
529  /* Remove from list of settings */
531  settings->parent = NULL;
532  list_del ( &settings->siblings );
533  ref_put ( settings->refcnt );
534 
535  /* Apply potentially-updated settings */
536  apply_settings();
537 }
void unregister_settings(struct settings *settings)
Unregister settings block.
Definition: settings.c:517
struct settings * parent
Parent settings block.
Definition: settings.h:138
#define DBGC(...)
Definition: compiler.h:505
const char * settings_name(struct settings *settings)
Return settings block name.
Definition: settings.c:345
static int apply_settings(void)
Apply all settings.
Definition: settings.c:416
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
A settings block.
Definition: settings.h:132
struct list_head siblings
Sibling settings blocks.
Definition: settings.h:140
struct list_head children
Child settings blocks.
Definition: settings.h:142
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
struct refcnt * refcnt
Reference counter.
Definition: settings.h:134
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References apply_settings(), settings::children, DBGC, list_del, list_first_entry, NULL, settings::parent, ref_put, settings::refcnt, settings_name(), settings::siblings, and unregister_settings().

Referenced by guestinfo_net_remove(), ndp_register_settings(), phantom_probe(), phantom_remove(), register_netdev(), register_settings(), settings_test_exec(), unregister_netdev(), unregister_nvo(), and unregister_settings().

◆ settings_target()

struct settings* settings_target ( struct settings settings)

Redirect to target settings block.

Parameters
settingsSettings block, or NULL
Return values
settingsUnderlying settings block

Definition at line 552 of file settings.c.

552  {
553 
554  /* NULL settings implies the global settings root */
555  if ( ! settings )
557 
558  /* Redirect to underlying settings block, if applicable */
559  if ( settings->op->redirect )
560  return settings->op->redirect ( settings );
561 
562  /* Otherwise, return this settings block */
563  return settings;
564 }
struct settings_operations * op
Settings block operations.
Definition: settings.h:144
struct settings *(* redirect)(struct settings *settings)
Redirect to underlying settings block (if applicable)
Definition: settings.h:91
A settings block.
Definition: settings.h:132
#define settings_root
Root settings block.
Definition: settings.c:249

References settings::op, settings_operations::redirect, and settings_root.

Referenced by autovivify_child_settings(), clear_settings(), fetch_setting(), find_child_settings(), register_settings(), select_settings(), setting_applies(), setting_name(), settings_name(), and store_setting().

◆ setting_applies()

int setting_applies ( struct settings settings,
const struct setting setting 
)

Check applicability of setting.

Parameters
settingsSettings block
settingSetting
Return values
appliesSetting applies within this settings block

Definition at line 573 of file settings.c.

574  {
575 
576  /* Find target settings block */
578 
579  /* Check applicability of setting */
580  return ( settings->op->applies ?
581  settings->op->applies ( settings, setting ) : 1 );
582 }
struct settings_operations * op
Settings block operations.
Definition: settings.h:144
struct settings * settings_target(struct settings *settings)
Redirect to target settings block.
Definition: settings.c:552
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
int(* applies)(struct settings *settings, const struct setting *setting)
Check applicability of setting.
Definition: settings.h:98

References settings_operations::applies, settings::op, and settings_target().

Referenced by applicable_setting(), select_setting_row(), and store_setting().

◆ applicable_setting()

static const struct setting* applicable_setting ( struct settings settings,
const struct setting setting 
)
static

Find setting applicable to settings block, if any.

Parameters
settingsSettings block
settingSetting
Return values
settingApplicable setting, if any

Definition at line 592 of file settings.c.

592  {
593  const struct setting *applicable;
594 
595  /* If setting is already applicable, use it */
596  if ( setting_applies ( settings, setting ) )
597  return setting;
598 
599  /* Otherwise, look for a matching predefined setting which does apply */
600  for_each_table_entry ( applicable, SETTINGS ) {
601  if ( ( setting_cmp ( setting, applicable ) == 0 ) &&
602  ( setting_applies ( settings, applicable ) ) )
603  return applicable;
604  }
605 
606  return NULL;
607 }
#define SETTINGS
Configuration setting table.
Definition: settings.h:53
int setting_applies(struct settings *settings, const struct setting *setting)
Check applicability of setting.
Definition: settings.c:573
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
int setting_cmp(const struct setting *a, const struct setting *b)
Compare two settings.
Definition: settings.c:1124
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References for_each_table_entry, NULL, generic_setting::setting, setting_applies(), setting_cmp(), and SETTINGS.

Referenced by fetch_setting().

◆ store_setting()

int store_setting ( struct settings settings,
const struct setting setting,
const void *  data,
size_t  len 
)

Store value of setting.

Parameters
settingsSettings block, or NULL
settingSetting to store
dataSetting data, or NULL to clear setting
lenLength of setting data
Return values
rcReturn status code

Definition at line 618 of file settings.c.

619  {
620  int rc;
621 
622  /* Find target settings block */
624 
625  /* Fail if setting does not apply to this settings block */
626  if ( ! setting_applies ( settings, setting ) )
627  return -ENOTTY;
628 
629  /* Sanity check */
630  if ( ! settings->op->store )
631  return -ENOTSUP;
632 
633  /* Store setting */
634  if ( ( rc = settings->op->store ( settings, setting,
635  data, len ) ) != 0 )
636  return rc;
637 
638  /* Reprioritise settings if necessary */
639  if ( setting_cmp ( setting, &priority_setting ) == 0 )
641 
642  /* If these settings are registered, apply potentially-updated
643  * settings
644  */
645  for ( ; settings ; settings = settings->parent ) {
646  if ( settings == &settings_root ) {
647  if ( ( rc = apply_settings() ) != 0 )
648  return rc;
649  break;
650  }
651  }
652 
653  return 0;
654 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct settings * parent
Parent settings block.
Definition: settings.h:138
static int apply_settings(void)
Apply all settings.
Definition: settings.c:416
struct settings_operations * op
Settings block operations.
Definition: settings.h:144
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
struct settings * settings_target(struct settings *settings)
Redirect to target settings block.
Definition: settings.c:552
int setting_applies(struct settings *settings, const struct setting *setting)
Check applicability of setting.
Definition: settings.c:573
static void reprioritise_settings(struct settings *settings)
Reprioritise settings.
Definition: settings.c:440
A settings block.
Definition: settings.h:132
#define settings_root
Root settings block.
Definition: settings.c:249
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14
#define ENOTTY
Inappropriate I/O control operation.
Definition: errno.h:594
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
int(* store)(struct settings *settings, const struct setting *setting, const void *data, size_t len)
Store value of setting.
Definition: settings.h:108
int setting_cmp(const struct setting *a, const struct setting *b)
Compare two settings.
Definition: settings.c:1124

References apply_settings(), data, ENOTSUP, ENOTTY, len, settings::op, settings::parent, rc, reprioritise_settings(), setting_applies(), setting_cmp(), settings_root, settings_target(), and settings_operations::store.

Referenced by delete_setting(), login_ui(), nslookup_resolv_done(), storef_setting(), and storen_setting().

◆ fetch_setting()

int fetch_setting ( struct settings settings,
const struct setting setting,
struct settings **  origin,
struct setting fetched,
void *  data,
size_t  len 
)

Fetch setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
originOrigin of setting to fill in, or NULL
fetchedFetched setting to fill in, or NULL
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

The actual length of the setting will be returned even if the buffer was too small.

Definition at line 670 of file settings.c.

672  {
673  const struct setting *applicable;
674  struct settings *child;
675  struct setting tmp;
676  int ret;
677 
678  /* Avoid returning uninitialised data on error */
679  memset ( data, 0, len );
680  if ( origin )
681  *origin = NULL;
682  if ( fetched )
683  memcpy ( fetched, setting, sizeof ( *fetched ) );
684 
685  /* Find target settings block */
687 
688  /* Sanity check */
689  if ( ! settings->op->fetch )
690  return -ENOTSUP;
691 
692  /* Try this block first, if an applicable setting exists */
693  if ( ( applicable = applicable_setting ( settings, setting ) ) ) {
694 
695  /* Create modifiable copy of setting */
696  memcpy ( &tmp, applicable, sizeof ( tmp ) );
697  if ( ( ret = settings->op->fetch ( settings, &tmp,
698  data, len ) ) >= 0 ) {
699 
700  /* Default to string type, if not yet specified */
701  if ( ! tmp.type )
702  tmp.type = &setting_type_string;
703 
704  /* Record origin, if applicable */
705  if ( origin )
706  *origin = settings;
707 
708  /* Record fetched setting, if applicable */
709  if ( fetched )
710  memcpy ( fetched, &tmp, sizeof ( *fetched ) );
711 
712  return ret;
713  }
714  }
715 
716  /* Recurse into each child block in turn */
717  list_for_each_entry ( child, &settings->children, siblings ) {
718  if ( ( ret = fetch_setting ( child, setting, origin, fetched,
719  data, len ) ) >= 0 )
720  return ret;
721  }
722 
723  return -ENOENT;
724 }
uint64_t origin
Origin.
Definition: hyperv.h:20
#define ENOENT
No such file or directory.
Definition: errno.h:514
struct settings_operations * op
Settings block operations.
Definition: settings.h:144
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct settings * settings_target(struct settings *settings)
Redirect to target settings block.
Definition: settings.c:552
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
int fetch_setting(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void *data, size_t len)
Fetch setting.
Definition: settings.c:670
uint8_t * tmp
Definition: entropy.h:156
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
static const struct setting * applicable_setting(struct settings *settings, const struct setting *setting)
Find setting applicable to settings block, if any.
Definition: settings.c:592
uint32_t len
Length.
Definition: ena.h:14
int(* fetch)(struct settings *settings, struct setting *setting, void *data, size_t len)
Fetch value of setting.
Definition: settings.h:122
struct list_head children
Child settings blocks.
Definition: settings.h:142
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
void * memset(void *dest, int character, size_t len) __nonnull

References applicable_setting(), settings::children, data, ENOENT, ENOTSUP, settings_operations::fetch, fetch_setting(), len, list_for_each_entry, memcpy(), memset(), NULL, settings::op, origin, settings_target(), and tmp.

Referenced by fetch_next_server_and_filename(), fetch_raw_setting(), fetch_setting(), fetch_setting_alloc(), ibft_fill_nic(), ibft_set_string_setting(), ipv6_create_routes(), and setting_exists().

◆ fetch_setting_alloc()

static int fetch_setting_alloc ( struct settings settings,
const struct setting setting,
struct settings **  origin,
struct setting fetched,
void **  data,
void *(*)(size_t len alloc 
)
static

Fetch allocated copy of setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
originOrigin of setting to fill in, or NULL
fetchedFetched setting to fill in, or NULL
dataBuffer to allocate and fill with setting data
allocAllocation function
Return values
lenLength of setting, or negative error

The caller is responsible for eventually freeing the allocated buffer.

Definition at line 740 of file settings.c.

745  {
746  struct settings *tmp_origin;
747  struct setting tmp_fetched;
748  int len;
749  int check_len;
750 
751  /* Use local buffers if necessary */
752  if ( ! origin )
753  origin = &tmp_origin;
754  if ( ! fetched )
755  fetched = &tmp_fetched;
756 
757  /* Avoid returning uninitialised data on error */
758  *data = NULL;
759 
760  /* Check existence, and fetch setting length */
761  len = fetch_setting ( settings, setting, origin, fetched, NULL, 0 );
762  if ( len < 0 )
763  return len;
764 
765  /* Allocate buffer */
766  *data = alloc ( len );
767  if ( ! *data )
768  return -ENOMEM;
769 
770  /* Fetch setting value */
771  check_len = fetch_setting ( *origin, fetched, NULL, NULL, *data, len );
772  assert ( check_len == len );
773  return len;
774 }
uint64_t origin
Origin.
Definition: hyperv.h:20
#define ENOMEM
Not enough space.
Definition: errno.h:534
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
int fetch_setting(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void *data, size_t len)
Fetch setting.
Definition: settings.c:670
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References assert(), data, ENOMEM, fetch_setting(), len, NULL, and origin.

Referenced by fetch_setting_copy(), and fetch_string_setting_copy().

◆ fetch_setting_copy()

int fetch_setting_copy ( struct settings settings,
const struct setting setting,
struct settings **  origin,
struct setting fetched,
void **  data 
)

Fetch copy of setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
originOrigin of setting to fill in, or NULL
fetchedFetched setting to fill in, or NULL
dataBuffer to allocate and fill with setting data
Return values
lenLength of setting, or negative error

The caller is responsible for eventually freeing the allocated buffer.

Definition at line 789 of file settings.c.

792  {
793 
794  return fetch_setting_alloc ( settings, setting, origin, fetched,
795  data, malloc );
796 }
uint64_t origin
Origin.
Definition: hyperv.h:20
static int fetch_setting_alloc(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void **data, void *(*alloc)(size_t len))
Fetch allocated copy of setting.
Definition: settings.c:740
A settings block.
Definition: settings.h:132
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:583
A setting.
Definition: settings.h:23
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References data, fetch_setting_alloc(), malloc(), and origin.

Referenced by fetch_raw_setting_copy(), fetchf_setting(), and fetchn_setting().

◆ fetch_raw_setting()

int fetch_raw_setting ( struct settings settings,
const struct setting setting,
void *  data,
size_t  len 
)

Fetch value of setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
dataBuffer to fill with setting string data
lenLength of buffer
Return values
lenLength of setting, or negative error

Definition at line 807 of file settings.c.

809  {
810 
811  return fetch_setting ( settings, setting, NULL, NULL, data, len );
812 }
int fetch_setting(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void *data, size_t len)
Fetch setting.
Definition: settings.c:670
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References data, fetch_setting(), len, and NULL.

Referenced by dhcp_create_request(), dhcpv6_user_class(), fetch_ipv4_array_setting(), fetch_ipv6_array_setting(), fetch_numeric_setting(), fetch_string_setting(), fetch_uuid_setting(), pxe_menu_parse(), start_pxebs(), trivial_change_key(), and trivial_init().

◆ fetch_raw_setting_copy()

int fetch_raw_setting_copy ( struct settings settings,
const struct setting setting,
void **  data 
)

Fetch value of setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
dataBuffer to allocate and fill with setting data
Return values
lenLength of setting, or negative error

The caller is responsible for eventually freeing the allocated buffer.

Definition at line 825 of file settings.c.

827  {
828 
830 }
A settings block.
Definition: settings.h:132
int fetch_setting_copy(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void **data)
Fetch copy of setting.
Definition: settings.c:789
A setting.
Definition: settings.h:23
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References data, fetch_setting_copy(), and NULL.

Referenced by apply_dns_search(), apply_dns_servers(), certstore_apply_settings(), copy_encap_settings(), dhcp_create_request(), privkey_apply_settings(), and rootcert_init().

◆ fetch_string_setting()

int fetch_string_setting ( struct settings settings,
const struct setting setting,
char *  data,
size_t  len 
)

Fetch value of string setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
dataBuffer to fill with setting string data
lenLength of buffer
Return values
lenLength of string setting, or negative error

The resulting string is guaranteed to be correctly NUL-terminated. The returned length will be the length of the underlying setting data.

Definition at line 845 of file settings.c.

847  {
848 
849  memset ( data, 0, len );
851  ( ( len > 0 ) ? ( len - 1 ) : 0 ) );
852 }
int fetch_raw_setting(struct settings *settings, const struct setting *setting, void *data, size_t len)
Fetch value of setting.
Definition: settings.c:807
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
void * memset(void *dest, int character, size_t len) __nonnull

References data, fetch_raw_setting(), len, and memset().

Referenced by efi_blacklist_dell_ip4config(), have_pxe_menu(), ib_sma_node_desc(), ibft_set_string_setting(), login_ui(), net80211_autoassociate(), net80211_check_settings_update(), wpa_psk_start(), and xsigo_xds_complete().

◆ fetch_string_setting_copy_alloc()

static void* fetch_string_setting_copy_alloc ( size_t  len)
static

Allocate memory for copy of string setting.

Parameters
lenLength of setting
Return values
ptrAllocated memory

Definition at line 860 of file settings.c.

860  {
861  return zalloc ( len + 1 /* NUL */ );
862 }
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
uint32_t len
Length.
Definition: ena.h:14

References len, and zalloc().

Referenced by fetch_string_setting_copy().

◆ fetch_string_setting_copy()

int fetch_string_setting_copy ( struct settings settings,
const struct setting setting,
char **  data 
)

Fetch value of string setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
dataBuffer to allocate and fill with setting string data
Return values
lenLength of string setting, or negative error

The resulting string is guaranteed to be correctly NUL-terminated. The returned length will be the length of the underlying setting data. The caller is responsible for eventually freeing the allocated buffer.

Definition at line 877 of file settings.c.

878  {
879 
881  ( ( void ** ) data ),
883 }
static int fetch_setting_alloc(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void **data, void *(*alloc)(size_t len))
Fetch allocated copy of setting.
Definition: settings.c:740
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
static void * fetch_string_setting_copy_alloc(size_t len)
Allocate memory for copy of string setting.
Definition: settings.c:860
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References data, fetch_setting_alloc(), fetch_string_setting_copy_alloc(), and NULL.

Referenced by apply_dns_search(), apply_peerdisc_settings(), apply_syslog_settings(), apply_syslogs_settings(), fetch_next_server_and_filename(), fetch_root_path(), fetch_san_filename(), ipxe(), iscsi_fetch_settings(), oncrpc_init_cred_sys(), and validator_start_download().

◆ fetch_ipv4_array_setting()

int fetch_ipv4_array_setting ( struct settings settings,
const struct setting setting,
struct in_addr inp,
unsigned int  count 
)

Fetch value of IPv4 address setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
inpIPv4 addresses to fill in
countMaximum number of IPv4 addresses
Return values
lenLength of setting, or negative error

Definition at line 894 of file settings.c.

896  {
897  int len;
898 
900  ( sizeof ( *inp ) * count ) );
901  if ( len < 0 )
902  return len;
903  if ( ( len % sizeof ( *inp ) ) != 0 )
904  return -ERANGE;
905  return len;
906 }
int fetch_raw_setting(struct settings *settings, const struct setting *setting, void *data, size_t len)
Fetch value of setting.
Definition: settings.c:807
#define ERANGE
Result too large.
Definition: errno.h:639
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14
uint16_t count
Number of entries.
Definition: ena.h:22

References count, ERANGE, fetch_raw_setting(), and len.

Referenced by fetch_ipv4_setting(), and ibft_set_ipaddr_setting().

◆ fetch_ipv4_setting()

int fetch_ipv4_setting ( struct settings settings,
const struct setting setting,
struct in_addr inp 
)

Fetch value of IPv4 address setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
inpIPv4 address to fill in
Return values
lenLength of setting, or negative error

Definition at line 916 of file settings.c.

918  {
919 
920  return fetch_ipv4_array_setting ( settings, setting, inp, 1 );
921 }
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
int fetch_ipv4_array_setting(struct settings *settings, const struct setting *setting, struct in_addr *inp, unsigned int count)
Fetch value of IPv4 address setting.
Definition: settings.c:894

References fetch_ipv4_array_setting().

Referenced by apply_syslog_settings(), create_fakepxebsack(), efi_pxe_install(), efi_pxe_ip(), fetch_next_server_and_filename(), gdbudp_configure(), ibft_fill_nic(), ipv4_settings(), start_pxebs(), and tftp_apply_settings().

◆ fetch_ipv6_array_setting()

int fetch_ipv6_array_setting ( struct settings settings,
const struct setting setting,
struct in6_addr inp,
unsigned int  count 
)

Fetch value of IPv6 address setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
inpIPv6 addresses to fill in
countMaximum number of IPv6 addresses
Return values
lenLength of setting, or negative error

Definition at line 932 of file settings.c.

934  {
935  int len;
936 
938  ( sizeof ( *inp ) * count ) );
939  if ( len < 0 )
940  return len;
941  if ( ( len % sizeof ( *inp ) ) != 0 )
942  return -ERANGE;
943  return len;
944 }
int fetch_raw_setting(struct settings *settings, const struct setting *setting, void *data, size_t len)
Fetch value of setting.
Definition: settings.c:807
#define ERANGE
Result too large.
Definition: errno.h:639
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14
uint16_t count
Number of entries.
Definition: ena.h:22

References count, ERANGE, fetch_raw_setting(), and len.

Referenced by fetch_ipv6_setting().

◆ fetch_ipv6_setting()

int fetch_ipv6_setting ( struct settings settings,
const struct setting setting,
struct in6_addr inp 
)

Fetch value of IPv6 address setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
inpIPv6 address to fill in
Return values
lenLength of setting, or negative error

Definition at line 954 of file settings.c.

956  {
957 
958  return fetch_ipv6_array_setting ( settings, setting, inp, 1 );
959 }
int fetch_ipv6_array_setting(struct settings *settings, const struct setting *setting, struct in6_addr *inp, unsigned int count)
Fetch value of IPv6 address setting.
Definition: settings.c:932
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23

References fetch_ipv6_array_setting().

Referenced by apply_syslog_settings().

◆ numeric_setting_value()

static int numeric_setting_value ( int  is_signed,
const void *  raw,
size_t  len,
unsigned long *  value 
)
static

Extract numeric value of setting.

Parameters
is_signedTreat value as a signed integer
rawRaw setting data
lenLength of raw setting data
Return values
valueNumeric value
lenLength of setting, or negative error

Definition at line 970 of file settings.c.

971  {
972  const uint8_t *unsigned_bytes = raw;
973  const int8_t *signed_bytes = raw;
974  int is_negative;
975  unsigned int i;
976  uint8_t pad;
977  uint8_t byte;
978 
979  /* Convert to host-ordered longs */
980  is_negative = ( len && ( signed_bytes[0] < 0 ) );
981  *value = ( ( is_signed && is_negative ) ? -1L : 0 );
982  pad = *value;
983  for ( i = 0 ; i < len ; i++ ) {
984  byte = unsigned_bytes[i];
985  *value = ( ( *value << 8 ) | byte );
986  if ( ( ( i + sizeof ( *value ) ) < len ) && ( byte != pad ) )
987  return -ERANGE;
988  }
989 
990  return len;
991 }
u32 pad[9]
Padding.
Definition: ar9003_mac.h:90
signed char int8_t
Definition: stdint.h:15
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
#define ERANGE
Result too large.
Definition: errno.h:639
unsigned char uint8_t
Definition: stdint.h:10
unsigned char byte
Definition: smc9000.h:38
uint32_t len
Length.
Definition: ena.h:14
__be32 raw[7]
Definition: CIB_PRM.h:28

References ERANGE, len, pad, raw, and value.

Referenced by fetch_numeric_setting(), format_busdevfn_setting(), and numerate_int_setting().

◆ fetch_numeric_setting()

int fetch_numeric_setting ( struct settings settings,
const struct setting setting,
unsigned long *  value,
int  is_signed 
)

Fetch value of numeric setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
valueInteger value to fill in
Return values
lenLength of setting, or negative error

Definition at line 1001 of file settings.c.

1003  {
1004  unsigned long tmp;
1005  int len;
1006 
1007  /* Avoid returning uninitialised data on error */
1008  *value = 0;
1009 
1010  /* Fetch raw (network-ordered, variable-length) setting */
1011  len = fetch_raw_setting ( settings, setting, &tmp, sizeof ( tmp ) );
1012  if ( len < 0 )
1013  return len;
1014 
1015  /* Extract numeric value */
1016  return numeric_setting_value ( is_signed, &tmp, len, value );
1017 }
int fetch_raw_setting(struct settings *settings, const struct setting *setting, void *data, size_t len)
Fetch value of setting.
Definition: settings.c:807
static int numeric_setting_value(int is_signed, const void *raw, size_t len, unsigned long *value)
Extract numeric value of setting.
Definition: settings.c:970
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
uint8_t * tmp
Definition: entropy.h:156
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14

References fetch_raw_setting(), len, numeric_setting_value(), tmp, and value.

Referenced by fetch_int_setting(), fetch_intz_setting(), fetch_uint_setting(), and fetch_uintz_setting().

◆ fetch_int_setting()

int fetch_int_setting ( struct settings settings,
const struct setting setting,
long *  value 
)

Fetch value of signed integer setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
valueInteger value to fill in
Return values
lenLength of setting, or negative error

Definition at line 1027 of file settings.c.

1029  {
1030 
1032  ( ( unsigned long * ) value ), 1 );
1033 }
int fetch_numeric_setting(struct settings *settings, const struct setting *setting, unsigned long *value, int is_signed)
Fetch value of numeric setting.
Definition: settings.c:1001
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23

References fetch_numeric_setting(), and value.

Referenced by apply_peerdist_settings().

◆ fetch_uint_setting()

int fetch_uint_setting ( struct settings settings,
const struct setting setting,
unsigned long *  value 
)

Fetch value of unsigned integer setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
valueInteger value to fill in
Return values
lenLength of setting, or negative error

Definition at line 1043 of file settings.c.

1045  {
1046 
1047  return fetch_numeric_setting ( settings, setting, value, 0 );
1048 }
int fetch_numeric_setting(struct settings *settings, const struct setting *setting, unsigned long *value, int is_signed)
Fetch value of numeric setting.
Definition: settings.c:1001
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23

References fetch_numeric_setting(), and value.

Referenced by san_default_drive(), and sandev_apply().

◆ fetch_intz_setting()

long fetch_intz_setting ( struct settings settings,
const struct setting setting 
)

Fetch value of signed integer setting, or zero.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
Return values
valueSetting value, or zero

Definition at line 1057 of file settings.c.

1058  {
1059  unsigned long value;
1060 
1062  return value;
1063 }
int fetch_numeric_setting(struct settings *settings, const struct setting *setting, unsigned long *value, int is_signed)
Fetch value of numeric setting.
Definition: settings.c:1001
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23

References fetch_numeric_setting(), and value.

Referenced by net80211_step_associate(), reprioritise_settings(), and uriboot().

◆ fetch_uintz_setting()

unsigned long fetch_uintz_setting ( struct settings settings,
const struct setting setting 
)

Fetch value of unsigned integer setting, or zero.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
Return values
valueSetting value, or zero

Definition at line 1072 of file settings.c.

1073  {
1074  unsigned long value;
1075 
1077  return value;
1078 }
int fetch_numeric_setting(struct settings *settings, const struct setting *setting, unsigned long *value, int is_signed)
Fetch value of numeric setting.
Definition: settings.c:1001
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23

References fetch_numeric_setting(), and value.

Referenced by apply_netdev_settings(), have_pxe_menu(), oncrpc_init_cred_sys(), and start_pxebs().

◆ fetch_uuid_setting()

int fetch_uuid_setting ( struct settings settings,
const struct setting setting,
union uuid uuid 
)

Fetch value of UUID setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
uuidUUID to fill in
Return values
lenLength of setting, or negative error

Definition at line 1088 of file settings.c.

1090  {
1091  int len;
1092 
1093  len = fetch_raw_setting ( settings, setting, uuid, sizeof ( *uuid ) );
1094  if ( len < 0 )
1095  return len;
1096  if ( len != sizeof ( *uuid ) )
1097  return -ERANGE;
1098  return len;
1099 }
A universally unique ID.
Definition: uuid.h:15
int fetch_raw_setting(struct settings *settings, const struct setting *setting, void *data, size_t len)
Fetch value of setting.
Definition: settings.c:807
#define ERANGE
Result too large.
Definition: errno.h:639
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14

References ERANGE, fetch_raw_setting(), and len.

Referenced by dhcp_create_request(), iscsi_fetch_settings(), rbg_startup(), and start_dhcpv6().

◆ clear_settings()

void clear_settings ( struct settings settings)

Clear settings block.

Parameters
settingsSettings block

Definition at line 1106 of file settings.c.

1106  {
1107 
1108  /* Find target settings block */
1110 
1111  /* Clear settings, if applicable */
1112  if ( settings->op->clear )
1113  settings->op->clear ( settings );
1114 }
void(* clear)(struct settings *settings)
Clear settings block.
Definition: settings.h:128
struct settings_operations * op
Settings block operations.
Definition: settings.h:144
struct settings * settings_target(struct settings *settings)
Redirect to target settings block.
Definition: settings.c:552
A settings block.
Definition: settings.h:132

References settings_operations::clear, settings::op, and settings_target().

Referenced by free_netdev(), register_netdev(), settings_test_exec(), and unregister_netdev().

◆ setting_cmp()

int setting_cmp ( const struct setting a,
const struct setting b 
)

Compare two settings.

Parameters
aSetting to compare
bSetting to compare
Return values
0Settings are the same
non-zeroSettings are not the same

Definition at line 1124 of file settings.c.

1124  {
1125 
1126  /* If the settings have tags, compare them */
1127  if ( a->tag && ( a->tag == b->tag ) && ( a->scope == b->scope ) )
1128  return 0;
1129 
1130  /* Otherwise, if the settings have names, compare them */
1131  if ( a->name && b->name && a->name[0] )
1132  return strcmp ( a->name, b->name );
1133 
1134  /* Otherwise, return a non-match */
1135  return ( ! 0 );
1136 }
uint32_t a
Definition: md4.c:28
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:172
uint32_t b
Definition: md4.c:29

References a, b, and strcmp().

Referenced by applicable_setting(), builtin_fetch(), dhcpv6_applies(), dhcpv6_fetch(), efi_snp_hii_questions(), find_generic_setting(), ipv6_fetch(), ndp_prefix_fetch(), netdev_fetch(), netdev_store(), parse_setting_name(), phantom_clp_setting(), select_setting_row(), and store_setting().

◆ setting_format()

int setting_format ( const struct setting_type type,
const void *  raw,
size_t  raw_len,
char *  buf,
size_t  len 
)

Format setting value as a string.

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 1155 of file settings.c.

1156  {
1157 
1158  /* Sanity check */
1159  if ( ! type->format )
1160  return -ENOTSUP;
1161 
1162  return type->format ( type, raw, raw_len, buf, len );
1163 }
uint8_t type
Type.
Definition: ena.h:16
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
static size_t raw_len
Definition: base16.h:50
uint32_t len
Length.
Definition: ena.h:14
__be32 raw[7]
Definition: CIB_PRM.h:28

References ENOTSUP, len, raw, raw_len, and type.

Referenced by fetchf_setting().

◆ setting_parse()

int setting_parse ( const struct setting_type type,
const char *  value,
void *  buf,
size_t  len 
)

Parse formatted string to setting value.

Parameters
typeSetting type
valueFormatted setting value
bufBuffer to contain raw value
lenLength of buffer
Return values
lenLength of raw value, or negative error

Definition at line 1174 of file settings.c.

1175  {
1176 
1177  /* Sanity check */
1178  if ( ! type->parse )
1179  return -ENOTSUP;
1180 
1181  return type->parse ( type, value, buf, len );
1182 }
uint8_t type
Type.
Definition: ena.h:16
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
uint32_t len
Length.
Definition: ena.h:14

References ENOTSUP, len, type, and value.

Referenced by guestinfo_fetch_type(), and storef_setting().

◆ setting_numerate()

int setting_numerate ( const struct setting_type type,
const void *  raw,
size_t  raw_len,
unsigned long *  value 
)

Convert setting value to number.

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
Return values
valueNumeric value
rcReturn status code

Definition at line 1193 of file settings.c.

1194  {
1195 
1196  /* Sanity check */
1197  if ( ! type->numerate )
1198  return -ENOTSUP;
1199 
1200  return type->numerate ( type, raw, raw_len, value );
1201 }
uint8_t type
Type.
Definition: ena.h:16
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static size_t raw_len
Definition: base16.h:50
__be32 raw[7]
Definition: CIB_PRM.h:28

References ENOTSUP, raw, raw_len, type, and value.

Referenced by fetchn_setting().

◆ setting_denumerate()

int setting_denumerate ( const struct setting_type type,
unsigned long  value,
void *  buf,
size_t  len 
)

Convert number to setting value.

Parameters
typeSetting type
valueNumeric value
bufBuffer to contain raw value
lenLength of buffer
Return values
lenLength of raw value, or negative error

Definition at line 1212 of file settings.c.

1213  {
1214 
1215  /* Sanity check */
1216  if ( ! type->denumerate )
1217  return -ENOTSUP;
1218 
1219  return type->denumerate ( type, value, buf, len );
1220 }
uint8_t type
Type.
Definition: ena.h:16
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
uint32_t len
Length.
Definition: ena.h:14

References ENOTSUP, len, type, and value.

Referenced by storen_setting().

◆ fetchf_setting()

int fetchf_setting ( struct settings settings,
const struct setting setting,
struct settings **  origin,
struct setting fetched,
char *  buf,
size_t  len 
)

Fetch formatted value of setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
originOrigin of setting to fill in, or NULL
fetchedFetched setting to fill in, or NULL
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 1233 of file settings.c.

1235  {
1236  struct setting tmp_fetched;
1237  void *raw;
1238  int raw_len;
1239  int ret;
1240 
1241  /* Use local buffers if necessary */
1242  if ( ! fetched )
1243  fetched = &tmp_fetched;
1244 
1245  /* Fetch raw value */
1247  &raw );
1248  if ( raw_len < 0 ) {
1249  ret = raw_len;
1250  goto err_fetch_copy;
1251  }
1252 
1253  /* Sanity check */
1254  assert ( fetched->type != NULL );
1255 
1256  /* Format setting */
1257  if ( ( ret = setting_format ( fetched->type, raw, raw_len, buf,
1258  len ) ) < 0 )
1259  goto err_format;
1260 
1261  err_format:
1262  free ( raw );
1263  err_fetch_copy:
1264  return ret;
1265 }
uint64_t origin
Origin.
Definition: hyperv.h:20
int setting_format(const struct setting_type *type, const void *raw, size_t raw_len, char *buf, size_t len)
Format setting value as a string.
Definition: settings.c:1155
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
const struct setting_type * type
Setting type.
Definition: settings.h:36
static size_t raw_len
Definition: base16.h:50
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
A settings block.
Definition: settings.h:132
int fetch_setting_copy(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void **data)
Fetch copy of setting.
Definition: settings.c:789
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14
__be32 raw[7]
Definition: CIB_PRM.h:28
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References assert(), fetch_setting_copy(), free, len, NULL, origin, raw, raw_len, setting_format(), and setting::type.

Referenced by efi_snp_hii_fetch(), fetchf_setting_copy(), and select_setting_row().

◆ fetchf_setting_copy()

int fetchf_setting_copy ( struct settings settings,
const struct setting setting,
struct settings **  origin,
struct setting fetched,
char **  value 
)

Fetch copy of formatted value of setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
originOrigin of setting to fill in, or NULL
fetchedFetched setting to fill in, or NULL
valueBuffer to allocate and fill with formatted value
Return values
lenLength of formatted value, or negative error

The caller is responsible for eventually freeing the allocated buffer.

Definition at line 1280 of file settings.c.

1283  {
1284  struct settings *tmp_origin;
1285  struct setting tmp_fetched;
1286  int len;
1287  int check_len;
1288 
1289  /* Use local buffers if necessary */
1290  if ( ! origin )
1291  origin = &tmp_origin;
1292  if ( ! fetched )
1293  fetched = &tmp_fetched;
1294 
1295  /* Avoid returning uninitialised data on error */
1296  *value = NULL;
1297 
1298  /* Check existence, and fetch formatted value length */
1299  len = fetchf_setting ( settings, setting, origin, fetched, NULL, 0 );
1300  if ( len < 0 )
1301  return len;
1302 
1303  /* Allocate buffer */
1304  *value = zalloc ( len + 1 /* NUL */ );
1305  if ( ! *value )
1306  return -ENOMEM;
1307 
1308  /* Fetch formatted value */
1309  check_len = fetchf_setting ( *origin, fetched, NULL, NULL, *value,
1310  ( len + 1 /* NUL */ ) );
1311  assert ( check_len == len );
1312  return len;
1313 }
uint64_t origin
Origin.
Definition: hyperv.h:20
int fetchf_setting(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, char *buf, size_t len)
Fetch formatted value of setting.
Definition: settings.c:1233
#define ENOMEM
Not enough space.
Definition: errno.h:534
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References assert(), ENOMEM, fetchf_setting(), len, NULL, origin, value, and zalloc().

Referenced by expand_settings(), read_value(), and show_exec().

◆ storef_setting()

int storef_setting ( struct settings settings,
const struct setting setting,
const char *  value 
)

Store formatted value of setting.

Parameters
settingsSettings block
settingSetting to store
valueFormatted setting data, or NULL
Return values
rcReturn status code

Definition at line 1323 of file settings.c.

1324  {
1325  void *raw;
1326  int raw_len;
1327  int check_len;
1328  int rc;
1329 
1330  /* NULL value or empty string implies deletion */
1331  if ( ( ! value ) || ( ! value[0] ) )
1332  return delete_setting ( settings, setting );
1333 
1334  /* Sanity check */
1335  assert ( setting->type != NULL );
1336 
1337  /* Get raw value length */
1339  if ( raw_len < 0 ) {
1340  rc = raw_len;
1341  goto err_raw_len;
1342  }
1343 
1344  /* Allocate buffer for raw value */
1345  raw = malloc ( raw_len );
1346  if ( ! raw ) {
1347  rc = -ENOMEM;
1348  goto err_alloc_raw;
1349  }
1350 
1351  /* Parse formatted value */
1352  check_len = setting_parse ( setting->type, value, raw, raw_len );
1353  assert ( check_len == raw_len );
1354 
1355  /* Store raw value */
1356  if ( ( rc = store_setting ( settings, setting, raw, raw_len ) ) != 0 )
1357  goto err_store;
1358 
1359  err_store:
1360  free ( raw );
1361  err_alloc_raw:
1362  err_raw_len:
1363  return rc;
1364 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int delete_setting(struct settings *settings, const struct setting *setting)
Delete setting.
Definition: settings.h:526
int store_setting(struct settings *settings, const struct setting *setting, const void *data, size_t len)
Store value of setting.
Definition: settings.c:618
#define ENOMEM
Not enough space.
Definition: errno.h:534
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
const struct setting_type * type
Setting type.
Definition: settings.h:36
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static size_t raw_len
Definition: base16.h:50
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
A settings block.
Definition: settings.h:132
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:583
A setting.
Definition: settings.h:23
__be32 raw[7]
Definition: CIB_PRM.h:28
int setting_parse(const struct setting_type *type, const char *value, void *buf, size_t len)
Parse formatted string to setting value.
Definition: settings.c:1174
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References assert(), delete_setting(), ENOMEM, free, malloc(), NULL, raw, raw_len, rc, setting_parse(), store_setting(), setting::type, and value.

Referenced by choose_exec(), efi_snp_hii_store(), save_setting(), and set_core_exec().

◆ fetchn_setting()

int fetchn_setting ( struct settings settings,
const struct setting setting,
struct settings **  origin,
struct setting fetched,
unsigned long *  value 
)

Fetch numeric value of setting.

Parameters
settingsSettings block, or NULL to search all blocks
settingSetting to fetch
originOrigin of setting to fill in, or NULL
fetchedFetched setting to fill in, or NULL
valueNumeric value to fill in
Return values
rcReturn status code

Definition at line 1376 of file settings.c.

1378  {
1379  struct setting tmp_fetched;
1380  void *raw;
1381  int raw_len;
1382  int rc;
1383 
1384  /* Use local buffers if necessary */
1385  if ( ! fetched )
1386  fetched = &tmp_fetched;
1387 
1388  /* Fetch raw value */
1390  &raw );
1391  if ( raw_len < 0 ) {
1392  rc = raw_len;
1393  goto err_fetch_copy;
1394  }
1395 
1396  /* Sanity check */
1397  assert ( fetched->type != NULL );
1398 
1399  /* Numerate setting */
1400  if ( ( rc = setting_numerate ( fetched->type, raw, raw_len,
1401  value ) ) < 0 )
1402  goto err_numerate;
1403 
1404  err_numerate:
1405  free ( raw );
1406  err_fetch_copy:
1407  return rc;
1408 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint64_t origin
Origin.
Definition: hyperv.h:20
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
const struct setting_type * type
Setting type.
Definition: settings.h:36
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static size_t raw_len
Definition: base16.h:50
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
A settings block.
Definition: settings.h:132
int fetch_setting_copy(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void **data)
Fetch copy of setting.
Definition: settings.c:789
A setting.
Definition: settings.h:23
__be32 raw[7]
Definition: CIB_PRM.h:28
int setting_numerate(const struct setting_type *type, const void *raw, size_t raw_len, unsigned long *value)
Convert setting value to number.
Definition: settings.c:1193
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References assert(), fetch_setting_copy(), free, NULL, origin, raw, raw_len, rc, setting_numerate(), setting::type, and value.

Referenced by inc_exec(), and pciscan_exec().

◆ storen_setting()

int storen_setting ( struct settings settings,
const struct setting setting,
unsigned long  value 
)

Store numeric value of setting.

Parameters
settingsSettings block
settingSetting
valueNumeric value
Return values
rcReturn status code

Definition at line 1418 of file settings.c.

1419  {
1420  void *raw;
1421  int raw_len;
1422  int check_len;
1423  int rc;
1424 
1425  /* Sanity check */
1426  assert ( setting->type != NULL );
1427 
1428  /* Get raw value length */
1430  if ( raw_len < 0 ) {
1431  rc = raw_len;
1432  goto err_raw_len;
1433  }
1434 
1435  /* Allocate buffer for raw value */
1436  raw = malloc ( raw_len );
1437  if ( ! raw ) {
1438  rc = -ENOMEM;
1439  goto err_alloc_raw;
1440  }
1441 
1442  /* Denumerate value */
1443  check_len = setting_denumerate ( setting->type, value, raw, raw_len );
1444  assert ( check_len == raw_len );
1445 
1446  /* Store raw value */
1447  if ( ( rc = store_setting ( settings, setting, raw, raw_len ) ) != 0 )
1448  goto err_store;
1449 
1450  err_store:
1451  free ( raw );
1452  err_alloc_raw:
1453  err_raw_len:
1454  return rc;
1455 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int setting_denumerate(const struct setting_type *type, unsigned long value, void *buf, size_t len)
Convert number to setting value.
Definition: settings.c:1212
int store_setting(struct settings *settings, const struct setting *setting, const void *data, size_t len)
Store value of setting.
Definition: settings.c:618
#define ENOMEM
Not enough space.
Definition: errno.h:534
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
const struct setting_type * type
Setting type.
Definition: settings.h:36
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static size_t raw_len
Definition: base16.h:50
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
A settings block.
Definition: settings.h:132
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:583
A setting.
Definition: settings.h:23
__be32 raw[7]
Definition: CIB_PRM.h:28
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References assert(), ENOMEM, free, malloc(), NULL, raw, raw_len, rc, setting_denumerate(), store_setting(), setting::type, and value.

Referenced by inc_exec(), and pciscan_exec().

◆ find_setting()

struct setting* find_setting ( const char *  name)

Find predefined setting.

Parameters
nameName
Return values
settingSetting, or NULL

Definition at line 1470 of file settings.c.

1470  {
1471  struct setting *setting;
1472 
1474  if ( strcmp ( name, setting->name ) == 0 )
1475  return setting;
1476  }
1477  return NULL;
1478 }
const char * name
Definition: ath9k_hw.c:1984
const char * name
Name.
Definition: settings.h:28
#define SETTINGS
Configuration setting table.
Definition: settings.h:53
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
A setting.
Definition: settings.h:23
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:172
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References for_each_table_entry, setting::name, name, NULL, generic_setting::setting, SETTINGS, and strcmp().

Referenced by efi_snp_hii_fetch(), efi_snp_hii_store(), and guestinfo_fetch_type().

◆ parse_setting_tag()

static uint64_t parse_setting_tag ( const char *  name)
static

Parse setting name as tag number.

Parameters
nameName
Return values
tagTag number, or 0 if not a valid number

Definition at line 1486 of file settings.c.

1486  {
1487  char *tmp = ( ( char * ) name );
1488  uint64_t tag = 0;
1489 
1490  while ( 1 ) {
1491  tag = ( ( tag << 8 ) | strtoul ( tmp, &tmp, 0 ) );
1492  if ( *tmp == 0 )
1493  return tag;
1494  if ( *tmp != '.' )
1495  return 0;
1496  tmp++;
1497  }
1498 }
const char * name
Definition: ath9k_hw.c:1984
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
Definition: string.c:456
unsigned long long uint64_t
Definition: stdint.h:13
uint8_t * tmp
Definition: entropy.h:156
uint64_t tag
Identity tag.
Definition: edd.h:30

References name, strtoul(), tag, and tmp.

Referenced by parse_setting_name().

◆ find_setting_type()

static const struct setting_type* find_setting_type ( const char *  name)
static

Find setting type.

Parameters
nameName
Return values
typeSetting type, or NULL

Definition at line 1506 of file settings.c.

1506  {
1507  const struct setting_type *type;
1508 
1510  if ( strcmp ( name, type->name ) == 0 )
1511  return type;
1512  }
1513  return NULL;
1514 }
const char * name
Definition: ath9k_hw.c:1984
uint8_t type
Type.
Definition: ena.h:16
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:172
#define SETTING_TYPES
Configuration setting type table.
Definition: settings.h:242
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A setting type.
Definition: settings.h:191

References for_each_table_entry, name, NULL, SETTING_TYPES, strcmp(), and type.

Referenced by parse_setting_name().

◆ parse_setting_name()

int parse_setting_name ( char *  name,
get_child_settings_t  get_child,
struct settings **  settings,
struct setting setting 
)

Parse setting name.

Parameters
nameName of setting
get_childFunction to find or create child settings block
settingsSettings block to fill in
settingSetting to fill in
Return values
rcReturn status code

Interprets a name of the form "[settings_name/]tag_name[:type_name]" and fills in the appropriate fields.

Note that on success, this function will have modified the original setting name.

Definition at line 1532 of file settings.c.

1533  {
1534  char *settings_name;
1535  char *setting_name;
1536  char *type_name;
1537  struct setting *predefined;
1538  int rc;
1539 
1540  /* Set defaults */
1541  *settings = &settings_root;
1542  memset ( setting, 0, sizeof ( *setting ) );
1543  setting->name = "";
1544 
1545  /* Split name into "[settings_name/]setting_name[:type_name]" */
1546  if ( ( setting_name = strchr ( name, '/' ) ) != NULL ) {
1547  *(setting_name++) = 0;
1548  settings_name = name;
1549  } else {
1550  setting_name = name;
1551  settings_name = NULL;
1552  }
1553  if ( ( type_name = strchr ( setting_name, ':' ) ) != NULL )
1554  *(type_name++) = 0;
1555 
1556  /* Identify settings block, if specified */
1557  if ( settings_name ) {
1558  *settings = parse_settings_name ( settings_name, get_child );
1559  if ( *settings == NULL ) {
1560  DBG ( "Unrecognised settings block \"%s\" in \"%s\"\n",
1561  settings_name, name );
1562  rc = -ENODEV;
1563  goto err;
1564  }
1565  }
1566 
1567  /* Identify setting */
1569  setting->scope = (*settings)->default_scope;
1571  for_each_table_entry ( predefined, SETTINGS ) {
1572  /* Matches a predefined setting; use that setting */
1573  if ( setting_cmp ( predefined, setting ) == 0 ) {
1574  memcpy ( setting, predefined, sizeof ( *setting ) );
1575  break;
1576  }
1577  }
1578 
1579  /* Identify setting type, if specified */
1580  if ( type_name ) {
1581  setting->type = find_setting_type ( type_name );
1582  if ( setting->type == NULL ) {
1583  DBG ( "Invalid setting type \"%s\" in \"%s\"\n",
1584  type_name, name );
1585  rc = -ENOTSUP;
1586  goto err;
1587  }
1588  }
1589 
1590  return 0;
1591 
1592  err:
1593  /* Restore original name */
1594  if ( settings_name )
1595  *( setting_name - 1 ) = '/';
1596  if ( type_name )
1597  *( type_name - 1 ) = ':';
1598  return rc;
1599 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
static struct settings * parse_settings_name(const char *name, get_child_settings_t get_child)
Parse settings block name.
Definition: settings.c:371
const char * settings_name(struct settings *settings)
Return settings block name.
Definition: settings.c:345
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
const char * name
Name.
Definition: settings.h:28
#define SETTINGS
Configuration setting table.
Definition: settings.h:53
uint64_t tag
Setting tag, if applicable.
Definition: settings.h:43
void * memcpy(void *dest, const void *src, size_t len) __nonnull
const struct setting_type * type
Setting type.
Definition: settings.h:36
static uint64_t parse_setting_tag(const char *name)
Parse setting name as tag number.
Definition: settings.c:1486
char * strchr(const char *src, int character)
Find character within a string.
Definition: string.c:256
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
#define ENODEV
No such device.
Definition: errno.h:509
A settings block.
Definition: settings.h:132
#define settings_root
Root settings block.
Definition: settings.c:249
static const struct setting_type * find_setting_type(const char *name)
Find setting type.
Definition: settings.c:1506
A setting.
Definition: settings.h:23
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
const struct settings_scope * scope
Setting scope (or NULL)
Definition: settings.h:49
int setting_name(struct settings *settings, const struct setting *setting, char *buf, size_t len)
Return full setting name.
Definition: settings.c:1610
int setting_cmp(const struct setting *a, const struct setting *b)
Compare two settings.
Definition: settings.c:1124
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
void * memset(void *dest, int character, size_t len) __nonnull

References DBG, ENODEV, ENOTSUP, find_setting_type(), for_each_table_entry, memcpy(), memset(), setting::name, name, NULL, parse_setting_tag(), parse_settings_name(), rc, setting::scope, setting_cmp(), setting_name(), SETTINGS, settings_name(), settings_root, strchr(), setting::tag, and setting::type.

Referenced by expand_settings(), nslookup_resolv_done(), and parse_setting().

◆ setting_name()

int setting_name ( struct settings settings,
const struct setting setting,
char *  buf,
size_t  len 
)

Return full setting name.

Parameters
settingsSettings block, or NULL
settingSetting
bufBuffer
lenLength of buffer
Return values
lenLength of setting name, or negative error

Definition at line 1610 of file settings.c.

1611  {
1612  const char *name;
1613 
1615  name = settings_name ( settings );
1616  return snprintf ( buf, len, "%s%s%s:%s", name, ( name[0] ? "/" : "" ),
1617  setting->name, setting->type->name );
1618 }
const char * name
Definition: ath9k_hw.c:1984
const char * settings_name(struct settings *settings)
Return settings block name.
Definition: settings.c:345
const char * name
Name.
Definition: settings.h:28
struct settings * settings_target(struct settings *settings)
Redirect to target settings block.
Definition: settings.c:552
const struct setting_type * type
Setting type.
Definition: settings.h:36
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14
const char * name
Name.
Definition: settings.h:196
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382

References len, setting::name, setting_type::name, name, settings_name(), settings_target(), snprintf(), and setting::type.

Referenced by draw_info_row(), nslookup(), nslookup_exec(), parse_setting_name(), resolv_setting(), and show_exec().

◆ parse_string_setting()

static int parse_string_setting ( const struct setting_type *type  __unused,
const char *  value,
void *  buf,
size_t  len 
)
static

Parse string setting value.

Parameters
typeSetting type
valueFormatted setting value
bufBuffer to contain raw value
lenLength of buffer
Return values
lenLength of raw value, or negative error

Definition at line 1636 of file settings.c.

1637  {
1638  size_t raw_len = strlen ( value ); /* Exclude terminating NUL */
1639 
1640  /* Copy string to buffer */
1641  if ( len > raw_len )
1642  len = raw_len;
1643  memcpy ( buf, value, len );
1644 
1645  return raw_len;
1646 }
void * memcpy(void *dest, const void *src, size_t len) __nonnull
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static size_t raw_len
Definition: base16.h:50
size_t strlen(const char *src)
Get length of string.
Definition: string.c:228
uint32_t len
Length.
Definition: ena.h:14

References len, memcpy(), raw_len, strlen(), and value.

◆ format_string_setting()

static int format_string_setting ( const struct setting_type *type  __unused,
const void *  raw,
size_t  raw_len,
char *  buf,
size_t  len 
)
static

Format string setting value.

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 1658 of file settings.c.

1660  {
1661 
1662  /* Copy string to buffer, and terminate */
1663  memset ( buf, 0, len );
1664  if ( len > raw_len )
1665  len = raw_len;
1666  memcpy ( buf, raw, len );
1667 
1668  return raw_len;
1669 }
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static size_t raw_len
Definition: base16.h:50
uint32_t len
Length.
Definition: ena.h:14
__be32 raw[7]
Definition: CIB_PRM.h:28
void * memset(void *dest, int character, size_t len) __nonnull

References len, memcpy(), memset(), raw, and raw_len.

◆ parse_uristring_setting()

static int parse_uristring_setting ( const struct setting_type *type  __unused,
const char *  value,
void *  buf,
size_t  len 
)
static

Parse URI-encoded string setting value.

Parameters
typeSetting type
valueFormatted setting value
bufBuffer to contain raw value
lenLength of buffer
Return values
lenLength of raw value, or negative error

Definition at line 1687 of file settings.c.

1688  {
1689 
1690  return uri_decode ( value, buf, len );
1691 }
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
size_t uri_decode(const char *encoded, void *buf, size_t len)
Decode URI field.
Definition: uri.c:53
uint32_t len
Length.
Definition: ena.h:14

References len, uri_decode(), and value.

◆ format_uristring_setting()

static int format_uristring_setting ( const struct setting_type *type  __unused,
const void *  raw,
size_t  raw_len,
char *  buf,
size_t  len 
)
static

Format URI-encoded string setting value.

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 1703 of file settings.c.

1705  {
1706 
1707  return uri_encode ( 0, raw, raw_len, buf, len );
1708 }
size_t uri_encode(unsigned int field, const void *raw, size_t raw_len, char *buf, ssize_t len)
Encode URI field.
Definition: uri.c:201
static size_t raw_len
Definition: base16.h:50
uint32_t len
Length.
Definition: ena.h:14
__be32 raw[7]
Definition: CIB_PRM.h:28

References len, raw, raw_len, and uri_encode().

◆ parse_ipv4_setting()

__weak int parse_ipv4_setting ( const struct setting_type *type  __unused,
const char *value  __unused,
void *buf  __unused,
size_t len  __unused 
)

Parse IPv4 address setting value (when IPv4 support is not present)

Parameters
typeSetting type
valueFormatted setting value
bufBuffer to contain raw value
lenLength of buffer
Return values
lenLength of raw value, or negative error

Definition at line 1726 of file settings.c.

1728  {
1729  return -ENOTSUP;
1730 }
#define ENOTSUP
Operation not supported.
Definition: errno.h:589

References ENOTSUP.

◆ format_ipv4_setting()

__weak int format_ipv4_setting ( const struct setting_type *type  __unused,
const void *raw  __unused,
size_t raw_len  __unused,
char *buf  __unused,
size_t len  __unused 
)

Format IPv4 address setting value (when IPv4 support is not present)

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 1742 of file settings.c.

1745  {
1746  return -ENOTSUP;
1747 }
#define ENOTSUP
Operation not supported.
Definition: errno.h:589

References ENOTSUP.

◆ parse_ipv6_setting()

__weak int parse_ipv6_setting ( const struct setting_type *type  __unused,
const char *value  __unused,
void *buf  __unused,
size_t len  __unused 
)

Parse IPv6 address setting value (when IPv6 support is not present)

Parameters
typeSetting type
valueFormatted setting value
bufBuffer to contain raw value
lenLength of buffer
Return values
lenLength of raw value, or negative error

Definition at line 1765 of file settings.c.

1767  {
1768  return -ENOTSUP;
1769 }
#define ENOTSUP
Operation not supported.
Definition: errno.h:589

References ENOTSUP.

◆ format_ipv6_setting()

__weak int format_ipv6_setting ( const struct setting_type *type  __unused,
const void *raw  __unused,
size_t raw_len  __unused,
char *buf  __unused,
size_t len  __unused 
)

Format IPv6 address setting value (when IPv6 support is not present)

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 1781 of file settings.c.

1784  {
1785  return -ENOTSUP;
1786 }
#define ENOTSUP
Operation not supported.
Definition: errno.h:589

References ENOTSUP.

◆ setting_type_int_index()

static unsigned int setting_type_int_index ( const struct setting_type type)
static

Get integer setting type index.

Parameters
typeSetting type
Return values
indexInteger setting type index

Definition at line 1847 of file settings.c.

1847  {
1848 
1849  return ( ( type->name - setting_type_int_name[0] ) /
1850  sizeof ( setting_type_int_name[0] ) );
1851 }
uint8_t type
Type.
Definition: ena.h:16
static const char setting_type_int_name[][8]
Integer setting type names.
Definition: settings.c:1819

References setting_type_int_name, and type.

◆ setting_type_int_width()

static unsigned int setting_type_int_width ( const struct setting_type type)
static

Get integer setting type width.

Parameters
typeSetting type
Return values
indexInteger setting type width

Definition at line 1859 of file settings.c.

1859  {
1860 
1861  return ( 1 << setting_type_int_index ( type ) );
1862 }
uint8_t type
Type.
Definition: ena.h:16
setting_type_int_index
Integer setting type indices.
Definition: settings.c:1804

References type.

Referenced by denumerate_int_setting().

◆ setting_type_int_is_signed()

static int setting_type_int_is_signed ( const struct setting_type type)
static

Get integer setting type signedness.

Parameters
typeSetting type
Return values
is_signedInteger setting type is signed

Definition at line 1870 of file settings.c.

1870  {
1871  return ( ( type->name - setting_type_int_name[0] ) & 1 );
1872 }
uint8_t type
Type.
Definition: ena.h:16
static const char setting_type_int_name[][8]
Integer setting type names.
Definition: settings.c:1819

References setting_type_int_name, and type.

Referenced by numerate_int_setting().

◆ denumerate_int_setting()

static int denumerate_int_setting ( const struct setting_type type,
unsigned long  value,
void *  buf,
size_t  len 
)
static

Convert number to setting value.

Parameters
typeSetting type
valueNumeric value
bufBuffer to contain raw value
lenLength of buffer
Return values
lenLength of raw value, or negative error

Definition at line 1883 of file settings.c.

1885  {
1886  unsigned int size = setting_type_int_width ( type );
1887  union {
1888  uint32_t num;
1889  uint8_t bytes[4];
1890  } u;
1891 
1892  u.num = htonl ( value );
1893  if ( len > size )
1894  len = size;
1895  memcpy ( buf, &u.bytes[ sizeof ( u ) - size ], len );
1896 
1897  return size;
1898 }
uint8_t type
Type.
Definition: ena.h:16
#define htonl(value)
Definition: byteswap.h:133
void * memcpy(void *dest, const void *src, size_t len) __nonnull
char unsigned long * num
Definition: xenstore.h:17
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
unsigned char uint8_t
Definition: stdint.h:10
unsigned int uint32_t
Definition: stdint.h:12
uint32_t len
Length.
Definition: ena.h:14
union @17 u
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
static unsigned int setting_type_int_width(const struct setting_type *type)
Get integer setting type width.
Definition: settings.c:1859
uint8_t bytes[64]
Definition: ib_mad.h:16

References bytes, htonl, len, memcpy(), num, setting_type_int_width(), size, type, u, and value.

◆ numerate_int_setting()

static int numerate_int_setting ( const struct setting_type type,
const void *  raw,
size_t  raw_len,
unsigned long *  value 
)
static

Convert setting value to number.

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
valueNumeric value to fill in
Return values
rcReturn status code

Definition at line 1909 of file settings.c.

1911  {
1912  int is_signed = setting_type_int_is_signed ( type );
1913  int check_len;
1914 
1915  /* Extract numeric value */
1916  check_len = numeric_setting_value ( is_signed, raw, raw_len, value );
1917  if ( check_len < 0 )
1918  return check_len;
1919  assert ( check_len == ( int ) raw_len );
1920 
1921  return 0;
1922 }
uint8_t type
Type.
Definition: ena.h:16
static int numeric_setting_value(int is_signed, const void *raw, size_t len, unsigned long *value)
Extract numeric value of setting.
Definition: settings.c:970
static int setting_type_int_is_signed(const struct setting_type *type)
Get integer setting type signedness.
Definition: settings.c:1870
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static size_t raw_len
Definition: base16.h:50
__be32 raw[7]
Definition: CIB_PRM.h:28

References assert(), numeric_setting_value(), raw, raw_len, setting_type_int_is_signed(), type, and value.

◆ parse_int_setting()

static int parse_int_setting ( const struct setting_type type,
const char *  value,
void *  buf,
size_t  len 
)
static

Parse integer setting value.

Parameters
typeSetting type
valueFormatted setting value
bufBuffer to contain raw value
lenLength of buffer
Return values
lenLength of raw value, or negative error

Definition at line 1933 of file settings.c.

1934  {
1935  char *endp;
1936  unsigned long num_value;
1937 
1938  /* Parse value */
1939  num_value = strtoul ( value, &endp, 0 );
1940  if ( *endp )
1941  return -EINVAL;
1942 
1943  return type->denumerate ( type, num_value, buf, len );
1944 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
Definition: string.c:456
uint8_t type
Type.
Definition: ena.h:16
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
uint32_t len
Length.
Definition: ena.h:14

References EINVAL, len, strtoul(), type, and value.

◆ format_int_setting()

static int format_int_setting ( const struct setting_type type,
const void *  raw,
size_t  raw_len,
char *  buf,
size_t  len 
)
static

Format signed integer setting value.

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 1956 of file settings.c.

1958  {
1959  unsigned long value;
1960  int ret;
1961 
1962  /* Extract numeric value */
1963  if ( ( ret = type->numerate ( type, raw, raw_len, &value ) ) < 0 )
1964  return ret;
1965 
1966  /* Format value */
1967  return snprintf ( buf, len, "%ld", value );
1968 }
uint8_t type
Type.
Definition: ena.h:16
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static size_t raw_len
Definition: base16.h:50
uint32_t len
Length.
Definition: ena.h:14
__be32 raw[7]
Definition: CIB_PRM.h:28
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382

References len, raw, raw_len, snprintf(), type, and value.

◆ format_uint_setting()

static int format_uint_setting ( const struct setting_type type,
const void *  raw,
size_t  raw_len,
char *  buf,
size_t  len 
)
static

Format unsigned integer setting value.

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 1980 of file settings.c.

1982  {
1983  unsigned long value;
1984  int ret;
1985 
1986  /* Extract numeric value */
1987  if ( ( ret = type->numerate ( type, raw, raw_len, &value ) ) < 0 )
1988  return ret;
1989 
1990  /* Format value */
1991  return snprintf ( buf, len, "%#lx", value );
1992 }
uint8_t type
Type.
Definition: ena.h:16
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static size_t raw_len
Definition: base16.h:50
uint32_t len
Length.
Definition: ena.h:14
__be32 raw[7]
Definition: CIB_PRM.h:28
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382

References len, raw, raw_len, snprintf(), type, and value.

◆ parse_hex_setting()

static int parse_hex_setting ( const struct setting_type *type  __unused,
const char *  value,
void *  buf,
size_t  len 
)
static

Parse hex string setting value (using colon delimiter)

Parameters
typeSetting type
valueFormatted setting value
bufBuffer to contain raw value
lenLength of buffer
sizeInteger size, in bytes
Return values
lenLength of raw value, or negative error

Definition at line 2056 of file settings.c.

2057  {
2058  return hex_decode ( ':', value, buf, len );
2059 }
int hex_decode(char separator, const char *encoded, void *data, size_t len)
Decode hexadecimal string (with optional byte separator character)
Definition: base16.c:76
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
uint32_t len
Length.
Definition: ena.h:14

References hex_decode(), len, and value.

◆ format_hex_colon_setting()

static int format_hex_colon_setting ( const struct setting_type *type  __unused,
const void *  raw,
size_t  raw_len,
char *  buf,
size_t  len 
)
static

Format hex string setting value (using colon delimiter)

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 2071 of file settings.c.

2073  {
2074  return hex_encode ( ':', raw, raw_len, buf, len );
2075 }
static size_t raw_len
Definition: base16.h:50
size_t hex_encode(char separator, const void *raw, size_t raw_len, char *data, size_t len)
Encode hexadecimal string (with optional byte separator character)
Definition: base16.c:50
uint32_t len
Length.
Definition: ena.h:14
__be32 raw[7]
Definition: CIB_PRM.h:28

References hex_encode(), len, raw, and raw_len.

◆ parse_hex_hyphen_setting()

static int parse_hex_hyphen_setting ( const struct setting_type *type  __unused,
const char *  value,
void *  buf,
size_t  len 
)
static

Parse hex string setting value (using hyphen delimiter)

Parameters
typeSetting type
valueFormatted setting value
bufBuffer to contain raw value
lenLength of buffer
sizeInteger size, in bytes
Return values
lenLength of raw value, or negative error

Definition at line 2087 of file settings.c.

2089  {
2090  return hex_decode ( '-', value, buf, len );
2091 }
int hex_decode(char separator, const char *encoded, void *data, size_t len)
Decode hexadecimal string (with optional byte separator character)
Definition: base16.c:76
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
uint32_t len
Length.
Definition: ena.h:14

References hex_decode(), len, and value.

◆ format_hex_hyphen_setting()

static int format_hex_hyphen_setting ( const struct setting_type *type  __unused,
const void *  raw,
size_t  raw_len,
char *  buf,
size_t  len 
)
static

Format hex string setting value (using hyphen delimiter)

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 2103 of file settings.c.

2105  {
2106  return hex_encode ( '-', raw, raw_len, buf, len );
2107 }
static size_t raw_len
Definition: base16.h:50
size_t hex_encode(char separator, const void *raw, size_t raw_len, char *data, size_t len)
Encode hexadecimal string (with optional byte separator character)
Definition: base16.c:50
uint32_t len
Length.
Definition: ena.h:14
__be32 raw[7]
Definition: CIB_PRM.h:28

References hex_encode(), len, raw, and raw_len.

◆ parse_hex_raw_setting()

static int parse_hex_raw_setting ( const struct setting_type *type  __unused,
const char *  value,
void *  buf,
size_t  len 
)
static

Parse hex string setting value (using no delimiter)

Parameters
typeSetting type
valueFormatted setting value
bufBuffer to contain raw value
lenLength of buffer
sizeInteger size, in bytes
Return values
lenLength of raw value, or negative error

Definition at line 2119 of file settings.c.

2120  {
2121  return hex_decode ( 0, value, buf, len );
2122 }
int hex_decode(char separator, const char *encoded, void *data, size_t len)
Decode hexadecimal string (with optional byte separator character)
Definition: base16.c:76
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
uint32_t len
Length.
Definition: ena.h:14

References hex_decode(), len, and value.

◆ format_hex_raw_setting()

static int format_hex_raw_setting ( const struct setting_type *type  __unused,
const void *  raw,
size_t  raw_len,
char *  buf,
size_t  len 
)
static

Format hex string setting value (using no delimiter)

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 2134 of file settings.c.

2136  {
2137  return hex_encode ( 0, raw, raw_len, buf, len );
2138 }
static size_t raw_len
Definition: base16.h:50
size_t hex_encode(char separator, const void *raw, size_t raw_len, char *data, size_t len)
Encode hexadecimal string (with optional byte separator character)
Definition: base16.c:50
uint32_t len
Length.
Definition: ena.h:14
__be32 raw[7]
Definition: CIB_PRM.h:28

References hex_encode(), len, raw, and raw_len.

◆ parse_base64_setting()

static int parse_base64_setting ( const struct setting_type *type  __unused,
const char *  value,
void *  buf,
size_t  len 
)
static

Parse Base64-encoded setting value.

Parameters
typeSetting type
valueFormatted setting value
bufBuffer to contain raw value
lenLength of buffer
sizeInteger size, in bytes
Return values
lenLength of raw value, or negative error

Definition at line 2171 of file settings.c.

2172  {
2173 
2174  return base64_decode ( value, buf, len );
2175 }
int base64_decode(const char *encoded, void *data, size_t len)
Base64-decode string.
Definition: base64.c:91
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
uint32_t len
Length.
Definition: ena.h:14

References base64_decode(), len, and value.

◆ format_base64_setting()

static int format_base64_setting ( const struct setting_type *type  __unused,
const void *  raw,
size_t  raw_len,
char *  buf,
size_t  len 
)
static

Format Base64-encoded setting value.

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 2187 of file settings.c.

2189  {
2190 
2191  return base64_encode ( raw, raw_len, buf, len );
2192 }
static size_t raw_len
Definition: base16.h:50
uint32_t len
Length.
Definition: ena.h:14
__be32 raw[7]
Definition: CIB_PRM.h:28
size_t base64_encode(const void *raw, size_t raw_len, char *data, size_t len)
Base64-encode data.
Definition: base64.c:51

References base64_encode(), len, raw, and raw_len.

◆ format_uuid_setting()

static int format_uuid_setting ( const struct setting_type *type  __unused,
const void *  raw,
size_t  raw_len,
char *  buf,
size_t  len 
)
static

Format UUID setting value.

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 2211 of file settings.c.

2213  {
2214  const union uuid *uuid = raw;
2215 
2216  /* Range check */
2217  if ( raw_len != sizeof ( *uuid ) )
2218  return -ERANGE;
2219 
2220  /* Format value */
2221  return snprintf ( buf, len, "%s", uuid_ntoa ( uuid ) );
2222 }
A universally unique ID.
Definition: uuid.h:15
static size_t raw_len
Definition: base16.h:50
#define ERANGE
Result too large.
Definition: errno.h:639
const char * uuid_ntoa(const union uuid *uuid)
Convert UUID to printable string.
Definition: uuid.c:43
uint32_t len
Length.
Definition: ena.h:14
__be32 raw[7]
Definition: CIB_PRM.h:28
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382

References ERANGE, len, raw, raw_len, snprintf(), and uuid_ntoa().

◆ format_busdevfn_setting()

static int format_busdevfn_setting ( const struct setting_type *type  __unused,
const void *  raw,
size_t  raw_len,
char *  buf,
size_t  len 
)
static

Format PCI bus:dev.fn setting value.

Parameters
typeSetting type
rawRaw setting value
raw_lenLength of raw setting value
bufBuffer to contain formatted value
lenLength of buffer
Return values
lenLength of formatted value, or negative error

Definition at line 2240 of file settings.c.

2242  {
2243  unsigned long busdevfn;
2244  unsigned int seg;
2245  unsigned int bus;
2246  unsigned int slot;
2247  unsigned int func;
2248  int check_len;
2249 
2250  /* Extract numeric value */
2251  check_len = numeric_setting_value ( 0, raw, raw_len, &busdevfn );
2252  if ( check_len < 0 )
2253  return check_len;
2254  assert ( check_len == ( int ) raw_len );
2255 
2256  /* Extract PCI address components */
2257  seg = PCI_SEG ( busdevfn );
2258  bus = PCI_BUS ( busdevfn );
2259  slot = PCI_SLOT ( busdevfn );
2260  func = PCI_FUNC ( busdevfn );
2261 
2262  /* Format value */
2263  return snprintf ( buf, len, "%04x:%02x:%02x.%x", seg, bus, slot, func );
2264 }
#define PCI_FUNC(busdevfn)
Definition: pci.h:258
#define PCI_BUS(busdevfn)
Definition: pci.h:256
static int numeric_setting_value(int is_signed, const void *raw, size_t len, unsigned long *value)
Extract numeric value of setting.
Definition: settings.c:970
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
static size_t raw_len
Definition: base16.h:50
#define PCI_SLOT(busdevfn)
Definition: pci.h:257
uint8_t slot
Slot.
Definition: edd.h:16
uint32_t len
Length.
Definition: ena.h:14
__be32 raw[7]
Definition: CIB_PRM.h:28
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
struct golan_mkey_seg seg
Definition: CIB_PRM.h:28
#define PCI_SEG(busdevfn)
Definition: pci.h:255
uint8_t bus
Bus.
Definition: edd.h:14

References assert(), bus, len, numeric_setting_value(), PCI_BUS, PCI_FUNC, PCI_SEG, PCI_SLOT, raw, raw_len, seg, slot, and snprintf().

◆ expand_settings()

char* expand_settings ( const char *  string)

Expand variables within string.

Parameters
stringString
Return values
expstrExpanded string

The expanded string is allocated with malloc() and the caller must eventually free() it.

Definition at line 2288 of file settings.c.

2288  {
2289  struct settings *settings;
2290  struct setting setting;
2291  char *expstr;
2292  char *start;
2293  char *end;
2294  char *head;
2295  char *name;
2296  char *tail;
2297  char *value;
2298  char *tmp;
2299  int new_len;
2300  int rc;
2301 
2302  /* Obtain temporary modifiable copy of string */
2303  expstr = strdup ( string );
2304  if ( ! expstr )
2305  return NULL;
2306 
2307  /* Expand while expansions remain */
2308  while ( 1 ) {
2309 
2310  head = expstr;
2311 
2312  /* Locate setting to be expanded */
2313  start = NULL;
2314  end = NULL;
2315  for ( tmp = expstr ; *tmp ; tmp++ ) {
2316  if ( ( tmp[0] == '$' ) && ( tmp[1] == '{' ) )
2317  start = tmp;
2318  if ( start && ( tmp[0] == '}' ) ) {
2319  end = tmp;
2320  break;
2321  }
2322  }
2323  if ( ! end )
2324  break;
2325  *start = '\0';
2326  name = ( start + 2 );
2327  *end = '\0';
2328  tail = ( end + 1 );
2329 
2330  /* Expand setting */
2332  &settings,
2333  &setting ) ) != 0 ) {
2334  /* Treat invalid setting names as empty */
2335  value = NULL;
2336  } else {
2337  /* Fetch and format setting value. Ignore
2338  * errors; treat non-existent settings as empty.
2339  */
2341  &value );
2342  }
2343 
2344  /* Construct expanded string and discard old string */
2345  tmp = expstr;
2346  new_len = asprintf ( &expstr, "%s%s%s",
2347  head, ( value ? value : "" ), tail );
2348  free ( value );
2349  free ( tmp );
2350  if ( new_len < 0 )
2351  return NULL;
2352  }
2353 
2354  return expstr;
2355 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
int fetchf_setting_copy(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, char **value)
Fetch copy of formatted value of setting.
Definition: settings.c:1280
uint8_t head
Head number.
Definition: int13.h:34
uint32_t start
Starting offset.
Definition: netvsc.h:12
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
int asprintf(char **strp, const char *fmt,...)
Write a formatted string to newly allocated memory.
Definition: asprintf.c:41
uint8_t * tmp
Definition: entropy.h:156
char * strdup(const char *src)
Duplicate string.
Definition: string.c:365
A settings block.
Definition: settings.h:132
A setting.
Definition: settings.h:23
uint32_t end
Ending offset.
Definition: netvsc.h:18
struct settings * find_child_settings(struct settings *parent, const char *name)
Find child settings block.
Definition: settings.c:279
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
int parse_setting_name(char *name, get_child_settings_t get_child, struct settings **settings, struct setting *setting)
Parse setting name.
Definition: settings.c:1532

References asprintf(), end, fetchf_setting_copy(), find_child_settings(), free, head, name, NULL, parse_setting_name(), rc, generic_setting::setting, start, strdup(), tmp, and value.

Referenced by expand_tokens(), fetch_next_server_and_filename(), fetch_root_path(), and fetch_san_filename().

◆ __setting() [1/16]

const struct setting hostname_setting __setting ( SETTING_HOST  ,
hostname   
)

Hostname setting.

◆ __setting() [2/16]

const struct setting domain_setting __setting ( SETTING_IP_EXTRA  ,
domain   
)

Domain name setting.

◆ __setting() [3/16]

const struct setting next_server_setting __setting ( SETTING_BOOT  ,
next server 
)

TFTP server setting.

◆ __setting() [4/16]

const struct setting filename_setting __setting ( SETTING_BOOT  ,
filename   
)

Filename setting.

◆ __setting() [5/16]

const struct setting root_path_setting __setting ( SETTING_SANBOOT  ,
root path 
)

Root path setting.

◆ __setting() [6/16]

const struct setting san_filename_setting __setting ( SETTING_SANBOOT  ,
san-  filename 
)

SAN filename setting.

◆ __setting() [7/16]

const struct setting username_setting __setting ( SETTING_AUTH  ,
username   
)

Username setting.

◆ __setting() [8/16]

const struct setting password_setting __setting ( SETTING_AUTH  ,
password   
)

Password setting.

◆ __setting() [9/16]

const struct setting priority_setting __setting ( SETTING_MISC  ,
priority   
)

Priority setting.

◆ __setting() [10/16]

const struct setting user_class_setting __setting ( SETTING_HOST_EXTRA  ,
user class 
)

DHCP user class setting.

◆ __setting() [11/16]

const struct setting vendor_class_setting __setting ( SETTING_HOST_EXTRA  ,
vendor class 
)

DHCP vendor class setting.

◆ errno_fetch()

static int errno_fetch ( void *  data,
size_t  len 
)
static

Fetch error number setting.

Parameters
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 2472 of file settings.c.

2472  {
2473  uint32_t content;
2474 
2475  /* Return current error */
2476  content = htonl ( errno );
2477  if ( len > sizeof ( content ) )
2478  len = sizeof ( content );
2479  memcpy ( data, &content, len );
2480  return sizeof ( content );
2481 }
#define htonl(value)
Definition: byteswap.h:133
void * memcpy(void *dest, const void *src, size_t len) __nonnull
int errno
Global "last error" number.
Definition: errno.c:20
unsigned int uint32_t
Definition: stdint.h:12
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References data, errno, htonl, len, and memcpy().

◆ __setting() [12/16]

const struct setting errno_setting __setting ( SETTING_MISC  ,
errno   
)

Error number setting.

◆ buildarch_fetch()

static int buildarch_fetch ( void *  data,
size_t  len 
)
static

Fetch build architecture setting.

Parameters
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 2504 of file settings.c.

2504  {
2505  static const char buildarch[] = _S2 ( ARCH );
2506 
2507  strncpy ( data, buildarch, len );
2508  return ( sizeof ( buildarch ) - 1 /* NUL */ );
2509 }
#define _S2(x)
Stringify expanded argument.
Definition: compiler.h:53
char * strncpy(char *dest, const char *src, size_t max)
Copy string.
Definition: string.c:332
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References _S2, data, len, and strncpy().

◆ __setting() [13/16]

const struct setting buildarch_setting __setting ( SETTING_MISC  ,
buildarch   
)

Build architecture setting.

◆ platform_fetch()

static int platform_fetch ( void *  data,
size_t  len 
)
static

Fetch platform setting.

Parameters
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 2532 of file settings.c.

2532  {
2533  static const char platform[] = _S2 ( PLATFORM );
2534 
2535  strncpy ( data, platform, len );
2536  return ( sizeof ( platform ) - 1 /* NUL */ );
2537 }
#define _S2(x)
Stringify expanded argument.
Definition: compiler.h:53
char * strncpy(char *dest, const char *src, size_t max)
Copy string.
Definition: string.c:332
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References _S2, data, len, and strncpy().

◆ __setting() [14/16]

const struct setting platform_setting __setting ( SETTING_MISC  ,
platform   
)

Platform setting.

◆ version_fetch()

static int version_fetch ( void *  data,
size_t  len 
)
static

Fetch version setting.

Parameters
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 2560 of file settings.c.

2560  {
2562  return ( strlen ( product_version ) );
2563 }
char * strncpy(char *dest, const char *src, size_t max)
Copy string.
Definition: string.c:332
size_t strlen(const char *src)
Get length of string.
Definition: string.c:228
const char product_version[]
Product version string.
Definition: version.c:69
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12

References data, len, product_version, strlen(), and strncpy().

◆ __setting() [15/16]

const struct setting version_setting __setting ( SETTING_MISC  ,
version   
)

Version setting.

◆ unixtime_fetch()

static int unixtime_fetch ( void *  data,
size_t  len 
)
static

Fetch current time setting.

Parameters
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 2586 of file settings.c.

2586  {
2587  uint32_t content;
2588 
2589  /* Return current time */
2590  content = htonl ( time(NULL) );
2591  if ( len > sizeof ( content ) )
2592  len = sizeof ( content );
2593  memcpy ( data, &content, len );
2594  return sizeof ( content );
2595 }
#define htonl(value)
Definition: byteswap.h:133
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned int uint32_t
Definition: stdint.h:12
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
uint64_t time
Current time.
Definition: ntlm.h:20
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References data, htonl, len, memcpy(), NULL, and time.

◆ __setting() [16/16]

const struct setting unixtime_setting __setting ( SETTING_MISC  ,
unixtime   
)

Current time setting.

◆ builtin_fetch()

static int builtin_fetch ( struct settings *settings  __unused,
struct setting setting,
void *  data,
size_t  len 
)
static

Fetch built-in setting.

Parameters
settingsSettings block
settingSetting to fetch
dataBuffer to fill with setting data
lenLength of buffer
Return values
lenLength of setting data, or negative error

Definition at line 2620 of file settings.c.

2622  {
2623  struct builtin_setting *builtin;
2624 
2625  for_each_table_entry ( builtin, BUILTIN_SETTINGS ) {
2626  if ( setting_cmp ( setting, builtin->setting ) == 0 )
2627  return builtin->fetch ( data, len );
2628  }
2629  return -ENOENT;
2630 }
#define ENOENT
No such file or directory.
Definition: errno.h:514
int(* fetch)(void *data, size_t len)
Fetch setting value.
Definition: settings.h:276
const struct setting * setting
Setting.
Definition: settings.h:269
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
A built-in setting.
Definition: settings.h:267
A setting.
Definition: settings.h:23
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
int setting_cmp(const struct setting *a, const struct setting *b)
Compare two settings.
Definition: settings.c:1124
#define BUILTIN_SETTINGS
Built-in settings table.
Definition: settings.h:280

References BUILTIN_SETTINGS, data, ENOENT, builtin_setting::fetch, for_each_table_entry, len, builtin_setting::setting, and setting_cmp().

◆ builtin_applies()

static int builtin_applies ( struct settings *settings  __unused,
const struct setting setting 
)
static

Check applicability of built-in setting.

Parameters
settingsSettings block
settingSetting
Return values
appliesSetting applies within this settings block

Definition at line 2639 of file settings.c.

2640  {
2641 
2642  return ( setting->scope == &builtin_scope );
2643 }
A setting.
Definition: settings.h:23
const struct settings_scope builtin_scope
Built-in setting scope.
Definition: settings.c:2463
const struct settings_scope * scope
Setting scope (or NULL)
Definition: settings.h:49

References builtin_scope, and setting::scope.

◆ builtin_init()

static void builtin_init ( void  )
static

Initialise built-in settings.

Definition at line 2660 of file settings.c.

2660  {
2661  int rc;
2662 
2664  "builtin" ) ) != 0 ) {
2665  DBG ( "Could not register built-in settings: %s\n",
2666  strerror ( rc ) );
2667  return;
2668  }
2669 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static struct settings builtin_settings
Built-in settings.
Definition: settings.c:2652
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
int register_settings(struct settings *settings, struct settings *parent, const char *name)
Register settings block.
Definition: settings.c:478
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References builtin_settings, DBG, NULL, rc, register_settings(), and strerror().

◆ __init_fn()

struct init_fn builtin_init_fn __init_fn ( INIT_NORMAL  )

Built-in settings initialiser.

Variable Documentation

◆ generic_settings_operations

struct settings_operations generic_settings_operations
Initial value:
= {
}
void generic_settings_clear(struct settings *settings)
Clear generic settings block.
Definition: settings.c:207
int generic_settings_fetch(struct settings *settings, struct setting *setting, void *data, size_t len)
Fetch value of generic setting.
Definition: settings.c:178
int generic_settings_store(struct settings *settings, const struct setting *setting, const void *data, size_t len)
Store value of generic setting.
Definition: settings.c:126

Generic settings operations.

Definition at line 221 of file settings.c.

Referenced by generic_settings_init().

◆ generic_settings_root

struct generic_settings generic_settings_root
Initial value:
= {
.settings = {
.refcnt = NULL,
.name = "",
.siblings =
.children =
},
}
struct settings_operations generic_settings_operations
Generic settings operations.
Definition: settings.c:221
struct list_head list
List of generic settings.
Definition: settings.h:302
struct generic_settings generic_settings_root
Root generic settings block.
Definition: settings.c:235
struct list_head siblings
Sibling settings blocks.
Definition: settings.h:140
struct settings settings
Settings block.
Definition: settings.h:300
struct list_head children
Child settings blocks.
Definition: settings.h:142
#define LIST_HEAD_INIT(list)
Initialise a static list head.
Definition: list.h:30
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

Root generic settings block.

Definition at line 235 of file settings.c.

◆ __setting_type

const struct setting_type setting_type_busdevfn __setting_type
Initial value:
= {
.name = "string",
}
static int format_string_setting(const struct setting_type *type __unused, const void *raw, size_t raw_len, char *buf, size_t len)
Format string setting value.
Definition: settings.c:1658
static int parse_string_setting(const struct setting_type *type __unused, const char *value, void *buf, size_t len)
Parse string setting value.
Definition: settings.c:1636

A string setting type.

PCI bus:dev.fn setting type.

UUID setting type.

A Base64-encoded setting.

A hex-string setting (non-delimited)

A hex-string setting (hyphen-delimited)

A hex-string setting (colon-delimited)

An unsigned 32-bit integer setting type.

An unsigned 16-bit integer setting type.

An unsigned 8-bit integer setting type.

A signed 32-bit integer setting type.

A signed 16-bit integer setting type.

A signed 8-bit integer setting type.

An IPv6 address setting type.

An IPv4 address setting type.

A URI-encoded string setting type.

Definition at line 1672 of file settings.c.

◆ dhcpv6_scope

const struct settings_scope dhcpv6_scope

IPv6 settings scope.

DHCPv6 setting scope.

Definition at line 1796 of file settings.c.

Referenced by dhcpv6_applies(), and dhcpv6_register().

◆ setting_type_int_name

const char setting_type_int_name[][8]
static
Initial value:

Integer setting type names.

These names exist as a static array in order to allow the type's integer size and signedness to be determined from the type's name. Note that there are no separate entries for the signed integer types: the name pointers simply point to the second character of the relevant string.

Definition at line 1819 of file settings.c.

Referenced by setting_type_int_index(), and setting_type_int_is_signed().

◆ builtin_scope

const struct settings_scope builtin_scope

Built-in setting scope.

Definition at line 2463 of file settings.c.

Referenced by builtin_applies().

◆ __builtin_setting

struct builtin_setting unixtime_builtin_setting __builtin_setting
Initial value:
= {
.setting = &errno_setting,
.fetch = errno_fetch,
}
static int errno_fetch(void *data, size_t len)
Fetch error number setting.
Definition: settings.c:2472

Error number built-in setting.

Current time built-in setting.

Version built-in setting.

Platform built-in setting.

Build architecture built-in setting.

Definition at line 2492 of file settings.c.

◆ builtin_settings_operations

struct settings_operations builtin_settings_operations
static
Initial value:
= {
.applies = builtin_applies,
.fetch = builtin_fetch,
}
static int builtin_applies(struct settings *settings __unused, const struct setting *setting)
Check applicability of built-in setting.
Definition: settings.c:2639
static int builtin_fetch(struct settings *settings __unused, struct setting *setting, void *data, size_t len)
Fetch built-in setting.
Definition: settings.c:2620

Built-in settings operations.

Definition at line 2646 of file settings.c.

◆ builtin_settings

struct settings builtin_settings
static
Initial value:
= {
.refcnt = NULL,
}
static struct settings_operations builtin_settings_operations
Built-in settings operations.
Definition: settings.c:2646
static struct settings builtin_settings
Built-in settings.
Definition: settings.c:2652
struct list_head siblings
Sibling settings blocks.
Definition: settings.h:140
struct list_head children
Child settings blocks.
Definition: settings.h:142
#define LIST_HEAD_INIT(list)
Initialise a static list head.
Definition: list.h:30
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

Built-in settings.

Definition at line 2652 of file settings.c.

Referenced by builtin_init().