WPS: Make Config Methods configurable for wpa_supplicant
This adds config_methods configuration option for wpa_supplicant following the design used in hostapd. In addition, the string is now parsed in common code from src/wps/wps_common.c and the list of configurable methods include all the defined methods from WPS 1.0h spec.
This commit is contained in:
parent
b64576fcf5
commit
c0e4dd9eeb
11 changed files with 71 additions and 25 deletions
|
@ -715,5 +715,6 @@ int wps_dev_type_str2bin(const char *str, u8 dev_type[WPS_DEV_TYPE_LEN]);
|
|||
char * wps_dev_type_bin2str(const u8 dev_type[WPS_DEV_TYPE_LEN], char *buf,
|
||||
size_t buf_len);
|
||||
void uuid_gen_mac_addr(const u8 *mac_addr, u8 *uuid);
|
||||
u16 wps_config_methods_str2bin(const char *str);
|
||||
|
||||
#endif /* WPS_H */
|
||||
|
|
|
@ -595,3 +595,42 @@ void uuid_gen_mac_addr(const u8 *mac_addr, u8 *uuid)
|
|||
/* Variant specified in RFC 4122 */
|
||||
uuid[8] = 0x80 | (uuid[8] & 0x3f);
|
||||
}
|
||||
|
||||
|
||||
u16 wps_config_methods_str2bin(const char *str)
|
||||
{
|
||||
u16 methods = 0;
|
||||
|
||||
if (str == NULL) {
|
||||
/* Default to enabling methods based on build configuration */
|
||||
methods |= WPS_CONFIG_LABEL | WPS_CONFIG_DISPLAY |
|
||||
WPS_CONFIG_KEYPAD;
|
||||
#ifdef CONFIG_WPS_UFD
|
||||
methods |= WPS_CONFIG_USBA;
|
||||
#endif /* CONFIG_WPS_UFD */
|
||||
#ifdef CONFIG_WPS_NFC
|
||||
methods |= WPS_CONFIG_NFC_INTERFACE;
|
||||
#endif /* CONFIG_WPS_NFC */
|
||||
} else {
|
||||
if (os_strstr(str, "usba"))
|
||||
methods |= WPS_CONFIG_USBA;
|
||||
if (os_strstr(str, "ethernet"))
|
||||
methods |= WPS_CONFIG_ETHERNET;
|
||||
if (os_strstr(str, "label"))
|
||||
methods |= WPS_CONFIG_LABEL;
|
||||
if (os_strstr(str, "display"))
|
||||
methods |= WPS_CONFIG_DISPLAY;
|
||||
if (os_strstr(str, "ext_nfc_token"))
|
||||
methods |= WPS_CONFIG_EXT_NFC_TOKEN;
|
||||
if (os_strstr(str, "int_nfc_token"))
|
||||
methods |= WPS_CONFIG_INT_NFC_TOKEN;
|
||||
if (os_strstr(str, "nfc_interface"))
|
||||
methods |= WPS_CONFIG_NFC_INTERFACE;
|
||||
if (os_strstr(str, "push_button"))
|
||||
methods |= WPS_CONFIG_PUSHBUTTON;
|
||||
if (os_strstr(str, "keypad"))
|
||||
methods |= WPS_CONFIG_KEYPAD;
|
||||
}
|
||||
|
||||
return methods;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,6 @@ static int wps_build_e_snonce2(struct wps_data *wps, struct wpabuf *msg)
|
|||
static struct wpabuf * wps_build_m1(struct wps_data *wps)
|
||||
{
|
||||
struct wpabuf *msg;
|
||||
u16 methods;
|
||||
|
||||
if (os_get_random(wps->nonce_e, WPS_NONCE_LEN) < 0)
|
||||
return NULL;
|
||||
|
@ -131,16 +130,6 @@ static struct wpabuf * wps_build_m1(struct wps_data *wps)
|
|||
if (msg == NULL)
|
||||
return NULL;
|
||||
|
||||
methods = WPS_CONFIG_LABEL | WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD;
|
||||
#ifdef CONFIG_WPS_UFD
|
||||
methods |= WPS_CONFIG_USBA;
|
||||
#endif /* CONFIG_WPS_UFD */
|
||||
#ifdef CONFIG_WPS_NFC
|
||||
methods |= WPS_CONFIG_NFC_INTERFACE;
|
||||
#endif /* CONFIG_WPS_NFC */
|
||||
if (wps->pbc)
|
||||
methods |= WPS_CONFIG_PUSHBUTTON;
|
||||
|
||||
if (wps_build_version(msg) ||
|
||||
wps_build_msg_type(msg, WPS_M1) ||
|
||||
wps_build_uuid_e(msg, wps->uuid_e) ||
|
||||
|
@ -150,7 +139,7 @@ static struct wpabuf * wps_build_m1(struct wps_data *wps)
|
|||
wps_build_auth_type_flags(wps, msg) ||
|
||||
wps_build_encr_type_flags(wps, msg) ||
|
||||
wps_build_conn_type_flags(wps, msg) ||
|
||||
wps_build_config_methods(msg, methods) ||
|
||||
wps_build_config_methods(msg, wps->wps->config_methods) ||
|
||||
wps_build_wps_state(wps, msg) ||
|
||||
wps_build_device_attrs(&wps->wps->dev, msg) ||
|
||||
wps_build_rf_bands(&wps->wps->dev, msg) ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue