Pārlūkot izejas kodu

[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 gadus atpakaļ
vecāks
revīzija
15d2f947f5

+ 1
- 1
src/arch/i386/interface/vmware/guestinfo.c Parādīt failu

@@ -224,7 +224,7 @@ static int guestinfo_net_probe ( struct net_device *netdev ) {
224 224
 		rc = -ENOMEM;
225 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 229
 	/* Register settings */
230 230
 	if ( ( rc = register_settings ( settings, netdev_settings ( netdev ),

+ 4
- 2
src/core/nvo.c Parādīt failu

@@ -195,7 +195,8 @@ static int nvo_save ( struct nvo_block *nvo ) {
195 195
 int nvo_applies ( struct settings *settings __unused,
196 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,7 +275,8 @@ void nvo_init ( struct nvo_block *nvo, struct nvs_device *nvs,
274 275
 	nvo->len = len;
275 276
 	nvo->resize = resize;
276 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 Parādīt failu

@@ -984,7 +984,7 @@ void clear_settings ( struct settings *settings ) {
984 984
 int setting_cmp ( struct setting *a, struct setting *b ) {
985 985
 
986 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 988
 		return 0;
989 989
 
990 990
 	/* Otherwise, if the settings have names, compare them */
@@ -1099,19 +1099,17 @@ struct setting * find_setting ( const char *name ) {
1099 1099
 /**
1100 1100
  * Parse setting name as tag number
1101 1101
  *
1102
- * @v settings		Settings block
1103 1102
  * @v name		Name
1104 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 1106
 	char *tmp = ( ( char * ) name );
1109 1107
 	unsigned int tag = 0;
1110 1108
 
1111 1109
 	while ( 1 ) {
1112 1110
 		tag = ( ( tag << 8 ) | strtoul ( tmp, &tmp, 0 ) );
1113 1111
 		if ( *tmp == 0 )
1114
-			return ( tag | settings->tag_magic );
1112
+			return tag;
1115 1113
 		if ( *tmp != '.' )
1116 1114
 			return 0;
1117 1115
 		tmp++;
@@ -1193,7 +1191,8 @@ parse_setting_name ( const char *name,
1193 1191
 	}
1194 1192
 
1195 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 1196
 	setting->name = setting_name;
1198 1197
 	for_each_table_entry ( named_setting, SETTINGS ) {
1199 1198
 		/* Matches a defined named setting; use that setting */
@@ -1998,26 +1997,15 @@ struct builtin_setting_operation {
1998 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 2003
 /** Error number setting */
2016 2004
 struct setting errno_setting __setting ( SETTING_MISC ) = {
2017 2005
 	.name = "errno",
2018 2006
 	.description = "Last error",
2019
-	.tag = BUILTIN_SETTING_TAG_ERRNO,
2020 2007
 	.type = &setting_type_uint32,
2008
+	.scope = &builtin_scope,
2021 2009
 };
2022 2010
 
2023 2011
 /**
@@ -2038,15 +2026,12 @@ static int errno_fetch ( void *data, size_t len ) {
2038 2026
 	return sizeof ( content );
2039 2027
 }
2040 2028
 
2041
-/** "buildarch" setting tag */
2042
-#define BUILTIN_SETTING_TAG_BUILDARCH BUILTIN_SETTING_TAG ( 0x02 )
2043
-
2044 2029
 /** Build architecture setting */
2045 2030
 struct setting buildarch_setting __setting ( SETTING_MISC ) = {
2046 2031
 	.name = "buildarch",
2047 2032
 	.description = "Build architecture",
2048
-	.tag = BUILTIN_SETTING_TAG_BUILDARCH,
2049 2033
 	.type = &setting_type_string,
2034
+	.scope = &builtin_scope,
2050 2035
 };
2051 2036
 
2052 2037
 /**
@@ -2063,15 +2048,12 @@ static int buildarch_fetch ( void *data, size_t len ) {
2063 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 2051
 /** Platform setting */
2070 2052
 struct setting platform_setting __setting ( SETTING_MISC ) = {
2071 2053
 	.name = "platform",
2072 2054
 	.description = "Platform",
2073
-	.tag = BUILTIN_SETTING_TAG_PLATFORM,
2074 2055
 	.type = &setting_type_string,
2056
+	.scope = &builtin_scope,
2075 2057
 };
2076 2058
 
2077 2059
 /**
@@ -2128,11 +2110,8 @@ static int builtin_fetch ( struct settings *settings __unused,
2128 2110
  */
2129 2111
 static int builtin_applies ( struct settings *settings __unused,
2130 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 2117
 /** Built-in settings operations */
@@ -2144,7 +2123,6 @@ static struct settings_operations builtin_settings_operations = {
2144 2123
 /** Built-in settings */
2145 2124
 static struct settings builtin_settings = {
2146 2125
 	.refcnt = NULL,
2147
-	.tag_magic = BUILTIN_SETTING_TAG ( 0 ),
2148 2126
 	.siblings = LIST_HEAD_INIT ( builtin_settings.siblings ),
2149 2127
 	.children = LIST_HEAD_INIT ( builtin_settings.children ),
2150 2128
 	.op = &builtin_settings_operations,

+ 5
- 8
src/drivers/net/phantom/phantom.c Parādīt failu

@@ -1454,11 +1454,8 @@ static struct net_device_operations phantom_operations = {
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 1460
 /** Phantom CLP data
1464 1461
  *
@@ -1689,8 +1686,8 @@ phantom_clp_setting ( struct phantom_nic *phantom, struct setting *setting ) {
1689 1686
 	}
1690 1687
 
1691 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 1692
 	DBGC2 ( phantom, "Phantom %p has no \"%s\" setting\n",
1696 1693
 		phantom, setting->name );
@@ -2075,7 +2072,7 @@ static int phantom_probe ( struct pci_device *pci ) {
2075 2072
 	assert ( phantom->port < PHN_MAX_NUM_PORTS );
2076 2073
 	settings_init ( &phantom->settings,
2077 2074
 			&phantom_settings_operations,
2078
-			&netdev->refcnt, PHN_CLP_TAG_MAGIC );
2075
+			&netdev->refcnt, &phantom_settings_scope );
2079 2076
 
2080 2077
 	/* Fix up PCI device */
2081 2078
 	adjust_pci_device ( pci );

+ 0
- 21
src/include/ipxe/net80211.h Parādīt failu

@@ -1183,25 +1183,4 @@ static inline u16 net80211_cts_duration ( struct net80211_device *dev,
1183 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 1186
 #endif

+ 0
- 32
src/include/ipxe/netdevice.h Parādīt failu

@@ -411,38 +411,6 @@ struct net_driver {
411 411
 /** Declare a network driver */
412 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 414
 extern struct list_head net_devices;
447 415
 extern struct net_device_operations null_netdev_operations;
448 416
 extern struct settings_operations netdev_settings_operations;

+ 46
- 29
src/include/ipxe/settings.h Parādīt failu

@@ -38,27 +38,14 @@ struct setting {
38 38
 	 * The setting tag is a numerical description of the setting
39 39
 	 * (such as a DHCP option number, or an SMBIOS structure and
40 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 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 51
 /** Configuration setting table */
@@ -134,12 +121,6 @@ struct settings {
134 121
 	struct refcnt *refcnt;
135 122
 	/** Name */
136 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 124
 	/** Parent settings block */
144 125
 	struct settings *parent;
145 126
 	/** Sibling settings blocks */
@@ -148,8 +129,44 @@ struct settings {
148 129
 	struct list_head children;
149 130
 	/** Settings block operations */
150 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 171
  * A setting type
155 172
  *
@@ -329,17 +346,17 @@ extern struct setting busid_setting __setting ( SETTING_NETDEV );
329 346
  * @v settings		Settings block
330 347
  * @v op		Settings block operations
331 348
  * @v refcnt		Containing object reference counter, or NULL
332
- * @v tag_magic		Tag magic
349
+ * @v default_scope	Default scope
333 350
  */
334 351
 static inline void settings_init ( struct settings *settings,
335 352
 				   struct settings_operations *op,
336 353
 				   struct refcnt *refcnt,
337
-				   unsigned int tag_magic ) {
354
+				   struct settings_scope *default_scope ) {
338 355
 	INIT_LIST_HEAD ( &settings->siblings );
339 356
 	INIT_LIST_HEAD ( &settings->children );
340 357
 	settings->op = op;
341 358
 	settings->refcnt = refcnt;
342
-	settings->tag_magic = tag_magic;
359
+	settings->default_scope = default_scope;
343 360
 }
344 361
 
345 362
 /**
@@ -351,7 +368,7 @@ static inline void settings_init ( struct settings *settings,
351 368
 static inline void generic_settings_init ( struct generic_settings *generics,
352 369
 					   struct refcnt *refcnt ) {
353 370
 	settings_init ( &generics->settings, &generic_settings_operations,
354
-			refcnt, 0 );
371
+			refcnt, NULL );
355 372
 	INIT_LIST_HEAD ( &generics->list );
356 373
 }
357 374
 

+ 11
- 21
src/interface/smbios/smbios_settings.c Parādīt failu

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

+ 0
- 3
src/net/80211/net80211.c Parādīt failu

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

+ 4
- 3
src/net/dhcppkt.c Parādīt failu

@@ -230,7 +230,8 @@ static int dhcppkt_settings_applies ( struct settings *settings,
230 230
 	struct dhcp_packet *dhcppkt =
231 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,6 +300,6 @@ void dhcppkt_init ( struct dhcp_packet *dhcppkt, struct dhcphdr *data,
299 300
 	dhcpopt_init ( &dhcppkt->options, &dhcppkt->dhcphdr->options,
300 301
 		       ( len - offsetof ( struct dhcphdr, options ) ),
301 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 Parādīt failu

@@ -39,29 +39,13 @@ struct setting mac_setting __setting ( SETTING_NETDEV ) = {
39 39
 	.name = "mac",
40 40
 	.description = "MAC address",
41 41
 	.type = &setting_type_hex,
42
-	.tag = NETDEV_SETTING_TAG_MAC,
43 42
 };
44 43
 struct setting busid_setting __setting ( SETTING_NETDEV ) = {
45 44
 	.name = "busid",
46 45
 	.description = "Bus ID",
47 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 50
  * Store value of network device setting
67 51
  *
@@ -134,7 +118,6 @@ static void netdev_clear ( struct settings *settings ) {
134 118
 
135 119
 /** Network device configuration settings operations */
136 120
 struct settings_operations netdev_settings_operations = {
137
-	.applies = netdev_applies,
138 121
 	.store = netdev_store,
139 122
 	.fetch = netdev_fetch,
140 123
 	.clear = netdev_clear,

Notiek ielāde…
Atcelt
Saglabāt