Browse Source

[settings] Eliminate settings "tag magic"

Create an explicit concept of "settings scope" and eliminate the magic
values used for numerical setting tags.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
15d2f947f5

+ 1
- 1
src/arch/i386/interface/vmware/guestinfo.c View File

224
 		rc = -ENOMEM;
224
 		rc = -ENOMEM;
225
 		goto err_alloc;
225
 		goto err_alloc;
226
 	}
226
 	}
227
-	settings_init ( settings, &guestinfo_settings_operations, NULL, 0 );
227
+	settings_init ( settings, &guestinfo_settings_operations, NULL, NULL );
228
 
228
 
229
 	/* Register settings */
229
 	/* Register settings */
230
 	if ( ( rc = register_settings ( settings, netdev_settings ( netdev ),
230
 	if ( ( rc = register_settings ( settings, netdev_settings ( netdev ),

+ 4
- 2
src/core/nvo.c View File

195
 int nvo_applies ( struct settings *settings __unused,
195
 int nvo_applies ( struct settings *settings __unused,
196
 		  struct setting *setting ) {
196
 		  struct setting *setting ) {
197
 
197
 
198
-	return dhcpopt_applies ( setting->tag );
198
+	return ( ( setting->scope == NULL ) &&
199
+		 dhcpopt_applies ( setting->tag ) );
199
 }
200
 }
200
 
201
 
201
 /**
202
 /**
274
 	nvo->len = len;
275
 	nvo->len = len;
275
 	nvo->resize = resize;
276
 	nvo->resize = resize;
276
 	dhcpopt_init ( &nvo->dhcpopts, NULL, 0, nvo_realloc_dhcpopt );
277
 	dhcpopt_init ( &nvo->dhcpopts, NULL, 0, nvo_realloc_dhcpopt );
277
-	settings_init ( &nvo->settings, &nvo_settings_operations, refcnt, 0 );
278
+	settings_init ( &nvo->settings, &nvo_settings_operations,
279
+			refcnt, NULL );
278
 }
280
 }
279
 
281
 
280
 /**
282
 /**

+ 11
- 33
src/core/settings.c View File

984
 int setting_cmp ( struct setting *a, struct setting *b ) {
984
 int setting_cmp ( struct setting *a, struct setting *b ) {
985
 
985
 
986
 	/* If the settings have tags, compare them */
986
 	/* If the settings have tags, compare them */
987
-	if ( a->tag && ( a->tag == b->tag ) )
987
+	if ( a->tag && ( a->tag == b->tag ) && ( a->scope == b->scope ) )
988
 		return 0;
988
 		return 0;
989
 
989
 
990
 	/* Otherwise, if the settings have names, compare them */
990
 	/* Otherwise, if the settings have names, compare them */
1099
 /**
1099
 /**
1100
  * Parse setting name as tag number
1100
  * Parse setting name as tag number
1101
  *
1101
  *
1102
- * @v settings		Settings block
1103
  * @v name		Name
1102
  * @v name		Name
1104
  * @ret tag		Tag number, or 0 if not a valid number
1103
  * @ret tag		Tag number, or 0 if not a valid number
1105
  */
1104
  */
1106
-static unsigned int parse_setting_tag ( struct settings *settings,
1107
-					const char *name ) {
1105
+static unsigned int parse_setting_tag ( const char *name ) {
1108
 	char *tmp = ( ( char * ) name );
1106
 	char *tmp = ( ( char * ) name );
1109
 	unsigned int tag = 0;
1107
 	unsigned int tag = 0;
1110
 
1108
 
1111
 	while ( 1 ) {
1109
 	while ( 1 ) {
1112
 		tag = ( ( tag << 8 ) | strtoul ( tmp, &tmp, 0 ) );
1110
 		tag = ( ( tag << 8 ) | strtoul ( tmp, &tmp, 0 ) );
1113
 		if ( *tmp == 0 )
1111
 		if ( *tmp == 0 )
1114
-			return ( tag | settings->tag_magic );
1112
+			return tag;
1115
 		if ( *tmp != '.' )
1113
 		if ( *tmp != '.' )
1116
 			return 0;
1114
 			return 0;
1117
 		tmp++;
1115
 		tmp++;
1193
 	}
1191
 	}
1194
 
1192
 
1195
 	/* Identify setting */
1193
 	/* Identify setting */
1196
-	setting->tag = parse_setting_tag ( *settings, setting_name );
1194
+	setting->tag = parse_setting_tag ( setting_name );
1195
+	setting->scope = (*settings)->default_scope;
1197
 	setting->name = setting_name;
1196
 	setting->name = setting_name;
1198
 	for_each_table_entry ( named_setting, SETTINGS ) {
1197
 	for_each_table_entry ( named_setting, SETTINGS ) {
1199
 		/* Matches a defined named setting; use that setting */
1198
 		/* Matches a defined named setting; use that setting */
1998
 	int ( * fetch ) ( void *data, size_t len );
1997
 	int ( * fetch ) ( void *data, size_t len );
1999
 };
1998
 };
2000
 
1999
 
2001
-/** Built-in setting tag magic */
2002
-#define BUILTIN_SETTING_TAG_MAGIC 0xb1
2003
-
2004
-/**
2005
- * Construct built-in setting tag
2006
- *
2007
- * @v id		Unique identifier
2008
- * @ret tag		Setting tag
2009
- */
2010
-#define BUILTIN_SETTING_TAG( id ) ( ( BUILTIN_SETTING_TAG_MAGIC << 24 ) | (id) )
2011
-
2012
-/** "errno" setting tag */
2013
-#define BUILTIN_SETTING_TAG_ERRNO BUILTIN_SETTING_TAG ( 0x01 )
2000
+/** Built-in setting scope */
2001
+static struct settings_scope builtin_scope;
2014
 
2002
 
2015
 /** Error number setting */
2003
 /** Error number setting */
2016
 struct setting errno_setting __setting ( SETTING_MISC ) = {
2004
 struct setting errno_setting __setting ( SETTING_MISC ) = {
2017
 	.name = "errno",
2005
 	.name = "errno",
2018
 	.description = "Last error",
2006
 	.description = "Last error",
2019
-	.tag = BUILTIN_SETTING_TAG_ERRNO,
2020
 	.type = &setting_type_uint32,
2007
 	.type = &setting_type_uint32,
2008
+	.scope = &builtin_scope,
2021
 };
2009
 };
2022
 
2010
 
2023
 /**
2011
 /**
2038
 	return sizeof ( content );
2026
 	return sizeof ( content );
2039
 }
2027
 }
2040
 
2028
 
2041
-/** "buildarch" setting tag */
2042
-#define BUILTIN_SETTING_TAG_BUILDARCH BUILTIN_SETTING_TAG ( 0x02 )
2043
-
2044
 /** Build architecture setting */
2029
 /** Build architecture setting */
2045
 struct setting buildarch_setting __setting ( SETTING_MISC ) = {
2030
 struct setting buildarch_setting __setting ( SETTING_MISC ) = {
2046
 	.name = "buildarch",
2031
 	.name = "buildarch",
2047
 	.description = "Build architecture",
2032
 	.description = "Build architecture",
2048
-	.tag = BUILTIN_SETTING_TAG_BUILDARCH,
2049
 	.type = &setting_type_string,
2033
 	.type = &setting_type_string,
2034
+	.scope = &builtin_scope,
2050
 };
2035
 };
2051
 
2036
 
2052
 /**
2037
 /**
2063
 	return ( sizeof ( buildarch ) - 1 /* NUL */ );
2048
 	return ( sizeof ( buildarch ) - 1 /* NUL */ );
2064
 }
2049
 }
2065
 
2050
 
2066
-/** "platform" setting tag */
2067
-#define BUILTIN_SETTING_TAG_PLATFORM BUILTIN_SETTING_TAG ( 0x03 )
2068
-
2069
 /** Platform setting */
2051
 /** Platform setting */
2070
 struct setting platform_setting __setting ( SETTING_MISC ) = {
2052
 struct setting platform_setting __setting ( SETTING_MISC ) = {
2071
 	.name = "platform",
2053
 	.name = "platform",
2072
 	.description = "Platform",
2054
 	.description = "Platform",
2073
-	.tag = BUILTIN_SETTING_TAG_PLATFORM,
2074
 	.type = &setting_type_string,
2055
 	.type = &setting_type_string,
2056
+	.scope = &builtin_scope,
2075
 };
2057
 };
2076
 
2058
 
2077
 /**
2059
 /**
2128
  */
2110
  */
2129
 static int builtin_applies ( struct settings *settings __unused,
2111
 static int builtin_applies ( struct settings *settings __unused,
2130
 			     struct setting *setting ) {
2112
 			     struct setting *setting ) {
2131
-	unsigned int tag_magic;
2132
 
2113
 
2133
-	/* Check tag magic */
2134
-	tag_magic = ( setting->tag >> 24 );
2135
-	return ( tag_magic == BUILTIN_SETTING_TAG_MAGIC );
2114
+	return ( setting->scope == &builtin_scope );
2136
 }
2115
 }
2137
 
2116
 
2138
 /** Built-in settings operations */
2117
 /** Built-in settings operations */
2144
 /** Built-in settings */
2123
 /** Built-in settings */
2145
 static struct settings builtin_settings = {
2124
 static struct settings builtin_settings = {
2146
 	.refcnt = NULL,
2125
 	.refcnt = NULL,
2147
-	.tag_magic = BUILTIN_SETTING_TAG ( 0 ),
2148
 	.siblings = LIST_HEAD_INIT ( builtin_settings.siblings ),
2126
 	.siblings = LIST_HEAD_INIT ( builtin_settings.siblings ),
2149
 	.children = LIST_HEAD_INIT ( builtin_settings.children ),
2127
 	.children = LIST_HEAD_INIT ( builtin_settings.children ),
2150
 	.op = &builtin_settings_operations,
2128
 	.op = &builtin_settings_operations,

+ 5
- 8
src/drivers/net/phantom/phantom.c View File

1454
  *
1454
  *
1455
  */
1455
  */
1456
 
1456
 
1457
-/** Phantom CLP settings tag magic */
1458
-#define PHN_CLP_TAG_MAGIC 0xc19c1900UL
1459
-
1460
-/** Phantom CLP settings tag magic mask */
1461
-#define PHN_CLP_TAG_MAGIC_MASK 0xffffff00UL
1457
+/** Phantom CLP settings scope */
1458
+static struct settings_scope phantom_settings_scope;
1462
 
1459
 
1463
 /** Phantom CLP data
1460
 /** Phantom CLP data
1464
  *
1461
  *
1689
 	}
1686
 	}
1690
 
1687
 
1691
 	/* Allow for use of numbered settings */
1688
 	/* Allow for use of numbered settings */
1692
-	if ( ( setting->tag & PHN_CLP_TAG_MAGIC_MASK ) == PHN_CLP_TAG_MAGIC )
1693
-		return ( setting->tag & ~PHN_CLP_TAG_MAGIC_MASK );
1689
+	if ( setting->scope == &phantom_settings_scope )
1690
+		return setting->tag;
1694
 
1691
 
1695
 	DBGC2 ( phantom, "Phantom %p has no \"%s\" setting\n",
1692
 	DBGC2 ( phantom, "Phantom %p has no \"%s\" setting\n",
1696
 		phantom, setting->name );
1693
 		phantom, setting->name );
2075
 	assert ( phantom->port < PHN_MAX_NUM_PORTS );
2072
 	assert ( phantom->port < PHN_MAX_NUM_PORTS );
2076
 	settings_init ( &phantom->settings,
2073
 	settings_init ( &phantom->settings,
2077
 			&phantom_settings_operations,
2074
 			&phantom_settings_operations,
2078
-			&netdev->refcnt, PHN_CLP_TAG_MAGIC );
2075
+			&netdev->refcnt, &phantom_settings_scope );
2079
 
2076
 
2080
 	/* Fix up PCI device */
2077
 	/* Fix up PCI device */
2081
 	adjust_pci_device ( pci );
2078
 	adjust_pci_device ( pci );

+ 0
- 21
src/include/ipxe/net80211.h View File

1183
 		 net80211_duration ( dev, size, dev->rates[dev->rate] ) );
1183
 		 net80211_duration ( dev, size, dev->rates[dev->rate] ) );
1184
 }
1184
 }
1185
 
1185
 
1186
-/** 802.11 device setting tag magic */
1187
-#define NET80211_SETTING_TAG_MAGIC 0x8211
1188
-
1189
-/**
1190
- * Construct 802.11 setting tag
1191
- *
1192
- * @v id		Unique identifier
1193
- * @ret tag		Setting tag
1194
- */
1195
-#define NET80211_SETTING_TAG( id ) \
1196
-	NETDEV_SETTING_TAG ( ( NET80211_SETTING_TAG_MAGIC << 8 ) | (id) )
1197
-
1198
-/** SSID setting tag */
1199
-#define NET80211_SETTING_TAG_SSID NET80211_SETTING_TAG ( 0x01 )
1200
-
1201
-/** Active scanning setting tag */
1202
-#define NET80211_SETTING_TAG_ACTIVE_SCAN NET80211_SETTING_TAG ( 0x02 )
1203
-
1204
-/** Wireless key setting tag */
1205
-#define NET80211_SETTING_TAG_KEY NET80211_SETTING_TAG ( 0x03 )
1206
-
1207
 #endif
1186
 #endif

+ 0
- 32
src/include/ipxe/netdevice.h View File

411
 /** Declare a network driver */
411
 /** Declare a network driver */
412
 #define __net_driver __table_entry ( NET_DRIVERS, 01 )
412
 #define __net_driver __table_entry ( NET_DRIVERS, 01 )
413
 
413
 
414
-/** Network device setting tag magic
415
- *
416
- * All DHCP option settings are deemed to be valid as network device
417
- * settings.  There are also some extra non-DHCP settings (such as
418
- * "mac"), which are marked as being valid network device settings by
419
- * using a magic tag value.
420
- */
421
-#define NETDEV_SETTING_TAG_MAGIC 0xeb
422
-
423
-/**
424
- * Construct network device setting tag
425
- *
426
- * @v id		Unique identifier
427
- * @ret tag		Setting tag
428
- */
429
-#define NETDEV_SETTING_TAG( id ) ( ( NETDEV_SETTING_TAG_MAGIC << 24 ) | (id) )
430
-
431
-/**
432
- * Check if tag is a network device setting tag
433
- *
434
- * @v tag		Setting tag
435
- * @ret is_ours		Tag is a network device setting tag
436
- */
437
-#define IS_NETDEV_SETTING_TAG( tag ) \
438
-	( ( (tag) >> 24 ) == NETDEV_SETTING_TAG_MAGIC )
439
-
440
-/** MAC address setting tag */
441
-#define NETDEV_SETTING_TAG_MAC NETDEV_SETTING_TAG ( 0x01 )
442
-
443
-/** Bus ID setting tag */
444
-#define NETDEV_SETTING_TAG_BUS_ID NETDEV_SETTING_TAG ( 0x02 )
445
-
446
 extern struct list_head net_devices;
414
 extern struct list_head net_devices;
447
 extern struct net_device_operations null_netdev_operations;
415
 extern struct net_device_operations null_netdev_operations;
448
 extern struct settings_operations netdev_settings_operations;
416
 extern struct settings_operations netdev_settings_operations;

+ 46
- 29
src/include/ipxe/settings.h View File

38
 	 * The setting tag is a numerical description of the setting
38
 	 * The setting tag is a numerical description of the setting
39
 	 * (such as a DHCP option number, or an SMBIOS structure and
39
 	 * (such as a DHCP option number, or an SMBIOS structure and
40
 	 * field number).
40
 	 * field number).
41
-	 *
42
-	 * Users can construct tags for settings that are not
43
-	 * explicitly known to iPXE using the generic syntax for
44
-	 * numerical settings.  For example, the setting name "60"
45
-	 * will be interpreted as referring to DHCP option 60 (the
46
-	 * vendor class identifier).
47
-	 *
48
-	 * This creates a potential for namespace collisions, since
49
-	 * the interpretation of the numerical description will vary
50
-	 * according to the settings block.  When a user attempts to
51
-	 * fetch a generic numerical setting, we need to ensure that
52
-	 * only the intended settings block interprets the numerical
53
-	 * description.  (For example, we do not want to attempt to
54
-	 * retrieve the subnet mask from SMBIOS, or the system UUID
55
-	 * from DHCP.)
56
-	 *
57
-	 * This potential problem is resolved by allowing the setting
58
-	 * tag to include a "magic" value indicating the
59
-	 * interpretation to be placed upon the numerical description.
60
 	 */
41
 	 */
61
 	unsigned int tag;
42
 	unsigned int tag;
43
+	/** Setting scope (or NULL)
44
+	 *
45
+	 * For historic reasons, a NULL scope with a non-zero tag
46
+	 * indicates a DHCPv4 option setting.
47
+	 */
48
+	struct settings_scope *scope;
62
 };
49
 };
63
 
50
 
64
 /** Configuration setting table */
51
 /** Configuration setting table */
134
 	struct refcnt *refcnt;
121
 	struct refcnt *refcnt;
135
 	/** Name */
122
 	/** Name */
136
 	const char *name;
123
 	const char *name;
137
-	/** Tag magic
138
-	 *
139
-	 * This value will be ORed in to any numerical tags
140
-	 * constructed by parse_setting_name().
141
-	 */
142
-	unsigned int tag_magic;
143
 	/** Parent settings block */
124
 	/** Parent settings block */
144
 	struct settings *parent;
125
 	struct settings *parent;
145
 	/** Sibling settings blocks */
126
 	/** Sibling settings blocks */
148
 	struct list_head children;
129
 	struct list_head children;
149
 	/** Settings block operations */
130
 	/** Settings block operations */
150
 	struct settings_operations *op;
131
 	struct settings_operations *op;
132
+	/** Default scope for numerical settings constructed for this block */
133
+	struct settings_scope *default_scope;
151
 };
