[RFC 1/3] config: separate global configuration fields
Ilan Peer
ilan.peer
Thu Mar 20 01:38:23 PDT 2014
Split the global configuration fields to:
1. Common fields: global fields that should be common between all
the wpa_supplicant interfaces, i.e., WPS and P2P parameters.
2. Interface specific global fields.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
wpa_supplicant/config.c | 116 +++++++++++++++++++++++++++++------------------
1 file changed, 72 insertions(+), 44 deletions(-)
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 23aab4b..9aa28cb 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -3522,6 +3522,47 @@ static const struct global_parse_data global_fields[] = {
{ INT(update_config), 0 },
#endif /* CONFIG_NO_CONFIG_WRITE */
{ FUNC_NO_VAR(load_dynamic_eap), 0 },
+ { FUNC(country), CFG_CHANGED_COUNTRY },
+ { INT(bss_max_count), 0 },
+ { INT(bss_expiration_age), 0 },
+ { INT(bss_expiration_scan_count), 0 },
+ { INT_RANGE(filter_ssids, 0, 1), 0 },
+ { INT_RANGE(filter_rssi, -100, 0), 0 },
+ { INT(max_num_sta), 0 },
+ { INT_RANGE(disassoc_low_ack, 0, 1), 0 },
+#ifdef CONFIG_HS20
+ { INT_RANGE(hs20, 0, 1), 0 },
+#endif /* CONFIG_HS20 */
+ { INT_RANGE(interworking, 0, 1), 0 },
+ { FUNC(hessid), 0 },
+ { INT_RANGE(access_network_type, 0, 15), 0 },
+ { INT_RANGE(pbc_in_m1, 0, 1), 0 },
+ { STR(autoscan), 0 },
+ { INT_RANGE(wps_nfc_dev_pw_id, 0x10, 0xffff),
+ CFG_CHANGED_NFC_PASSWORD_TOKEN },
+ { BIN(wps_nfc_dh_pubkey), CFG_CHANGED_NFC_PASSWORD_TOKEN },
+ { BIN(wps_nfc_dh_privkey), CFG_CHANGED_NFC_PASSWORD_TOKEN },
+ { BIN(wps_nfc_dev_pw), CFG_CHANGED_NFC_PASSWORD_TOKEN },
+ { STR(ext_password_backend), CFG_CHANGED_EXT_PW_BACKEND },
+ { INT(p2p_go_max_inactivity), 0 },
+ { INT_RANGE(auto_interworking, 0, 1), 0 },
+ { INT(okc), 0 },
+ { INT(pmf), 0 },
+ { FUNC(sae_groups), 0 },
+ { INT(dtim_period), 0 },
+ { INT(beacon_int), 0 },
+ { FUNC(ap_vendor_elements), 0 },
+ { INT_RANGE(ignore_old_scan_res, 0, 1), 0 },
+ { FUNC(freq_list), 0 },
+ { INT(scan_cur_freq), 0 },
+ { INT(sched_scan_interval), 0 },
+ { INT(tdls_external_control), 0},
+ { STR(osu_dir), 0 },
+};
+
+#define NUM_GLOBAL_FIELDS ARRAY_SIZE(global_fields)
+
+static const struct global_parse_data common_fields[] = {
#ifdef CONFIG_WPS
{ FUNC(uuid), CFG_CHANGED_UUID },
{ STR_RANGE(device_name, 0, 32), CFG_CHANGED_DEVICE_NAME },
@@ -3559,44 +3600,10 @@ static const struct global_parse_data global_fields[] = {
{ IPV4(ip_addr_start), 0 },
{ IPV4(ip_addr_end), 0 },
#endif /* CONFIG_P2P */
- { FUNC(country), CFG_CHANGED_COUNTRY },
- { INT(bss_max_count), 0 },
- { INT(bss_expiration_age), 0 },
- { INT(bss_expiration_scan_count), 0 },
- { INT_RANGE(filter_ssids, 0, 1), 0 },
- { INT_RANGE(filter_rssi, -100, 0), 0 },
- { INT(max_num_sta), 0 },
- { INT_RANGE(disassoc_low_ack, 0, 1), 0 },
-#ifdef CONFIG_HS20
- { INT_RANGE(hs20, 0, 1), 0 },
-#endif /* CONFIG_HS20 */
- { INT_RANGE(interworking, 0, 1), 0 },
- { FUNC(hessid), 0 },
- { INT_RANGE(access_network_type, 0, 15), 0 },
- { INT_RANGE(pbc_in_m1, 0, 1), 0 },
- { STR(autoscan), 0 },
- { INT_RANGE(wps_nfc_dev_pw_id, 0x10, 0xffff),
- CFG_CHANGED_NFC_PASSWORD_TOKEN },
- { BIN(wps_nfc_dh_pubkey), CFG_CHANGED_NFC_PASSWORD_TOKEN },
- { BIN(wps_nfc_dh_privkey), CFG_CHANGED_NFC_PASSWORD_TOKEN },
- { BIN(wps_nfc_dev_pw), CFG_CHANGED_NFC_PASSWORD_TOKEN },
- { STR(ext_password_backend), CFG_CHANGED_EXT_PW_BACKEND },
- { INT(p2p_go_max_inactivity), 0 },
- { INT_RANGE(auto_interworking, 0, 1), 0 },
- { INT(okc), 0 },
- { INT(pmf), 0 },
- { FUNC(sae_groups), 0 },
- { INT(dtim_period), 0 },
- { INT(beacon_int), 0 },
- { FUNC(ap_vendor_elements), 0 },
- { INT_RANGE(ignore_old_scan_res, 0, 1), 0 },
- { FUNC(freq_list), 0 },
- { INT(scan_cur_freq), 0 },
- { INT(sched_scan_interval), 0 },
- { INT(tdls_external_control), 0},
- { STR(osu_dir), 0 },
};
+#define NUM_COMMON_FIELDS ARRAY_SIZE(common_fields)
+
#undef FUNC
#undef _INT
#undef INT
@@ -3606,16 +3613,17 @@ static const struct global_parse_data global_fields[] = {
#undef STR_RANGE
#undef BIN
#undef IPV4
-#define NUM_GLOBAL_FIELDS ARRAY_SIZE(global_fields)
-
-int wpa_config_process_global(struct wpa_config *config, char *pos, int line)
+static int wpa_config_process_fields(struct wpa_config *config, char *pos,
+ int line,
+ const struct global_parse_data *fields,
+ size_t num_fields)
{
size_t i;
int ret = 0;
- for (i = 0; i < NUM_GLOBAL_FIELDS; i++) {
- const struct global_parse_data *field = &global_fields[i];
+ for (i = 0; i < num_fields; i++) {
+ const struct global_parse_data *field = &fields[i];
size_t flen = os_strlen(field->name);
if (os_strncmp(pos, field->name, flen) != 0 ||
pos[flen] != '=')
@@ -3631,7 +3639,7 @@ int wpa_config_process_global(struct wpa_config *config, char *pos, int line)
config->changed_parameters |= field->changed_flag;
break;
}
- if (i == NUM_GLOBAL_FIELDS) {
+ if (i == num_fields) {
#ifdef CONFIG_AP
if (os_strncmp(pos, "wmm_ac_", 7) == 0) {
char *tmp = os_strchr(pos, '=');
@@ -3653,10 +3661,30 @@ int wpa_config_process_global(struct wpa_config *config, char *pos, int line)
#endif /* CONFIG_AP */
if (line < 0)
return -1;
- wpa_printf(MSG_ERROR, "Line %d: unknown global field '%s'.",
- line, pos);
ret = -1;
}
return ret;
}
+
+int wpa_config_process_global(struct wpa_config *config, char *pos, int line)
+{
+ int ret;
+
+ ret = wpa_config_process_fields(config, pos, line, global_fields,
+ NUM_GLOBAL_FIELDS);
+
+ if (!ret)
+ return 0;
+
+ ret = wpa_config_process_fields(config, pos, line, common_fields,
+ NUM_COMMON_FIELDS);
+
+ if (ret < 0)
+ wpa_printf(MSG_ERROR,
+ "Line %d: unknown global/common field '%s'.",
+ line, pos);
+
+ return ret;
+}
+
--
1.7.10.4
More information about the Hostap
mailing list