aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2008-01-13 02:44:02 (GMT)
committerJouni Malinen <j@w1.fi>2008-01-13 02:44:02 (GMT)
commit499f7529e33ad3534a2fc4988ee474e34ba34bb3 (patch)
treee793f49aabc6a22fef2127a06de5ba4e341fcd04 /hostapd
parent519a9cc2cafb6716fc6601dde74d069244a53dc5 (diff)
downloadhostap-history-499f7529e33ad3534a2fc4988ee474e34ba34bb3.zip
hostap-history-499f7529e33ad3534a2fc4988ee474e34ba34bb3.tar.gz
hostap-history-499f7529e33ad3534a2fc4988ee474e34ba34bb3.tar.bz2
madwifi: Deliver received Probe Request frames for WPS processing
Diffstat (limited to 'hostapd')
-rw-r--r--hostapd/driver_madwifi.c56
1 files changed, 54 insertions, 2 deletions
diff --git a/hostapd/driver_madwifi.c b/hostapd/driver_madwifi.c
index 156d1e4..4ba803a 100644
--- a/hostapd/driver_madwifi.c
+++ b/hostapd/driver_madwifi.c
@@ -28,6 +28,16 @@
#include <net80211/ieee80211_crypto.h>
#include <net80211/ieee80211_ioctl.h>
+#ifdef CONFIG_WPS
+#ifdef IEEE80211_IOCTL_FILTERFRAME
+#include <netpacket/packet.h>
+
+#ifndef ETH_P_80211_RAW
+#define ETH_P_80211_RAW 0x0019
+#endif
+#endif /* IEEE80211_IOCTL_FILTERFRAME */
+#endif /* CONFIG_WPS */
+
/*
* Avoid conflicts with hostapd definitions by undefining couple of defines
* from madwifi header files.
@@ -57,6 +67,7 @@
#include "ieee802_11.h"
#include "accounting.h"
#include "common.h"
+#include "wps_hostapd.h"
struct madwifi_driver_data {
@@ -71,6 +82,8 @@ struct madwifi_driver_data {
int we_version;
u8 acct_mac[ETH_ALEN];
struct hostap_sta_driver_data acct_data;
+
+ struct l2_packet_data *sock_raw; /* raw 802.11 management frames */
};
static int madwifi_sta_deauth(void *priv, const u8 *addr, int reason_code);
@@ -726,19 +739,56 @@ madwifi_sta_disassoc(void *priv, const u8 *addr, int reason_code)
return ret;
}
-static int madwifi_receive_probe_req(void *priv)
+#ifdef CONFIG_WPS
+#ifdef IEEE80211_IOCTL_FILTERFRAME
+static void madwifi_raw_receive(void *ctx, const u8 *src_addr, const u8 *buf,
+ size_t len)
+{
+ struct madwifi_driver_data *drv = ctx;
+ const struct ieee80211_mgmt *mgmt;
+ const u8 *end, *ie;
+ u16 fc;
+ size_t ie_len;
+
+ /* Send Probe Request information to WPS processing */
+
+ if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req))
+ return;
+ mgmt = (const struct ieee80211_mgmt *) buf;
+
+ fc = le_to_host16(mgmt->frame_control);
+ if (WLAN_FC_GET_TYPE(fc) != WLAN_FC_TYPE_MGMT ||
+ WLAN_FC_GET_STYPE(fc) != WLAN_FC_STYPE_PROBE_REQ)
+ return;
+
+ end = buf + len;
+ ie = mgmt->u.probe_req.variable;
+ ie_len = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req));
+
+ hostapd_wps_probe_req_rx(drv->hapd, mgmt->sa, ie, ie_len);
+}
+#endif /* IEEE80211_IOCTL_FILTERFRAME */
+#endif /* CONFIG_WPS */
+
+static int madwifi_receive_probe_req(struct madwifi_driver_data *drv)
{
int ret = 0;
#ifdef CONFIG_WPS
#ifdef IEEE80211_IOCTL_FILTERFRAME
struct ieee80211req_set_filter filt;
- struct madwifi_driver_data *drv = priv;
wpa_printf(MSG_DEBUG, "%s Enter", __func__);
filt.app_filterype = IEEE80211_FILTER_TYPE_PROBE_REQ;
ret = set80211priv(drv, IEEE80211_IOCTL_FILTERFRAME, &filt,
sizeof(struct ieee80211req_set_filter));
+ if (ret)
+ return ret;
+
+ drv->sock_raw = l2_packet_init(drv->iface, NULL, ETH_P_80211_RAW,
+ madwifi_raw_receive, drv, 1);
+ if (drv->sock_raw == NULL)
+ return -1;
#endif /* IEEE80211_IOCTL_FILTERFRAME */
#endif /* CONFIG_WPS */
return ret;
@@ -1345,6 +1395,8 @@ madwifi_deinit(void *priv)
l2_packet_deinit(drv->sock_recv);
if (drv->sock_xmit != NULL)
l2_packet_deinit(drv->sock_xmit);
+ if (drv->sock_raw)
+ l2_packet_deinit(drv->sock_raw);
free(drv);
}