134
 };
152
 
135
 
136
+/**
137
+ * A setting scope
138
+ *
139
+ * Users can construct tags for settings that are not explicitly known
140
+ * to iPXE using the generic syntax for numerical settings.  For
141
+ * example, the setting name "60" will be interpreted as referring to
142
+ * DHCP option 60 (the vendor class identifier).
143
+ *
144
+ * This creates a potential for namespace collisions, since the
145
+ * interpretation of the numerical description will vary according to
146
+ * the settings block.  When a user attempts to fetch a generic
147
+ * numerical setting, we need to ensure that only the intended
148
+ * settings blocks interpret this numerical description.  (For
149
+ * example, we do not want to attempt to retrieve the subnet mask from
150
+ * SMBIOS, or the system UUID from DHCP.)
151
+ *
152
+ * This potential problem is resolved by including a user-invisible
153
+ * "scope" within the definition of each setting.  Settings blocks may
154
+ * use this to determine whether or not the setting is applicable.
155
+ * Any settings constructed from a numerical description
156
+ * (e.g. "smbios/1.4.0") will be assigned the default scope of the
157
+ * settings block specified in the description (e.g. "smbios"); this
158
+ * provides behaviour matching the user's expectations in most
159
+ * circumstances.
160
+ */
161
+struct settings_scope {
162
+	/** Dummy field
163
+	 *
164
+	 * This is included only to ensure that pointers to different
165
+	 * scopes always compare differently.
166
+	 */
167
+	uint8_t dummy;
168
+} __attribute__ (( packed ));
169
+
153
 /**
170
 /**
154
  * A setting type
171
  * A setting type
155
  *
172
  *
329
  * @v settings		Settings block
346
  * @v settings		Settings block
330
  * @v op		Settings block operations
347
  * @v op		Settings block operations
331
  * @v refcnt		Containing object reference counter, or NULL
348
  * @v refcnt		Containing object reference counter, or NULL
332
- * @v tag_magic		Tag magic
349
+ * @v default_scope	Default scope
333
  */
