diff options
author | Anirban Sirkhell <anirban@qca.qualcomm.com> | 2012-04-04 00:08:57 +0300 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2012-04-04 00:08:57 +0300 |
commit | 71dd3b78f90a5ca4d5f56966df024c676af177be (patch) | |
tree | 2fc4104d83c6ce9f428633dfaa515dc1d88548a7 /wpa_supplicant | |
parent | 2e9f078c8dde5abfe7025513deb417c679502e99 (diff) | |
download | external_wpa_supplicant_8_ti-71dd3b78f90a5ca4d5f56966df024c676af177be.zip external_wpa_supplicant_8_ti-71dd3b78f90a5ca4d5f56966df024c676af177be.tar.gz external_wpa_supplicant_8_ti-71dd3b78f90a5ca4d5f56966df024c676af177be.tar.bz2 |
WPS: Allow vendor specific attribute to be added into M1
wps_vendor_ext_m1 configuration parameter can now be used to add a
vendor specific attribute into the WPS M1 message, e.g., for
Windows Vertical Pairing.
Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'wpa_supplicant')
-rw-r--r-- | wpa_supplicant/config.c | 39 | ||||
-rw-r--r-- | wpa_supplicant/config.h | 2 | ||||
-rw-r--r-- | wpa_supplicant/config_file.c | 10 | ||||
-rw-r--r-- | wpa_supplicant/wpa_supplicant.conf | 4 | ||||
-rw-r--r-- | wpa_supplicant/wps_supplicant.c | 23 |
5 files changed, 78 insertions, 0 deletions
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index ea0b6f4..2a166c7 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -1835,6 +1835,7 @@ void wpa_config_free(struct wpa_config *config) } #endif /* CONFIG_NO_CONFIG_BLOBS */ + wpabuf_free(config->wps_vendor_ext_m1); os_free(config->ctrl_interface); os_free(config->ctrl_interface_group); os_free(config->opensc_engine_path); @@ -2673,6 +2674,43 @@ static int wpa_config_process_os_version(const struct global_parse_data *data, return 0; } + +static int wpa_config_process_wps_vendor_ext_m1( + const struct global_parse_data *data, + struct wpa_config *config, int line, const char *pos) +{ + struct wpabuf *tmp; + int len = os_strlen(pos) / 2; + u8 *p; + + if (!len) { + wpa_printf(MSG_ERROR, "Line %d: " + "invalid wps_vendor_ext_m1", line); + return -1; + } + + tmp = wpabuf_alloc(len); + if (tmp) { + p = wpabuf_put(tmp, len); + + if (hexstr2bin(pos, p, len)) { + wpa_printf(MSG_ERROR, "Line %d: " + "invalid wps_vendor_ext_m1", line); + wpabuf_free(tmp); + return -1; + } + + wpabuf_free(config->wps_vendor_ext_m1); + config->wps_vendor_ext_m1 = tmp; + } else { + wpa_printf(MSG_ERROR, "Can not allocate " + "memory for wps_vendor_ext_m1"); + return -1; + } + + return 0; +} + #endif /* CONFIG_WPS */ #ifdef CONFIG_P2P @@ -2809,6 +2847,7 @@ static const struct global_parse_data global_fields[] = { { FUNC(os_version), CFG_CHANGED_OS_VERSION }, { STR(config_methods), CFG_CHANGED_CONFIG_METHODS }, { INT_RANGE(wps_cred_processing, 0, 2), 0 }, + { FUNC(wps_vendor_ext_m1), CFG_CHANGED_VENDOR_EXTENSION }, #endif /* CONFIG_WPS */ #ifdef CONFIG_P2P { FUNC(sec_device_type), CFG_CHANGED_SEC_DEVICE_TYPE }, diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index ac4ecfa..9bdc29e 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -507,6 +507,8 @@ struct wpa_config { unsigned int num_p2p_pref_chan; struct p2p_channel *p2p_pref_chan; + struct wpabuf *wps_vendor_ext_m1; + #define MAX_WPS_VENDOR_EXT 10 /** * wps_vendor_ext - Vendor extension attributes in WPS diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index e7f3a7c..e1e3a31 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -768,6 +768,16 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config) if (config->wps_cred_processing) fprintf(f, "wps_cred_processing=%d\n", config->wps_cred_processing); + if (config->wps_vendor_ext_m1) { + int i, len = wpabuf_len(config->wps_vendor_ext_m1); + const u8 *p = wpabuf_head_u8(config->wps_vendor_ext_m1); + if (len > 0) { + fprintf(f, "wps_vendor_ext_m1="); + for (i = 0; i < len; i++) + fprintf(f, "%02x", *p++); + fprintf(f, "\n"); + } + } #endif /* CONFIG_WPS */ #ifdef CONFIG_P2P if (config->p2p_listen_reg_class) diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index fb8ea25..e226954 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -214,6 +214,10 @@ fast_reauth=1 # to external program(s) #wps_cred_processing=0 +# Vendor attribute in WPS M1, e.g., Windows 7 Vertical Pairing +# The vendor attribute contents to be added in M1 (hex string) +#wps_vendor_ext_m1=000137100100020001 + # Maximum number of BSS entries to keep in memory # Default: 200 # This can be used to limit memory use on the BSS entries (cached scan diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c index 4965439..00ce9be 100644 --- a/wpa_supplicant/wps_supplicant.c +++ b/wpa_supplicant/wps_supplicant.c @@ -1130,6 +1130,23 @@ static void wpas_wps_set_uuid(struct wpa_supplicant *wpa_s, } +static void wpas_wps_set_vendor_ext_m1(struct wpa_supplicant *wpa_s, + struct wps_context *wps) +{ + wpabuf_free(wps->dev.vendor_ext_m1); + wps->dev.vendor_ext_m1 = NULL; + + if (wpa_s->conf->wps_vendor_ext_m1) { + wps->dev.vendor_ext_m1 = + wpabuf_dup(wpa_s->conf->wps_vendor_ext_m1); + if (!wps->dev.vendor_ext_m1) { + wpa_printf(MSG_ERROR, "WPS: Cannot " + "allocate memory for vendor_ext_m1"); + } + } +} + + int wpas_wps_init(struct wpa_supplicant *wpa_s) { struct wps_context *wps; @@ -1168,6 +1185,8 @@ int wpas_wps_init(struct wpa_supplicant *wpa_s) os_memcpy(wps->dev.sec_dev_type, wpa_s->conf->sec_device_type, WPS_DEV_TYPE_LEN * wps->dev.num_sec_dev_types); + wpas_wps_set_vendor_ext_m1(wpa_s, wps); + wps->dev.os_version = WPA_GET_BE32(wpa_s->conf->os_version); modes = wpa_s->hw.modes; if (modes) { @@ -1228,6 +1247,7 @@ void wpas_wps_deinit(struct wpa_supplicant *wpa_s) wpabuf_free(wpa_s->wps->dh_privkey); wpabuf_free(wpa_s->wps->oob_conf.pubkey_hash); wpabuf_free(wpa_s->wps->oob_conf.dev_password); + wpabuf_free(wpa_s->wps->dev.vendor_ext_m1); os_free(wpa_s->wps->network_key); os_free(wpa_s->wps); wpa_s->wps = NULL; @@ -1717,6 +1737,9 @@ void wpas_wps_update_config(struct wpa_supplicant *wpa_s) wps->dev.num_sec_dev_types * WPS_DEV_TYPE_LEN); } + if (wpa_s->conf->changed_parameters & CFG_CHANGED_VENDOR_EXTENSION) + wpas_wps_set_vendor_ext_m1(wpa_s, wps); + if (wpa_s->conf->changed_parameters & CFG_CHANGED_OS_VERSION) wps->dev.os_version = WPA_GET_BE32(wpa_s->conf->os_version); |