diff options
author | Jouni Malinen <jouni.malinen@atheros.com> | 2009-11-26 11:39:29 +0200 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2009-11-26 11:39:29 +0200 |
commit | 96750ea5e549a3c6ae9b6b8114b43408ae5705aa (patch) | |
tree | b55191b4650f27a48e28fc7f5f97b6ce2ad7bb44 /wpa_supplicant | |
parent | 8e2c104fa148c02da21fd87712a697ba6522a8b4 (diff) | |
download | external_wpa_supplicant_8_ti-96750ea5e549a3c6ae9b6b8114b43408ae5705aa.zip external_wpa_supplicant_8_ti-96750ea5e549a3c6ae9b6b8114b43408ae5705aa.tar.gz external_wpa_supplicant_8_ti-96750ea5e549a3c6ae9b6b8114b43408ae5705aa.tar.bz2 |
WPS: Clean up Primary Device Type handling
Use shared functions for converting Primary Device Type between binary
and string formats. In addition, use array of eight octets instead of a
specific structure with multiple fields to reduce code complexity.
Diffstat (limited to 'wpa_supplicant')
-rw-r--r-- | wpa_supplicant/wps_supplicant.c | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c index dc989d9..f5a96b1 100644 --- a/wpa_supplicant/wps_supplicant.c +++ b/wpa_supplicant/wps_supplicant.c @@ -797,15 +797,17 @@ static void wpas_wps_pin_needed_cb(void *ctx, const u8 *uuid_e, { char uuid[40], txt[400]; int len; + char devtype[WPS_DEV_TYPE_BUFSIZE]; if (uuid_bin2str(uuid_e, uuid, sizeof(uuid))) return; wpa_printf(MSG_DEBUG, "WPS: PIN needed for UUID-E %s", uuid); len = os_snprintf(txt, sizeof(txt), "WPS-EVENT-PIN-NEEDED %s " MACSTR - " [%s|%s|%s|%s|%s|%d-%08X-%d]", + " [%s|%s|%s|%s|%s|%s]", uuid, MAC2STR(dev->mac_addr), dev->device_name, dev->manufacturer, dev->model_name, dev->model_number, dev->serial_number, - dev->categ, dev->oui, dev->sub_categ); + wps_dev_type_bin2str(dev->pri_dev_type, devtype, + sizeof(devtype))); if (len > 0 && len < (int) sizeof(txt)) wpa_printf(MSG_INFO, "%s", txt); } @@ -843,32 +845,12 @@ int wpas_wps_init(struct wpa_supplicant *wpa_s) wps->dev.model_name = wpa_s->conf->model_name; wps->dev.model_number = wpa_s->conf->model_number; wps->dev.serial_number = wpa_s->conf->serial_number; - if (wpa_s->conf->device_type) { - char *pos; - u8 oui[4]; - /* <categ>-<OUI>-<subcateg> */ - wps->dev.categ = atoi(wpa_s->conf->device_type); - pos = os_strchr(wpa_s->conf->device_type, '-'); - if (pos == NULL) { - wpa_printf(MSG_ERROR, "WPS: Invalid device_type"); - os_free(wps); - return -1; - } - pos++; - if (hexstr2bin(pos, oui, 4)) { - wpa_printf(MSG_ERROR, "WPS: Invalid device_type OUI"); - os_free(wps); - return -1; - } - wps->dev.oui = WPA_GET_BE32(oui); - pos = os_strchr(pos, '-'); - if (pos == NULL) { - wpa_printf(MSG_ERROR, "WPS: Invalid device_type"); - os_free(wps); - return -1; - } - pos++; - wps->dev.sub_categ = atoi(pos); + if (wpa_s->conf->device_type && + wps_dev_type_str2bin(wpa_s->conf->device_type, + wps->dev.pri_dev_type) < 0) { + wpa_printf(MSG_ERROR, "WPS: Invalid device_type"); + os_free(wps); + return -1; } wps->dev.os_version = WPA_GET_BE32(wpa_s->conf->os_version); wps->dev.rf_bands = WPS_RF_24GHZ | WPS_RF_50GHZ; /* TODO: config */ |