350
  */
334
 static inline void settings_init ( struct settings *settings,
351
 static inline void settings_init ( struct settings *settings,
335
 				   struct settings_operations *op,
352
 				   struct settings_operations *op,
336
 				   struct refcnt *refcnt,
353
 				   struct refcnt *refcnt,
337
-				   unsigned int tag_magic ) {
354
+				   struct settings_scope *default_scope ) {
338
 	INIT_LIST_HEAD ( &settings->siblings );
355
 	INIT_LIST_HEAD ( &settings->siblings );
339
 	INIT_LIST_HEAD ( &settings->children );
356
 	INIT_LIST_HEAD ( &settings->children );
340
 	settings->op = op;
357
 	settings->op = op;
341
 	settings->refcnt = refcnt;
358
 	settings->refcnt = refcnt;
342
-	settings->tag_magic = tag_magic;
359
+	settings->default_scope = default_scope;
343
 }
360
 }
344
 
361
 
345
 /**
362
 /**
351
 static inline void generic_settings_init ( struct generic_settings *generics,
368
 static inline void generic_settings_init ( struct generic_settings *generics,
352
 					   struct refcnt *refcnt ) {
369
 					   struct refcnt *refcnt ) {
353
 	settings_init ( &generics->settings, &generic_settings_operations,
370
 	settings_init ( &generics->settings, &generic_settings_operations,
354
-			refcnt, 0 );
371
+			refcnt, NULL );
355
 	INIT_LIST_HEAD ( &generics->list );
372
 	INIT_LIST_HEAD ( &generics->list );
356
 }
373
 }
357
 
374
 

+ 11
- 21
src/interface/smbios/smbios_settings.c View File

27
 #include <ipxe/uuid.h>
27
 #include <ipxe/uuid.h>
28
 #include <ipxe/smbios.h>
28
 #include <ipxe/smbios.h>
29
 
29
 
30
-/** SMBIOS settings tag magic number */
31
-#define SMBIOS_TAG_MAGIC 0x5B /* "SmBios" */
32
-
33
-/**
34
- * Construct SMBIOS empty tag
35
- *
36
- * @ret tag		SMBIOS setting tag
37
- */
38
-#define SMBIOS_EMPTY_TAG ( SMBIOS_TAG_MAGIC << 24 )
30
+/** SMBIOS settings scope */
31
+static struct settings_scope smbios_settings_scope;
39
 
