From f5fd4dec3bab362a2ff7844859914e1f191fb905 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 22 Mar 2011 16:56:35 +0000 Subject: [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 Signed-off-by: Michael Brown --- src/include/ipxe/netdevice.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/include/ipxe/netdevice.h') diff --git a/src/include/ipxe/netdevice.h b/src/include/ipxe/netdevice.h index ac7cec521..e49191f4a 100644 --- a/src/include/ipxe/netdevice.h +++ b/src/include/ipxe/netdevice.h @@ -390,6 +390,38 @@ struct net_driver { /** Declare a network driver */ #define __net_driver __table_entry ( NET_DRIVERS, 01 ) +/** Network device setting tag magic + * + * All DHCP option settings are deemed to be valid as network device + * settings. There are also some extra non-DHCP settings (such as + * "mac"), which are marked as being valid network device settings by + * using a magic tag value. + */ +#define NETDEV_SETTING_TAG_MAGIC 0xeb + +/** + * Construct network device setting tag + * + * @v id Unique identifier + * @ret tag Setting tag + */ +#define NETDEV_SETTING_TAG( id ) ( ( NETDEV_SETTING_TAG_MAGIC << 24 ) | (id) ) + +/** + * Check if tag is a network device setting tag + * + * @v tag Setting tag + * @ret is_ours Tag is a network device setting tag + */ +#define IS_NETDEV_SETTING_TAG( tag ) \ + ( ( (tag) >> 24 ) == NETDEV_SETTING_TAG_MAGIC ) + +/** MAC address setting tag */ +#define NETDEV_SETTING_TAG_MAC NETDEV_SETTING_TAG ( 0x01 ) + +/** Bus ID setting tag */ +#define NETDEV_SETTING_TAG_BUS_ID NETDEV_SETTING_TAG ( 0x02 ) + extern struct list_head net_devices; extern struct net_device_operations null_netdev_operations; extern struct settings_operations netdev_settings_operations; -- cgit v1.2.3-55-g7522