WPS: Add secondary device types into Probe Request frames

The secondary device type list is an optional attribute in the WSC IE.

Signed-off-by: Jean-Michel Bachot <jean-michelx.bachot@linux.intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Jean-Michel Bachot 2011-03-17 11:09:49 +02:00 committed by Jouni Malinen
parent 13579b987b
commit a9e86bfb74
5 changed files with 64 additions and 3 deletions

View file

@ -486,10 +486,9 @@ struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev,
wps_build_model_name(dev, ie) || wps_build_model_name(dev, ie) ||
wps_build_model_number(dev, ie) || wps_build_model_number(dev, ie) ||
wps_build_dev_name(dev, ie) || wps_build_dev_name(dev, ie) ||
wps_build_wfa_ext(ie, req_type == WPS_REQ_ENROLLEE, NULL, 0) wps_build_wfa_ext(ie, req_type == WPS_REQ_ENROLLEE, NULL, 0) ||
#else /* CONFIG_WPS2 */
0
#endif /* CONFIG_WPS2 */ #endif /* CONFIG_WPS2 */
wps_build_secondary_dev_type(dev, ie)
) { ) {
wpabuf_free(ie); wpabuf_free(ie);
return NULL; return NULL;

View file

@ -73,6 +73,8 @@ struct wps_credential {
* @model_number: Model Number (0..32 octets encoded in UTF-8) * @model_number: Model Number (0..32 octets encoded in UTF-8)
* @serial_number: Serial Number (0..32 octets encoded in UTF-8) * @serial_number: Serial Number (0..32 octets encoded in UTF-8)
* @pri_dev_type: Primary Device Type * @pri_dev_type: Primary Device Type
* @sec_dev_type: Array of secondary device types
* @num_sec_dev_type: Number of secondary device types
* @os_version: OS Version * @os_version: OS Version
* @rf_bands: RF bands (WPS_RF_24GHZ, WPS_RF_50GHZ flags) * @rf_bands: RF bands (WPS_RF_24GHZ, WPS_RF_50GHZ flags)
* @p2p: Whether the device is a P2P device * @p2p: Whether the device is a P2P device
@ -85,6 +87,9 @@ struct wps_device_data {
char *model_number; char *model_number;
char *serial_number; char *serial_number;
u8 pri_dev_type[WPS_DEV_TYPE_LEN]; u8 pri_dev_type[WPS_DEV_TYPE_LEN];
#define WPS_SEC_DEVICE_TYPES 5
u8 sec_dev_type[WPS_SEC_DEVICE_TYPES][WPS_DEV_TYPE_LEN];
u8 num_sec_dev_types;
u32 os_version; u32 os_version;
u8 rf_bands; u8 rf_bands;

View file

@ -126,6 +126,22 @@ int wps_build_primary_dev_type(struct wps_device_data *dev, struct wpabuf *msg)
} }
int wps_build_secondary_dev_type(struct wps_device_data *dev,
struct wpabuf *msg)
{
if (!dev->num_sec_dev_types)
return 0;
wpa_printf(MSG_DEBUG, "WPS: * Secondary Device Type");
wpabuf_put_be16(msg, ATTR_SECONDARY_DEV_TYPE_LIST);
wpabuf_put_be16(msg, WPS_DEV_TYPE_LEN * dev->num_sec_dev_types);
wpabuf_put_data(msg, dev->sec_dev_type,
WPS_DEV_TYPE_LEN * dev->num_sec_dev_types);
return 0;
}
int wps_build_dev_name(struct wps_device_data *dev, struct wpabuf *msg) int wps_build_dev_name(struct wps_device_data *dev, struct wpabuf *msg)
{ {
size_t len; size_t len;

View file

@ -26,6 +26,8 @@ int wps_build_os_version(struct wps_device_data *dev, struct wpabuf *msg);
int wps_build_rf_bands(struct wps_device_data *dev, struct wpabuf *msg); int wps_build_rf_bands(struct wps_device_data *dev, struct wpabuf *msg);
int wps_build_primary_dev_type(struct wps_device_data *dev, int wps_build_primary_dev_type(struct wps_device_data *dev,
struct wpabuf *msg); struct wpabuf *msg);
int wps_build_secondary_dev_type(struct wps_device_data *dev,
struct wpabuf *msg);
int wps_build_dev_name(struct wps_device_data *dev, struct wpabuf *msg); int wps_build_dev_name(struct wps_device_data *dev, struct wpabuf *msg);
int wps_process_device_attrs(struct wps_device_data *dev, int wps_process_device_attrs(struct wps_device_data *dev,
struct wps_parse_attr *attr); struct wps_parse_attr *attr);

View file

@ -1067,6 +1067,7 @@ int wpas_wps_init(struct wpa_supplicant *wpa_s)
{ {
struct wps_context *wps; struct wps_context *wps;
struct wps_registrar_config rcfg; struct wps_registrar_config rcfg;
int i;
wps = os_zalloc(sizeof(*wps)); wps = os_zalloc(sizeof(*wps));
if (wps == NULL) if (wps == NULL)
@ -1098,6 +1099,22 @@ int wpas_wps_init(struct wpa_supplicant *wpa_s)
os_free(wps); os_free(wps);
return -1; return -1;
} }
for (i = 0; i < MAX_SEC_DEVICE_TYPES; i++) {
if (wpa_s->conf->sec_device_type[i] == NULL)
continue;
if (wps_dev_type_str2bin(
wpa_s->conf->sec_device_type[i],
wps->dev.sec_dev_type[wps->dev.num_sec_dev_types])
< 0) {
wpa_printf(MSG_ERROR, "WPS: Invalid sec_device_type");
return -1;
}
wps->dev.num_sec_dev_types++;
if (wps->dev.num_sec_dev_types == WPS_SEC_DEVICE_TYPES)
break;
}
wps->dev.os_version = WPA_GET_BE32(wpa_s->conf->os_version); wps->dev.os_version = WPA_GET_BE32(wpa_s->conf->os_version);
wps->dev.rf_bands = WPS_RF_24GHZ | WPS_RF_50GHZ; /* TODO: config */ wps->dev.rf_bands = WPS_RF_24GHZ | WPS_RF_50GHZ; /* TODO: config */
os_memcpy(wps->dev.mac_addr, wpa_s->own_addr, ETH_ALEN); os_memcpy(wps->dev.mac_addr, wpa_s->own_addr, ETH_ALEN);
@ -1644,6 +1661,28 @@ void wpas_wps_update_config(struct wpa_supplicant *wpa_s)
wpa_printf(MSG_ERROR, "WPS: Invalid device_type"); wpa_printf(MSG_ERROR, "WPS: Invalid device_type");
} }
if (wpa_s->conf->changed_parameters & CFG_CHANGED_SEC_DEVICE_TYPE) {
int i;
wps->dev.num_sec_dev_types = 0;
for (i = 0; i < MAX_SEC_DEVICE_TYPES; i++) {
if (wpa_s->conf->sec_device_type[i] == NULL)
continue;
if (wps_dev_type_str2bin(
wpa_s->conf->sec_device_type[i],
wps->dev.sec_dev_type[
wps->dev.num_sec_dev_types]) < 0) {
wpa_printf(MSG_ERROR,
"WPS: Invalid sec_device_type");
continue;
}
wps->dev.num_sec_dev_types++;
if (wps->dev.num_sec_dev_types == WPS_SEC_DEVICE_TYPES)
break;
}
}
if (wpa_s->conf->changed_parameters & CFG_CHANGED_OS_VERSION) if (wpa_s->conf->changed_parameters & CFG_CHANGED_OS_VERSION)
wps->dev.os_version = WPA_GET_BE32(wpa_s->conf->os_version); wps->dev.os_version = WPA_GET_BE32(wpa_s->conf->os_version);