]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS NFC: Allow BSSID and channel to be included in handover select
authorJouni Malinen <jouni@qca.qualcomm.com>
Sat, 27 Apr 2013 17:31:28 +0000 (20:31 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 27 Jan 2014 19:10:55 +0000 (21:10 +0200)
Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/ap/wps_hostapd.c
src/wps/wps.h
src/wps/wps_common.c
src/wps/wps_er.c

index c306ad158d7c9b38114c7885f8c4521095d305df..469ac3e9bde91c81d3a3161041e106ce47da138a 100644 (file)
@@ -1823,7 +1823,8 @@ struct wpabuf * hostapd_wps_nfc_hs_cr(struct hostapd_data *hapd, int ndef)
        }
 
        ret = wps_build_nfc_handover_sel(hapd->wps,
-                                        hapd->conf->wps_nfc_dh_pubkey);
+                                        hapd->conf->wps_nfc_dh_pubkey,
+                                        hapd->own_addr, hapd->iface->freq);
 
        if (ndef && ret) {
                struct wpabuf *tmp;
index 0a4ac55b35880492b5210a3ed7ead6a5762a772f..5ad7725e499301fbcb6210912a7ed073d40783f0 100644 (file)
@@ -866,7 +866,8 @@ struct wpabuf * wps_nfc_token_gen(int ndef, int *id, struct wpabuf **pubkey,
 struct wpabuf * wps_build_nfc_handover_req(struct wps_context *ctx,
                                           struct wpabuf *nfc_dh_pubkey);
 struct wpabuf * wps_build_nfc_handover_sel(struct wps_context *ctx,
-                                          struct wpabuf *nfc_dh_pubkey);
+                                          struct wpabuf *nfc_dh_pubkey,
+                                          const u8 *bssid, int freq);
 
 /* ndef.c */
 struct wpabuf * ndef_parse_wifi(const struct wpabuf *buf);
index 9919f266871ebd36c985f3d34478b361a2c1a161..47fc8de404e96e9d90ebc0fd307e79ee3fac1ea9 100644 (file)
@@ -9,6 +9,8 @@
 #include "includes.h"
 
 #include "common.h"
+#include "common/defs.h"
+#include "common/ieee802_11_common.h"
 #include "crypto/aes_wrap.h"
 #include "crypto/crypto.h"
 #include "crypto/dh_group5.h"
@@ -739,8 +741,38 @@ static int wps_build_ssid(struct wpabuf *msg, struct wps_context *wps)
 }
 
 
+static int wps_build_ap_freq(struct wpabuf *msg, int freq)
+{
+       enum hostapd_hw_mode mode;
+       u8 channel, rf_band;
+       u16 ap_channel;
+
+       if (freq <= 0)
+               return 0;
+
+       mode = ieee80211_freq_to_chan(freq, &channel);
+       if (mode == NUM_HOSTAPD_MODES)
+               return 0; /* Unknown channel */
+
+       if (mode == HOSTAPD_MODE_IEEE80211G || mode == HOSTAPD_MODE_IEEE80211B)
+               rf_band = WPS_RF_24GHZ;
+       else if (mode == HOSTAPD_MODE_IEEE80211A)
+               rf_band = WPS_RF_50GHZ;
+       else
+               return 0; /* Unknown band */
+       ap_channel = channel;
+
+       if (wps_build_rf_bands_attr(msg, rf_band) ||
+           wps_build_ap_channel(msg, ap_channel))
+               return -1;
+
+       return 0;
+}
+
+
 struct wpabuf * wps_build_nfc_handover_sel(struct wps_context *ctx,
-                                          struct wpabuf *nfc_dh_pubkey)
+                                          struct wpabuf *nfc_dh_pubkey,
+                                          const u8 *bssid, int freq)
 {
        struct wpabuf *msg;
        void *len;
@@ -765,6 +797,8 @@ struct wpabuf * wps_build_nfc_handover_sel(struct wps_context *ctx,
        if (wps_build_oob_dev_pw(msg, DEV_PW_NFC_CONNECTION_HANDOVER,
                                 nfc_dh_pubkey, NULL, 0) ||
            wps_build_ssid(msg, ctx) ||
+           wps_build_ap_freq(msg, freq) ||
+           (bssid && wps_build_mac_addr(msg, bssid)) ||
            wps_build_wfa_ext(msg, 0, NULL, 0)) {
                wpabuf_free(msg);
                return NULL;
index f03b0ac884a24f30c8616b571a71f2a7769be796..8e9ee7a5518768ad2e2844707b13a9cdd2afab3f 100644 (file)
@@ -2092,7 +2092,7 @@ struct wpabuf * wps_er_nfc_handover_sel(struct wps_er *er,
        os_memcpy(wps->ssid, ap->ap_settings->ssid, ap->ap_settings->ssid_len);
        wps->ssid_len = ap->ap_settings->ssid_len;
 
-       return wps_build_nfc_handover_sel(wps, pubkey);
+       return wps_build_nfc_handover_sel(wps, pubkey, addr, 0);
 }
 
 #endif /* CONFIG_WPS_NFC */