32
 
40
 /**
33
 /**
41
  * Construct SMBIOS raw-data tag
34
  * Construct SMBIOS raw-data tag
46
  * @ret tag		SMBIOS setting tag
39
  * @ret tag		SMBIOS setting tag
47
  */
40
  */
48
 #define SMBIOS_RAW_TAG( _type, _structure, _field )		\
41
 #define SMBIOS_RAW_TAG( _type, _structure, _field )		\
49
-	( ( SMBIOS_TAG_MAGIC << 24 ) |				\
50
-	  ( (_type) << 16 ) |					\
42
+	( ( (_type) << 16 ) |					\
51
 	  ( offsetof ( _structure, _field ) << 8 ) |		\
43
 	  ( offsetof ( _structure, _field ) << 8 ) |		\
52
 	  ( sizeof ( ( ( _structure * ) 0 )->_field ) ) )
44
 	  ( sizeof ( ( ( _structure * ) 0 )->_field ) ) )
53
 
45
 
60
  * @ret tag		SMBIOS setting tag
52
  * @ret tag		SMBIOS setting tag
61
  */
53
  */
62
 #define SMBIOS_STRING_TAG( _type, _structure, _field )		\
54
 #define SMBIOS_STRING_TAG( _type, _structure, _field )		\
63
-	( ( SMBIOS_TAG_MAGIC << 24 ) |				\
64
-	  ( (_type) << 16 ) |					\
55
+	( ( (_type) << 16 ) |					\
65
 	  ( offsetof ( _structure, _field ) << 8 ) )
56
 	  ( offsetof ( _structure, _field ) << 8 ) )
