mirror of
https://github.com/ipxe/ipxe
synced 2025-12-22 21:11:03 +03:00
[settings] Formalise notion of setting applicability
Expose a function setting_applies() to allow a caller to determine whether or not a particular setting is applicable to a particular settings block. Restrict DHCP-backed settings blocks to accepting only DHCP-based settings. Restrict network device settings blocks to accepting only DHCP-based settings and network device-specific settings such as "mac". Inspired-by: Glenn Brown <glenn@myri.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -63,6 +63,22 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
( (_type) << 16 ) | \
|
||||
( offsetof ( _structure, _field ) << 8 ) )
|
||||
|
||||
/**
|
||||
* Check applicability of SMBIOS setting
|
||||
*
|
||||
* @v settings Settings block
|
||||
* @v setting Setting
|
||||
* @ret applies Setting applies within this settings block
|
||||
*/
|
||||
static int smbios_applies ( struct settings *settings __unused,
|
||||
struct setting *setting ) {
|
||||
unsigned int tag_magic;
|
||||
|
||||
/* Check tag magic */
|
||||
tag_magic = ( setting->tag >> 24 );
|
||||
return ( tag_magic == SMBIOS_TAG_MAGIC );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch value of SMBIOS setting
|
||||
*
|
||||
@@ -87,8 +103,7 @@ static int smbios_fetch ( struct settings *settings __unused,
|
||||
tag_type = ( ( setting->tag >> 16 ) & 0xff );
|
||||
tag_offset = ( ( setting->tag >> 8 ) & 0xff );
|
||||
tag_len = ( setting->tag & 0xff );
|
||||
if ( tag_magic != SMBIOS_TAG_MAGIC )
|
||||
return -ENOENT;
|
||||
assert ( tag_magic == SMBIOS_TAG_MAGIC );
|
||||
|
||||
/* Find SMBIOS structure */
|
||||
if ( ( rc = find_smbios_structure ( tag_type, &structure ) ) != 0 )
|
||||
@@ -119,6 +134,7 @@ static int smbios_fetch ( struct settings *settings __unused,
|
||||
|
||||
/** SMBIOS settings operations */
|
||||
static struct settings_operations smbios_settings_operations = {
|
||||
.applies = smbios_applies,
|
||||
.fetch = smbios_fetch,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user