WPS: Set currently used RF band in RF Bands attribute

According to WSC specification (Ver 2.0.2, section 8.3), RF Bands
attribute should be set to the specific RF band used for the current
message. Add an option to set wanted band in wps_build_rf_bands() and
add a callback to get the current band from wpa_supplicant and hostapd.

Signed-hostap: David Spinadel <david.spinadel@intel.com>
This commit is contained in:
David Spinadel 2013-08-25 10:55:53 +03:00 committed by Jouni Malinen
parent bf83eab553
commit 239abaf2ab
8 changed files with 43 additions and 9 deletions

View file

@ -857,6 +857,15 @@ static void hostapd_wps_event_cb(void *ctx, enum wps_event event,
} }
static int hostapd_wps_rf_band_cb(void *ctx)
{
struct hostapd_data *hapd = ctx;
return hapd->iconf->hw_mode == HOSTAPD_MODE_IEEE80211A ?
WPS_RF_50GHZ : WPS_RF_24GHZ; /* FIX: dualband AP */
}
static void hostapd_wps_clear_ies(struct hostapd_data *hapd) static void hostapd_wps_clear_ies(struct hostapd_data *hapd)
{ {
wpabuf_free(hapd->wps_beacon_ie); wpabuf_free(hapd->wps_beacon_ie);
@ -964,6 +973,7 @@ int hostapd_init_wps(struct hostapd_data *hapd,
wps->cred_cb = hostapd_wps_cred_cb; wps->cred_cb = hostapd_wps_cred_cb;
wps->event_cb = hostapd_wps_event_cb; wps->event_cb = hostapd_wps_event_cb;
wps->rf_band_cb = hostapd_wps_rf_band_cb;
wps->cb_ctx = hapd; wps->cb_ctx = hapd;
os_memset(&cfg, 0, sizeof(cfg)); os_memset(&cfg, 0, sizeof(cfg));

View file

@ -497,7 +497,7 @@ struct wpabuf * wps_build_probe_req_ie(u16 pw_id, struct wps_device_data *dev,
wps_build_config_methods(ie, dev->config_methods) || wps_build_config_methods(ie, dev->config_methods) ||
wps_build_uuid_e(ie, uuid) || wps_build_uuid_e(ie, uuid) ||
wps_build_primary_dev_type(dev, ie) || wps_build_primary_dev_type(dev, ie) ||
wps_build_rf_bands(dev, ie) || wps_build_rf_bands(dev, ie, 0) ||
wps_build_assoc_state(NULL, ie) || wps_build_assoc_state(NULL, ie) ||
wps_build_config_error(ie, WPS_CFG_NO_ERROR) || wps_build_config_error(ie, WPS_CFG_NO_ERROR) ||
wps_build_dev_password_id(ie, pw_id) || wps_build_dev_password_id(ie, pw_id) ||

View file

@ -745,6 +745,13 @@ struct wps_context {
void (*event_cb)(void *ctx, enum wps_event event, void (*event_cb)(void *ctx, enum wps_event event,
union wps_event_data *data); union wps_event_data *data);
/**
* rf_band_cb - Fetch currently used RF band
* @ctx: Higher layer context data (cb_ctx)
* Return: Current used RF band or 0 if not known
*/
int (*rf_band_cb)(void *ctx);
/** /**
* cb_ctx: Higher layer context data for callbacks * cb_ctx: Higher layer context data for callbacks
*/ */

View file

@ -217,12 +217,13 @@ int wps_build_vendor_ext_m1(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,
u8 rf_band)
{ {
wpa_printf(MSG_DEBUG, "WPS: * RF Bands (%x)", dev->rf_bands); wpa_printf(MSG_DEBUG, "WPS: * RF Bands (%x)", dev->rf_bands);
wpabuf_put_be16(msg, ATTR_RF_BANDS); wpabuf_put_be16(msg, ATTR_RF_BANDS);
wpabuf_put_be16(msg, 1); wpabuf_put_be16(msg, 1);
wpabuf_put_u8(msg, dev->rf_bands); wpabuf_put_u8(msg, rf_band ? rf_band : dev->rf_bands);
return 0; return 0;
} }

View file

@ -18,7 +18,8 @@ int wps_build_dev_name(struct wps_device_data *dev, struct wpabuf *msg);
int wps_build_device_attrs(struct wps_device_data *dev, struct wpabuf *msg); 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_os_version(struct wps_device_data *dev, struct wpabuf *msg);
int wps_build_vendor_ext_m1(struct wps_device_data *dev, struct wpabuf *msg); int wps_build_vendor_ext_m1(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,
u8 rf_band);
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, int wps_build_secondary_dev_type(struct wps_device_data *dev,

View file

@ -148,7 +148,8 @@ static struct wpabuf * wps_build_m1(struct wps_data *wps)
wps_build_config_methods(msg, config_methods) || wps_build_config_methods(msg, config_methods) ||
wps_build_wps_state(wps, msg) || wps_build_wps_state(wps, msg) ||
wps_build_device_attrs(&wps->wps->dev, msg) || wps_build_device_attrs(&wps->wps->dev, msg) ||
wps_build_rf_bands(&wps->wps->dev, msg) || wps_build_rf_bands(&wps->wps->dev, msg,
wps->wps->rf_band_cb(wps->wps->cb_ctx)) ||
wps_build_assoc_state(wps, msg) || wps_build_assoc_state(wps, msg) ||
wps_build_dev_password_id(msg, wps->dev_pw_id) || wps_build_dev_password_id(msg, wps->dev_pw_id) ||
wps_build_config_error(msg, WPS_CFG_NO_ERROR) || wps_build_config_error(msg, WPS_CFG_NO_ERROR) ||

View file

@ -1265,7 +1265,7 @@ static int wps_set_ie(struct wps_registrar *reg)
wps_build_sel_reg_dev_password_id(reg, beacon) || wps_build_sel_reg_dev_password_id(reg, beacon) ||
wps_build_sel_reg_config_methods(reg, beacon) || wps_build_sel_reg_config_methods(reg, beacon) ||
wps_build_sel_pbc_reg_uuid_e(reg, beacon) || wps_build_sel_pbc_reg_uuid_e(reg, beacon) ||
(reg->dualband && wps_build_rf_bands(&reg->wps->dev, beacon)) || (reg->dualband && wps_build_rf_bands(&reg->wps->dev, beacon, 0)) ||
wps_build_wfa_ext(beacon, 0, auth_macs, count) || wps_build_wfa_ext(beacon, 0, auth_macs, count) ||
wps_build_vendor_ext(&reg->wps->dev, beacon)) { wps_build_vendor_ext(&reg->wps->dev, beacon)) {
wpabuf_free(beacon); wpabuf_free(beacon);
@ -1295,7 +1295,7 @@ static int wps_set_ie(struct wps_registrar *reg)
wps_build_uuid_e(probe, reg->wps->uuid) || wps_build_uuid_e(probe, reg->wps->uuid) ||
wps_build_device_attrs(&reg->wps->dev, probe) || wps_build_device_attrs(&reg->wps->dev, probe) ||
wps_build_probe_config_methods(reg, probe) || wps_build_probe_config_methods(reg, probe) ||
(reg->dualband && wps_build_rf_bands(&reg->wps->dev, probe)) || (reg->dualband && wps_build_rf_bands(&reg->wps->dev, probe, 0)) ||
wps_build_wfa_ext(probe, 0, auth_macs, count) || wps_build_wfa_ext(probe, 0, auth_macs, count) ||
wps_build_vendor_ext(&reg->wps->dev, probe)) { wps_build_vendor_ext(&reg->wps->dev, probe)) {
wpabuf_free(beacon); wpabuf_free(beacon);
@ -1790,7 +1790,8 @@ static struct wpabuf * wps_build_m2(struct wps_data *wps)
wps_build_conn_type_flags(wps, msg) || wps_build_conn_type_flags(wps, msg) ||
wps_build_config_methods_r(wps->wps->registrar, msg) || wps_build_config_methods_r(wps->wps->registrar, msg) ||
wps_build_device_attrs(&wps->wps->dev, msg) || wps_build_device_attrs(&wps->wps->dev, msg) ||
wps_build_rf_bands(&wps->wps->dev, msg) || wps_build_rf_bands(&wps->wps->dev, msg,
wps->wps->rf_band_cb(wps->wps->cb_ctx)) ||
wps_build_assoc_state(wps, msg) || wps_build_assoc_state(wps, msg) ||
wps_build_config_error(msg, WPS_CFG_NO_ERROR) || wps_build_config_error(msg, WPS_CFG_NO_ERROR) ||
wps_build_dev_password_id(msg, wps->dev_pw_id) || wps_build_dev_password_id(msg, wps->dev_pw_id) ||
@ -1831,7 +1832,8 @@ static struct wpabuf * wps_build_m2d(struct wps_data *wps)
wps_build_conn_type_flags(wps, msg) || wps_build_conn_type_flags(wps, msg) ||
wps_build_config_methods_r(wps->wps->registrar, msg) || wps_build_config_methods_r(wps->wps->registrar, msg) ||
wps_build_device_attrs(&wps->wps->dev, msg) || wps_build_device_attrs(&wps->wps->dev, msg) ||
wps_build_rf_bands(&wps->wps->dev, msg) || wps_build_rf_bands(&wps->wps->dev, msg,
wps->wps->rf_band_cb(wps->wps->cb_ctx)) ||
wps_build_assoc_state(wps, msg) || wps_build_assoc_state(wps, msg) ||
wps_build_config_error(msg, err) || wps_build_config_error(msg, err) ||
wps_build_os_version(&wps->wps->dev, msg) || wps_build_os_version(&wps->wps->dev, msg) ||

View file

@ -856,6 +856,17 @@ static void wpa_supplicant_wps_event(void *ctx, enum wps_event event,
} }
static int wpa_supplicant_wps_rf_band(void *ctx)
{
struct wpa_supplicant *wpa_s = ctx;
if (!wpa_s->current_ssid || !wpa_s->assoc_freq)
return 0;
return (wpa_s->assoc_freq > 2484) ? WPS_RF_50GHZ : WPS_RF_24GHZ;
}
enum wps_request_type wpas_wps_get_req_type(struct wpa_ssid *ssid) enum wps_request_type wpas_wps_get_req_type(struct wpa_ssid *ssid)
{ {
if (eap_is_wps_pbc_enrollee(&ssid->eap) || if (eap_is_wps_pbc_enrollee(&ssid->eap) ||
@ -1327,6 +1338,7 @@ int wpas_wps_init(struct wpa_supplicant *wpa_s)
wps->cred_cb = wpa_supplicant_wps_cred; wps->cred_cb = wpa_supplicant_wps_cred;
wps->event_cb = wpa_supplicant_wps_event; wps->event_cb = wpa_supplicant_wps_event;
wps->rf_band_cb = wpa_supplicant_wps_rf_band;
wps->cb_ctx = wpa_s; wps->cb_ctx = wpa_s;
wps->dev.device_name = wpa_s->conf->device_name; wps->dev.device_name = wpa_s->conf->device_name;