66
 
57
 
67
 /**
58
 /**
73
  */
64
  */
74
 static int smbios_applies ( struct settings *settings __unused,
65
 static int smbios_applies ( struct settings *settings __unused,
75
 			    struct setting *setting ) {
66
 			    struct setting *setting ) {
76
-	unsigned int tag_magic;
77
 
67
 
78
-	/* Check tag magic */
79
-	tag_magic = ( setting->tag >> 24 );
80
-	return ( tag_magic == SMBIOS_TAG_MAGIC );
68
+	return ( setting->scope == &smbios_settings_scope );
81
 }
69
 }
82
 
70
 
83
 /**
71
 /**
93
 			  struct setting *setting,
81
 			  struct setting *setting,
94
 			  void *data, size_t len ) {
82
 			  void *data, size_t len ) {
95
 	struct smbios_structure structure;
83
 	struct smbios_structure structure;
96
-	unsigned int tag_magic;
97
 	unsigned int tag_type;
84
 	unsigned int tag_type;
98
 	unsigned int tag_offset;
85
 	unsigned int tag_offset;
99
 	unsigned int tag_len;
86
 	unsigned int tag_len;
100
 	int rc;
87
 	int rc;
101
 
88
 
102
 	/* Split tag into type, offset and length */
89
 	/* Split tag into type, offset and length */
