From patchwork Thu Mar 20 08:38:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 332033 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 74B812C00A2 for ; Thu, 20 Mar 2014 19:36:49 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 892D39D2D0; Thu, 20 Mar 2014 04:36:40 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yyYQrvnSWJo0; Thu, 20 Mar 2014 04:36:40 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id E05449D2B8; Thu, 20 Mar 2014 04:36:23 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 8CBBB9D2B0 for ; Thu, 20 Mar 2014 04:36:22 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nTYqMkYHc0oB for ; Thu, 20 Mar 2014 04:36:17 -0400 (EDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2C2AB9D2B1 for ; Thu, 20 Mar 2014 04:36:17 -0400 (EDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 20 Mar 2014 01:36:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,693,1389772800"; d="scan'208";a="502616824" Received: from dspinade-left.jer.intel.com (HELO ipeer-e6430-1.jer.intel.com) ([10.12.217.170]) by fmsmga002.fm.intel.com with ESMTP; 20 Mar 2014 01:35:34 -0700 From: Ilan Peer To: hostap@lists.shmoo.com Subject: [RFC 1/3] config: separate global configuration fields Date: Thu, 20 Mar 2014 10:38:23 +0200 Message-Id: <1395304705-4661-2-git-send-email-ilan.peer@intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1395304705-4661-1-git-send-email-ilan.peer@intel.com> References: <1395304705-4661-1-git-send-email-ilan.peer@intel.com> X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com 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 --- 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; +} +