WPS: Moved RF Bands processing into wps_dev_attr.c

This allows the RF Bands attribute to be configured and stored.
This commit is contained in:
Jouni Malinen 2008-11-29 12:59:43 +02:00
parent c0d041d9a7
commit 120bd30c34
9 changed files with 38 additions and 30 deletions

View file

@ -432,6 +432,8 @@ int hostapd_init_wps(struct hostapd_data *hapd,
wps->dev.sub_categ = atoi(pos);
}
wps->dev.os_version = WPA_GET_BE32(hapd->conf->os_version);
wps->dev.rf_bands = hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211A ?
WPS_RF_50GHZ : WPS_RF_24GHZ; /* FIX: dualband AP */
if (conf->wpa & WPA_PROTO_RSN) {
if (conf->wpa_key_mgmt & WPA_KEY_MGMT_PSK)

View file

@ -78,6 +78,7 @@ struct wps_device_data {
u32 oui;
u16 sub_categ;
u32 os_version;
u8 rf_bands; /* WPS_RF_* */
};

View file

@ -531,16 +531,6 @@ int wps_build_uuid_e(struct wpabuf *msg, const u8 *uuid)
}
int wps_build_rf_bands(struct wpabuf *msg, u8 rf_bands)
{
wpa_printf(MSG_DEBUG, "WPS: * RF Bands (%x)", rf_bands);
wpabuf_put_be16(msg, ATTR_RF_BANDS);
wpabuf_put_be16(msg, 1);
wpabuf_put_u8(msg, rf_bands);
return 0;
}
int wps_build_dev_password_id(struct wpabuf *msg, u16 id)
{
wpa_printf(MSG_DEBUG, "WPS: * Device Password ID (%d)", id);
@ -616,7 +606,7 @@ struct wpabuf * wps_build_probe_req_ie(int pbc, struct wps_device_data *dev,
wps_build_config_methods(ie, methods) ||
wps_build_uuid_e(ie, uuid) ||
wps_build_primary_dev_type(dev, ie) ||
wps_build_rf_bands(ie, WPS_RF_24GHZ | WPS_RF_50GHZ) ||
wps_build_rf_bands(dev, ie) ||
wps_build_assoc_state(NULL, ie) ||
wps_build_config_error(ie, WPS_CFG_NO_ERROR) ||
wps_build_dev_password_id(ie, pbc ? DEV_PW_PUSHBUTTON :

View file

@ -120,6 +120,16 @@ 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)
{
wpa_printf(MSG_DEBUG, "WPS: * RF Bands (%x)", dev->rf_bands);
wpabuf_put_be16(msg, ATTR_RF_BANDS);
wpabuf_put_be16(msg, 1);
wpabuf_put_u8(msg, dev->rf_bands);
return 0;
}
static int wps_process_manufacturer(struct wps_device_data *dev, const u8 *str,
size_t str_len)
{
@ -280,6 +290,20 @@ int wps_process_os_version(struct wps_device_data *dev, const u8 *ver)
}
int wps_process_rf_bands(struct wps_device_data *dev, const u8 *bands)
{
if (bands == NULL) {
wpa_printf(MSG_DEBUG, "WPS: No RF Bands received");
return -1;
}
dev->rf_bands = *bands;
wpa_printf(MSG_DEBUG, "WPS: Enrollee RF Bands 0x%x", dev->rf_bands);
return 0;
}
void wps_device_data_dup(struct wps_device_data *dst,
const struct wps_device_data *src)
{
@ -297,6 +321,7 @@ void wps_device_data_dup(struct wps_device_data *dst,
dst->oui = src->oui;
dst->sub_categ = src->sub_categ;
dst->os_version = src->os_version;
dst->rf_bands = src->rf_bands;
}

View file

@ -19,11 +19,13 @@ struct wps_parse_attr;
int wps_build_device_attrs(struct wps_device_data *dev, struct wpabuf *msg);
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_primary_dev_type(struct wps_device_data *dev,
struct wpabuf *msg);
int wps_process_device_attrs(struct wps_device_data *dev,
struct wps_parse_attr *attr);
int wps_process_os_version(struct wps_device_data *dev, const u8 *ver);
int wps_process_rf_bands(struct wps_device_data *dev, const u8 *bands);
void wps_device_data_dup(struct wps_device_data *dst,
const struct wps_device_data *src);
void wps_device_data_free(struct wps_device_data *dev);

View file

@ -140,7 +140,7 @@ static struct wpabuf * wps_build_m1(struct wps_data *wps)
wps_build_config_methods(msg, methods) ||
wps_build_wps_state(wps, msg) ||
wps_build_device_attrs(&wps->wps->dev, msg) ||
wps_build_rf_bands(msg, WPS_RF_24GHZ | WPS_RF_50GHZ) ||
wps_build_rf_bands(&wps->wps->dev, msg) ||
wps_build_assoc_state(wps, msg) ||
wps_build_dev_password_id(msg, wps->dev_pw_id) ||
wps_build_config_error(msg, WPS_CFG_NO_ERROR) ||

View file

@ -161,7 +161,6 @@ void wps_kdf(const u8 *key, const u8 *label_prefix, size_t label_prefix_len,
int wps_build_public_key(struct wps_data *wps, struct wpabuf *msg);
int wps_build_config_methods(struct wpabuf *msg, u16 methods);
int wps_build_uuid_e(struct wpabuf *msg, const u8 *uuid);
int wps_build_rf_bands(struct wpabuf *msg, u8 rf_bands);
int wps_build_dev_password_id(struct wpabuf *msg, u16 id);
int wps_build_config_error(struct wpabuf *msg, u16 err);
int wps_derive_keys(struct wps_data *wps);

View file

@ -584,7 +584,7 @@ static int wps_set_ie(struct wps_registrar *reg)
wps_build_uuid_e(probe, reg->wps->uuid) ||
wps_build_device_attrs(&reg->wps->dev, probe) ||
wps_build_probe_config_methods(reg, probe) ||
wps_build_rf_bands(probe, WPS_RF_24GHZ /* TODO:|WPS_RF_50GHZ */)) {
wps_build_rf_bands(&reg->wps->dev, probe)) {
wpabuf_free(beacon);
wpabuf_free(probe);
return -1;
@ -945,7 +945,7 @@ static struct wpabuf * wps_build_m2(struct wps_data *wps)
wps_build_conn_type_flags(wps, msg) ||
wps_build_config_methods_r(wps->registrar, msg) ||
wps_build_device_attrs(&wps->wps->dev, msg) ||
wps_build_rf_bands(msg, WPS_RF_24GHZ /* TODO:|WPS_RF_50GHZ */) ||
wps_build_rf_bands(&wps->wps->dev, msg) ||
wps_build_assoc_state(wps, msg) ||
wps_build_config_error(msg, WPS_CFG_NO_ERROR) ||
wps_build_dev_password_id(msg, DEV_PW_DEFAULT) ||
@ -983,7 +983,7 @@ static struct wpabuf * wps_build_m2d(struct wps_data *wps)
wps_build_conn_type_flags(wps, msg) ||
wps_build_config_methods_r(wps->registrar, msg) ||
wps_build_device_attrs(&wps->wps->dev, msg) ||
wps_build_rf_bands(msg, WPS_RF_24GHZ /* TODO:|WPS_RF_50GHZ */) ||
wps_build_rf_bands(&wps->wps->dev, msg) ||
wps_build_assoc_state(wps, msg) ||
wps_build_config_error(msg, err) ||
wps_build_os_version(&wps->wps->dev, msg)) {
@ -1471,19 +1471,6 @@ static int wps_process_wps_state(struct wps_data *wps, const u8 *state)
}
static int wps_process_rf_bands(struct wps_data *wps, const u8 *bands)
{
if (bands == NULL) {
wpa_printf(MSG_DEBUG, "WPS: No RF Bands received");
return -1;
}
wpa_printf(MSG_DEBUG, "WPS: Enrollee RF Bands 0x%x", *bands);
return 0;
}
static int wps_process_assoc_state(struct wps_data *wps, const u8 *assoc)
{
u16 a;
@ -1537,7 +1524,7 @@ static enum wps_process_res wps_process_m1(struct wps_data *wps,
wps_process_config_methods(wps, attr->config_methods) ||
wps_process_wps_state(wps, attr->wps_state) ||
wps_process_device_attrs(&wps->peer_dev, attr) ||
wps_process_rf_bands(wps, attr->rf_bands) ||
wps_process_rf_bands(&wps->peer_dev, attr->rf_bands) ||
wps_process_assoc_state(wps, attr->assoc_state) ||
wps_process_dev_password_id(wps, attr->dev_password_id) ||
wps_process_config_error(wps, attr->config_error) ||

View file

@ -197,6 +197,8 @@ int wpas_wps_init(struct wpa_supplicant *wpa_s)
wps->dev.categ = WPS_DEV_COMPUTER;
wps->dev.oui = WPS_DEV_OUI_WFA;
wps->dev.sub_categ = WPS_DEV_COMPUTER_PC;
wps->dev.os_version = 0;
wps->dev.rf_bands = WPS_RF_24GHZ | WPS_RF_50GHZ;
os_memcpy(wps->dev.mac_addr, wpa_s->own_addr, ETH_ALEN);
os_memcpy(wps->uuid, wpa_s->conf->uuid, 16);