103
-	tag_magic = ( setting->tag >> 24 );
104
 	tag_type = ( ( setting->tag >> 16 ) & 0xff );
90
 	tag_type = ( ( setting->tag >> 16 ) & 0xff );
105
 	tag_offset = ( ( setting->tag >> 8 ) & 0xff );
91
 	tag_offset = ( ( setting->tag >> 8 ) & 0xff );
106
 	tag_len = ( setting->tag & 0xff );
92
 	tag_len = ( setting->tag & 0xff );
107
-	assert ( tag_magic == SMBIOS_TAG_MAGIC );
108
 
93
 
109
 	/* Find SMBIOS structure */
94
 	/* Find SMBIOS structure */
110
 	if ( ( rc = find_smbios_structure ( tag_type, &structure ) ) != 0 )
95
 	if ( ( rc = find_smbios_structure ( tag_type, &structure ) ) != 0 )
170
 /** SMBIOS settings */
155
 /** SMBIOS settings */
171
 static struct settings smbios_settings = {
156
 static struct settings smbios_settings = {
172
 	.refcnt = NULL,
157
 	.refcnt = NULL,
173
-	.tag_magic = SMBIOS_EMPTY_TAG,
174
 	.siblings = LIST_HEAD_INIT ( smbios_settings.siblings ),
158
 	.siblings = LIST_HEAD_INIT ( smbios_settings.siblings ),
175
 	.children = LIST_HEAD_INIT ( smbios_settings.children ),
159
 	.children = LIST_HEAD_INIT ( smbios_settings.children ),
176
 	.op = &smbios_settings_operations,
160
 	.op = &smbios_settings_operations,
161
+	.default_scope = &smbios_settings_scope,
177
 };
162
 };
