aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2008-01-10 04:30:31 (GMT)
committerJouni Malinen <j@w1.fi>2008-01-10 04:30:31 (GMT)
commit468222ab5d876c9bcae9f5d58621853acf2171b8 (patch)
tree1be80b98765a7a62e45351616a336cc327fc3fa6 /hostapd
parente928131452d59d0b61c1621c3e58cbc013508511 (diff)
downloadhostap-history-468222ab5d876c9bcae9f5d58621853acf2171b8.zip
hostap-history-468222ab5d876c9bcae9f5d58621853acf2171b8.tar.gz
hostap-history-468222ab5d876c9bcae9f5d58621853acf2171b8.tar.bz2
WPS: Added WPS IE handling for Probe Request messages
wpa_supplicant is now adding WPS IE to Probe Request messages if WPS is enabled. hostapd delivers concatenated WPS IE Data fields to WPS Registrar code to process to allow detection of overlapping PBC attempts. The actual collection of active PBC sessions list is not yet included in this commit.
Diffstat (limited to 'hostapd')
-rw-r--r--hostapd/beacon.c17
-rw-r--r--hostapd/wps_hostapd.c50
-rw-r--r--hostapd/wps_hostapd.h7
3 files changed, 67 insertions, 7 deletions
diff --git a/hostapd/beacon.c b/hostapd/beacon.c
index 9348f23..ce1b664 100644
--- a/hostapd/beacon.c
+++ b/hostapd/beacon.c
@@ -27,6 +27,7 @@
#include "driver.h"
#include "sta_info.h"
#include "ieee802_11h.h"
+#include "wps_hostapd.h"
static u8 ieee802_11_erp_info(struct hostapd_data *hapd)
@@ -178,18 +179,20 @@ void handle_probe_req(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
struct ieee80211_mgmt *resp;
struct ieee802_11_elems elems;
char *ssid;
- u8 *pos, *epos;
- size_t ssid_len;
+ u8 *pos, *epos, *ie;
+ size_t ssid_len, ie_len;
struct sta_info *sta = NULL;
+ ie = mgmt->u.probe_req.variable;
+ ie_len = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req));
+
+ hostapd_wps_probe_req_rx(hapd, mgmt->sa, ie, ie_len);
+
if (!hapd->iconf->send_probe_response)
return;
- if (ieee802_11_parse_elems(hapd, mgmt->u.probe_req.variable,
- len - (IEEE80211_HDRLEN +
- sizeof(mgmt->u.probe_req)), &elems,
- 0)
- == ParseFailed) {
+ if (ieee802_11_parse_elems(hapd, ie, ie_len, &elems, 0) == ParseFailed)
+ {
wpa_printf(MSG_DEBUG, "Could not parse ProbeReq from " MACSTR,
MAC2STR(mgmt->sa));
return;
diff --git a/hostapd/wps_hostapd.c b/hostapd/wps_hostapd.c
index adb1a37..916ddb4 100644
--- a/hostapd/wps_hostapd.c
+++ b/hostapd/wps_hostapd.c
@@ -19,6 +19,7 @@
#include "uuid.h"
#include "wpa_ctrl.h"
#include "ctrl_iface.h"
+#include "ieee802_11_defs.h"
#include "wps/wps.h"
#include "wps/wps_defs.h"
#include "wps_hostapd.h"
@@ -260,3 +261,52 @@ int hostapd_wps_button_pushed(struct hostapd_data *hapd)
{
return wps_registrar_button_pushed(hapd->wps_registrar);
}
+
+
+void hostapd_wps_probe_req_rx(struct hostapd_data *hapd, const u8 *addr,
+ const u8 *ie, size_t ie_len)
+{
+ struct wpabuf *wps_ie;
+ const u8 *end, *pos, *wps;
+
+ if (hapd->wps_registrar == NULL)
+ return;
+
+ pos = ie;
+ end = ie + ie_len;
+ wps = NULL;
+
+ while (pos + 1 < end) {
+ if (pos + 2 + pos[1] > end)
+ return;
+ if (pos[0] == WLAN_EID_VENDOR_SPECIFIC && pos[1] >= 4 &&
+ WPA_GET_BE32(&pos[2]) == WPS_DEV_OUI_WFA) {
+ wps = pos;
+ break;
+ }
+ pos += 2 + pos[1];
+ }
+
+ if (wps == NULL)
+ return; /* No WPS IE in Probe Request */
+
+ wps_ie = wpabuf_alloc(ie_len);
+ if (wps_ie == NULL)
+ return;
+
+ /* There may be multiple WPS IEs in the message, so need to concatenate
+ * their WPS Data fields */
+ while (pos + 1 < end) {
+ if (pos + 2 + pos[1] > end)
+ break;
+ if (pos[0] == WLAN_EID_VENDOR_SPECIFIC && pos[1] >= 4 &&
+ WPA_GET_BE32(&pos[2]) == WPS_DEV_OUI_WFA)
+ wpabuf_put_data(wps_ie, pos + 6, pos[1] - 4);
+ pos += 2 + pos[1];
+ }
+
+ if (wpabuf_len(wps_ie) > 0)
+ wps_registrar_probe_req_rx(hapd->wps_registrar, addr, wps_ie);
+
+ wpabuf_free(wps_ie);
+}
diff --git a/hostapd/wps_hostapd.h b/hostapd/wps_hostapd.h
index 621cc82..6615c62 100644
--- a/hostapd/wps_hostapd.h
+++ b/hostapd/wps_hostapd.h
@@ -23,6 +23,8 @@ void hostapd_deinit_wps(struct hostapd_data *hapd);
int hostapd_wps_add_pin(struct hostapd_data *hapd, const char *uuid,
const char *pin);
int hostapd_wps_button_pushed(struct hostapd_data *hapd);
+void hostapd_wps_probe_req_rx(struct hostapd_data *hapd, const u8 *addr,
+ const u8 *ie, size_t ie_len);
#else /* CONFIG_WPS */
@@ -36,6 +38,11 @@ static inline void hostapd_deinit_wps(struct hostapd_data *hapd)
{
}
+static inline void hostapd_wps_probe_req_rx(struct hostapd_data *hapd,
+ const u8 *addr,
+ const u8 *ie, size_t ie_len)
+{
+}
#endif /* CONFIG_WPS */
#endif /* WPS_HOSTAPD_H */