Replace hostapd_probe_req_rx() with EVENT_RX_PROBE_REQ driver event
authorJouni Malinen <j@w1.fi>
Sun, 3 Jan 2010 10:11:44 +0000 (12:11 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Jan 2010 10:11:44 +0000 (12:11 +0200)
src/ap/drv_callbacks.c
src/drivers/driver.h
src/drivers/driver_atheros.c
src/drivers/driver_madwifi.c
src/drivers/driver_test.c

index 30d87a8..ca316c9 100644 (file)
@@ -321,6 +321,23 @@ static void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf,
 #endif /* NEED_AP_MLME */
 
 
+static int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa,
+                               const u8 *ie, size_t ie_len)
+{
+       size_t i;
+       int ret = 0;
+
+       for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++) {
+               if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
+                                           sa, ie, ie_len) > 0) {
+                       ret = 1;
+                       break;
+               }
+       }
+       return ret;
+}
+
+
 void wpa_supplicant_event(void *ctx, wpa_event_type event,
                          union wpa_event_data *data)
 {
@@ -369,6 +386,11 @@ void wpa_supplicant_event(void *ctx, wpa_event_type event,
                                data->rx_mgmt.frame_len, data->rx_mgmt.fi);
                break;
 #endif /* NEED_AP_MLME */
+       case EVENT_RX_PROBE_REQ:
+               hostapd_probe_req_rx(hapd, data->rx_probe_req.sa,
+                                    data->rx_probe_req.ie,
+                                    data->rx_probe_req.ie_len);
+               break;
        default:
                wpa_printf(MSG_DEBUG, "Unknown event %d", event);
                break;
@@ -376,20 +398,3 @@ void wpa_supplicant_event(void *ctx, wpa_event_type event,
 }
 
 #endif /* HOSTAPD */
-
-
-int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa,
-                        const u8 *ie, size_t ie_len)
-{
-       size_t i;
-       int ret = 0;
-
-       for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++) {
-               if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
-                                           sa, ie, ie_len) > 0) {
-                       ret = 1;
-                       break;
-               }
-       }
-       return ret;
-}
index 5fbb791..8c31619 100644 (file)
@@ -1725,7 +1725,16 @@ typedef enum wpa_event_type {
         *
         * This event is used only by driver_test.c and userspace MLME.
         */
-       EVENT_MLME_RX
+       EVENT_MLME_RX,
+
+       /**
+        * EVENT_RX_PROBE_REQ - Indicate received Probe Request frame
+        *
+        * This event is used to indicate when a Probe Request frame has been
+        * received. Information about the received frame is included in
+        * union wpa_event_data::rx_probe_req.
+        */
+       EVENT_RX_PROBE_REQ,
 } wpa_event_type;
 
 
@@ -1978,6 +1987,26 @@ union wpa_event_data {
                int channel;
                int ssi;
        } mlme_rx;
+
+       /**
+        * struct rx_probe_req - Data for EVENT_RX_PROBE_REQ events
+        */
+       struct rx_probe_req {
+               /**
+                * sa - Source address of the received Probe Request frame
+                */
+               const u8 *sa;
+
+               /**
+                * ie - IEs from the Probe Request body
+                */
+               const u8 *ie;
+
+               /**
+                * ie_len - Length of ie buffer in octets
+                */
+               size_t ie_len;
+       } rx_probe_req;
 };
 
 /**
@@ -2021,7 +2050,6 @@ void wpa_scan_sort_results(struct wpa_scan_results *res);
 
 /* hostapd functions for driver wrappers */
 
-struct sta_info;
 struct ieee80211_hdr;
 
 int hostapd_notif_new_sta(struct hostapd_data *hapd, const u8 *addr);
@@ -2039,7 +2067,5 @@ struct hostapd_frame_info {
 
 struct hostapd_data * hostapd_sta_get_bss(struct hostapd_data *hapd,
                                          const u8 *addr);
-int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa,
-                        const u8 *ie, size_t ie_len);
 
 #endif /* DRIVER_H */
index 0c2f81c..58834b4 100644 (file)
@@ -649,9 +649,8 @@ static void madwifi_raw_receive(void *ctx, const u8 *src_addr, const u8 *buf,
 {
        struct madwifi_driver_data *drv = ctx;
        const struct ieee80211_mgmt *mgmt;
-       const u8 *end, *ie;
        u16 fc;
-       size_t ie_len;
+       union wpa_event_data event;
 
        /* Send Probe Request information to WPS processing */
 
@@ -664,11 +663,12 @@ static void madwifi_raw_receive(void *ctx, const u8 *src_addr, const u8 *buf,
            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_probe_req_rx(drv->hapd, mgmt->sa, ie, ie_len);
+       os_memset(&event, 0, sizeof(event));
+       event.rx_probe_req.sa = mgmt->sa;
+       event.rx_probe_req.ie = mgmt->u.probe_req.variable;
+       event.rx_probe_req.ie_len =
+               len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req));
+       wpa_supplicant_event(drv->hapd, EVENT_RX_PROBE_REQ, &event);
 }
 #endif /* CONFIG_WPS */
 
index 367148c..02852fe 100644 (file)
@@ -749,9 +749,8 @@ static void madwifi_raw_receive(void *ctx, const u8 *src_addr, const u8 *buf,
 {
        struct madwifi_driver_data *drv = ctx;
        const struct ieee80211_mgmt *mgmt;
-       const u8 *end, *ie;
        u16 fc;
-       size_t ie_len;
+       union wpa_event_data event;
 
        /* Send Probe Request information to WPS processing */
 
@@ -764,11 +763,12 @@ static void madwifi_raw_receive(void *ctx, const u8 *src_addr, const u8 *buf,
            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_probe_req_rx(drv->hapd, mgmt->sa, ie, ie_len);
+       os_memset(&event, 0, sizeof(event));
+       event.rx_probe_req.sa = mgmt->sa;
+       event.rx_probe_req.ie = mgmt->u.probe_req.variable;
+       event.rx_probe_req.ie_len =
+               len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req));
+       wpa_supplicant_event(drv->hapd, EVENT_RX_PROBE_REQ, &event);
 }
 #endif /* IEEE80211_IOCTL_FILTERFRAME */
 #endif /* CONFIG_WPS */
index add1e98..87647c5 100644 (file)
@@ -485,6 +485,7 @@ static void test_driver_scan(struct wpa_driver_test_data *drv,
        u8 sa[ETH_ALEN];
        u8 ie[512];
        size_t ielen;
+       union wpa_event_data event;
 
        /* data: optional [ ' ' | STA-addr | ' ' | IEs(hex) ] */
 
@@ -511,9 +512,11 @@ static void test_driver_scan(struct wpa_driver_test_data *drv,
                           MAC2STR(sa));
                wpa_hexdump(MSG_MSGDUMP, "test_driver: scan IEs", ie, ielen);
 
-#ifdef HOSTAPD
-               hostapd_probe_req_rx(drv->ctx, sa, ie, ielen);
-#endif /* HOSTAPD */
+               os_memset(&event, 0, sizeof(event));
+               event.rx_probe_req.sa = sa;
+               event.rx_probe_req.ie = ie;
+               event.rx_probe_req.ie_len = ielen;
+               wpa_supplicant_event(drv->ctx, EVENT_RX_PROBE_REQ, &event);
        }
 
        for (bss = drv->bss; bss; bss = bss->next) {