178
 
163
 
179
 /** Initialise SMBIOS settings */
164
 /** Initialise SMBIOS settings */
200
 	.tag = SMBIOS_RAW_TAG ( SMBIOS_TYPE_SYSTEM_INFORMATION,
185
 	.tag = SMBIOS_RAW_TAG ( SMBIOS_TYPE_SYSTEM_INFORMATION,
201
 				struct smbios_system_information, uuid ),
186
 				struct smbios_system_information, uuid ),
202
 	.type = &setting_type_uuid,
187
 	.type = &setting_type_uuid,
188
+	.scope = &smbios_settings_scope,
203
 };
189
 };
204
 
190
 
205
 /** Other SMBIOS named settings */
191
 /** Other SMBIOS named settings */
211
 					   struct smbios_system_information,
197
 					   struct smbios_system_information,
212
 					   manufacturer ),
198
 					   manufacturer ),
213
 		.type = &setting_type_string,
199
 		.type = &setting_type_string,
200
+		.scope = &smbios_settings_scope,
214
 	},
201
 	},
215
 	{
202
 	{
216
 		.name = "product",
203
 		.name = "product",
219
 					   struct smbios_system_information,
206
 					   struct smbios_system_information,
220
 					   product ),
207
 					   product ),
221
 		.type = &setting_type_string,
208
 		.type = &setting_type_string,
209
+		.scope = &smbios_settings_scope,
222
 	},
210
 	},
223
 	{
211
 	{
224
 		.name = "serial",
212
 		.name = "serial",
227
 					   struct smbios_system_information,
215
 					   struct smbios_system_information,
228
 					   serial ),
216
 					   serial ),
229
 		.type = &setting_type_string,
217
 		.type = &setting_type_string,
218
+		.scope = &smbios_settings_scope,
230
 	},
219
 	},
231
 	{
220
 	{
232
 		.name = "asset",
221
 		.name = "asset",
235
 					   struct smbios_enclosure_information,
224
 					   struct smbios_enclosure_information,
236
 					   asset_tag ),
225
 					   asset_tag ),
237
 		.type = &setting_type_string,
226
 		.type = &setting_type_string,
227
+		.scope = &smbios_settings_scope,
238
 	},
228
 	},
239
 };
229
 };

+ 0
- 3
src/net/80211/net80211.c View File

208
 	.name = "ssid",
208
 	.name = "ssid",
209
 	.description = "Wireless SSID",
209
 	.description = "Wireless SSID",
210
 	.type = &setting_type_string,
210
 	.type = &setting_type_string,
211
-	.tag = NET80211_SETTING_TAG_SSID,
212
 };
211
 };
213
 
212
 
