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);
#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"
}
+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;
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;
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 */