Browse Source

Add flag indicating which global configuration parameters have changed

Jouni Malinen 14 years ago
parent
commit
1d47214aa9
2 changed files with 43 additions and 27 deletions
  1. 31 27
      wpa_supplicant/config.c
  2. 12 0
      wpa_supplicant/config.h

+ 31 - 27
wpa_supplicant/config.c

@@ -2173,6 +2173,7 @@ struct global_parse_data {
 	int (*parser)(const struct global_parse_data *data,
 		      struct wpa_config *config, int line, const char *value);
 	void *param1, *param2, *param3;
+	unsigned int changed_flag;
 };
 
 
@@ -2326,38 +2327,38 @@ static int wpa_config_process_os_version(const struct global_parse_data *data,
 
 static const struct global_parse_data global_fields[] = {
 #ifdef CONFIG_CTRL_IFACE
-	{ STR(ctrl_interface) },
-	{ STR(ctrl_interface_group) } /* deprecated */,
+	{ STR(ctrl_interface), 0 },
+	{ STR(ctrl_interface_group), 0 } /* deprecated */,
 #endif /* CONFIG_CTRL_IFACE */
-	{ INT_RANGE(eapol_version, 1, 2) },
-	{ INT(ap_scan) },
-	{ INT(fast_reauth) },
-	{ STR(opensc_engine_path) },
-	{ STR(pkcs11_engine_path) },
-	{ STR(pkcs11_module_path) },
-	{ STR(driver_param) },
-	{ INT(dot11RSNAConfigPMKLifetime) },
-	{ INT(dot11RSNAConfigPMKReauthThreshold) },
-	{ INT(dot11RSNAConfigSATimeout) },
+	{ INT_RANGE(eapol_version, 1, 2), 0 },
+	{ INT(ap_scan), 0 },
+	{ INT(fast_reauth), 0 },
+	{ STR(opensc_engine_path), 0 },
+	{ STR(pkcs11_engine_path), 0 },
+	{ STR(pkcs11_module_path), 0 },
+	{ STR(driver_param), 0 },
+	{ INT(dot11RSNAConfigPMKLifetime), 0 },
+	{ INT(dot11RSNAConfigPMKReauthThreshold), 0 },
+	{ INT(dot11RSNAConfigSATimeout), 0 },
 #ifndef CONFIG_NO_CONFIG_WRITE
-	{ INT(update_config) },
+	{ INT(update_config), 0 },
 #endif /* CONFIG_NO_CONFIG_WRITE */
-	{ FUNC_NO_VAR(load_dynamic_eap) },
+	{ FUNC_NO_VAR(load_dynamic_eap), 0 },
 #ifdef CONFIG_WPS
-	{ FUNC(uuid) },
-	{ STR_RANGE(device_name, 0, 32) },
-	{ STR_RANGE(manufacturer, 0, 64) },
-	{ STR_RANGE(model_name, 0, 32) },
-	{ STR_RANGE(model_number, 0, 32) },
-	{ STR_RANGE(serial_number, 0, 32) },
-	{ STR(device_type) },
-	{ FUNC(os_version) },
-	{ STR(config_methods) },
-	{ INT_RANGE(wps_cred_processing, 0, 2) },
+	{ FUNC(uuid), CFG_CHANGED_UUID },
+	{ STR_RANGE(device_name, 0, 32), CFG_CHANGED_DEVICE_NAME },
+	{ STR_RANGE(manufacturer, 0, 64), 0 },
+	{ STR_RANGE(model_name, 0, 32), 0 },
+	{ STR_RANGE(model_number, 0, 32), 0 },
+	{ STR_RANGE(serial_number, 0, 32), 0 },
+	{ STR(device_type), CFG_CHANGED_DEVICE_TYPE },
+	{ FUNC(os_version), CFG_CHANGED_OS_VERSION },
+	{ STR(config_methods), CFG_CHANGED_CONFIG_METHODS },
+	{ INT_RANGE(wps_cred_processing, 0, 2), 0 },
 #endif /* CONFIG_WPS */
-	{ FUNC(country) },
-	{ INT(bss_max_count) },
-	{ INT_RANGE(filter_ssids, 0, 1) }
+	{ FUNC(country), CFG_CHANGED_COUNTRY },
+	{ INT(bss_max_count), 0 },
+	{ INT_RANGE(filter_ssids, 0, 1), 0 }
 };
 
 #undef FUNC
@@ -2387,9 +2388,12 @@ int wpa_config_process_global(struct wpa_config *config, char *pos, int line)
 				   "parse '%s'.", line, pos);
 			ret = -1;
 		}
+		config->changed_parameters |= field->changed_flag;
 		break;
 	}
 	if (i == NUM_GLOBAL_FIELDS) {
+		if (line < 0)
+			return -1;
 		wpa_printf(MSG_ERROR, "Line %d: unknown global field '%s'.",
 			   line, pos);
 		ret = -1;

+ 12 - 0
wpa_supplicant/config.h

@@ -27,6 +27,13 @@
 #include "config_ssid.h"
 
 
+#define CFG_CHANGED_DEVICE_NAME BIT(0)
+#define CFG_CHANGED_CONFIG_METHODS BIT(1)
+#define CFG_CHANGED_DEVICE_TYPE BIT(2)
+#define CFG_CHANGED_OS_VERSION BIT(3)
+#define CFG_CHANGED_UUID BIT(4)
+#define CFG_CHANGED_COUNTRY BIT(5)
+
 /**
  * struct wpa_config - wpa_supplicant configuration data
  *
@@ -348,6 +355,11 @@ struct wpa_config {
 	 *   1 = only include configured SSIDs in scan results/BSS table
 	 */
 	int filter_ssids;
+
+	/**
+	 * changed_parameters - Bitmap of changed parameters since last update
+	 */
+	unsigned int changed_parameters;
 };