214
 /** Whether to use active scanning
213
 /** Whether to use active scanning
221
 	.name = "active-scan",
220
 	.name = "active-scan",
222
 	.description = "Actively scan for wireless networks",
221
 	.description = "Actively scan for wireless networks",
223
 	.type = &setting_type_int8,
222
 	.type = &setting_type_int8,
224
-	.tag = NET80211_SETTING_TAG_ACTIVE_SCAN,
225
 };
223
 };
226
 
224
 
227
 /** The cryptographic key to use
225
 /** The cryptographic key to use
234
 	.name = "key",
232
 	.name = "key",
235
 	.description = "Wireless encryption key",
233
 	.description = "Wireless encryption key",
236
 	.type = &setting_type_string,
234
 	.type = &setting_type_string,
237
-	.tag = NET80211_SETTING_TAG_KEY,
238
 };
235
 };
239
 
236
 
240
 /** @} */
237
 /** @} */

+ 4
- 3
src/net/dhcppkt.c View File

230
 	struct dhcp_packet *dhcppkt =
230
 	struct dhcp_packet *dhcppkt =
231
 		container_of ( settings, struct dhcp_packet, settings );
231
 		container_of ( settings, struct dhcp_packet, settings );
232
 
232
 
233
-	return dhcppkt_applies ( dhcppkt, setting->tag );
233
+	return ( ( setting->scope == NULL ) &&
234
+		 dhcppkt_applies ( dhcppkt, setting->tag ) );
234
 }
235
 }
235
 
236
 
236
 /**
237
 /**
299
 	dhcpopt_init ( &dhcppkt->options, &dhcppkt->dhcphdr->options,
300
 	dhcpopt_init ( &dhcppkt->options, &dhcppkt->dhcphdr->options,
300
 		       ( len - offsetof ( struct dhcphdr, options ) ),
301
 		       ( len - offsetof ( struct dhcphdr, options ) ),
301
 		       dhcpopt_no_realloc );
302
 		       dhcpopt_no_realloc );
302
-	settings_init ( &dhcppkt->settings,
303
-			&dhcppkt_settings_operations, &dhcppkt->refcnt, 0 );
303
+	settings_init ( &dhcppkt->settings, &dhcppkt_settings_operations,
304
+			&dhcppkt->refcnt, NULL );
304
 }
305
 }

+ 0
- 17
src/net/netdev_settings.c View File

39
 	.name = "mac",
39
 	.name = "mac",
40
 	.description = "MAC address",
40
 	.description = "MAC address",
41
 	.type = &setting_type_hex,
41
 	.type = &setting_type_hex,
42
-	.tag = NETDEV_SETTING_TAG_MAC,
43
 };
42
 };
44
 struct setting busid_setting __setting ( SETTING_NETDEV ) = {
43
 struct setting busid_setting __setting ( SETTING_NETDEV ) = {
45
 	.name = "busid",
44
 	.name = "busid",
46
 	.description = "Bus ID",
45
 	.description = "Bus ID",
47
 	.type = &setting_type_hex,
46
 	.type = &setting_type_hex,
48
-	.tag = NETDEV_SETTING_TAG_BUS_ID,
49
 };
47
 };
50
 
48
 
51
-/**
52
- * Check applicability of network device setting
53
- *
54
- * @v settings		Settings block
55
- * @v setting		Setting
56
- * @ret applies		Setting applies within this settings block
57
- */
58
-static int netdev_applies ( struct settings *settings __unused,
59
-			    struct setting *setting ) {
60
-
61
-	return ( IS_NETDEV_SETTING_TAG ( setting->tag ) ||
62
-		 dhcpopt_applies ( setting->tag ) );
63
-}
64
-
65
 /**
49
 /**
66
  * Store value of network device setting
50
  * Store value of network device setting
67
  *
51
  *
134
 
118
 
135
 /** Network device configuration settings operations */
119
 /** Network device configuration settings operations */
136
 struct settings_operations netdev_settings_operations = {
120
 struct settings_operations netdev_settings_operations = {
137
-	.applies = netdev_applies,
138
 	.store = netdev_store,
121
 	.store = netdev_store,
139
 	.fetch = netdev_fetch,
122
 	.fetch = netdev_fetch,
140
 	.clear = netdev_clear,
123
 	.clear = netdev_clear,

Loading…
Cancel
Save