Replace wpa_supplicant_sta_rx() call with driver event
authorJouni Malinen <j@w1.fi>
Sun, 3 Jan 2010 09:50:26 +0000 (11:50 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Jan 2010 09:50:26 +0000 (11:50 +0200)
Get rid of wpa_supplicant_sta_rx() and add a new driver event that is
marked to be used only with driver_test.c. In addition, remove this
functionality from privsep wrapper. This is only use for client mode
MLME testing with driver_test.c.

src/common/privsep_commands.h
src/drivers/driver.h
src/drivers/driver_privsep.c
src/drivers/driver_test.c
wpa_supplicant/events.c
wpa_supplicant/mlme.h
wpa_supplicant/wpa_priv.c
wpa_supplicant/wpa_supplicant.c

index 1eb3a70..cc900be 100644 (file)
@@ -70,7 +70,6 @@ enum privsep_event {
        PRIVSEP_EVENT_STKSTART,
        PRIVSEP_EVENT_FT_RESPONSE,
        PRIVSEP_EVENT_RX_EAPOL,
-       PRIVSEP_EVENT_STA_RX,
 };
 
 #endif /* PRIVSEP_COMMANDS_H */
index 1ee43c6..5fbb791 100644 (file)
@@ -404,12 +404,6 @@ struct wpa_driver_capa {
 };
 
 
-struct ieee80211_rx_status {
-        int channel;
-        int ssi;
-};
-
-
 struct hostapd_data;
 
 struct hostap_sta_driver_data {
@@ -1724,7 +1718,14 @@ typedef enum wpa_event_type {
        /**
         * EVENT_RX_MGMT - Report RX of a management frame
         */
-       EVENT_RX_MGMT
+       EVENT_RX_MGMT,
+
+       /**
+        * EVENT_MLME_RX - Report reception of frame for MLME (test use only)
+        *
+        * This event is used only by driver_test.c and userspace MLME.
+        */
+       EVENT_MLME_RX
 } wpa_event_type;
 
 
@@ -1966,6 +1967,17 @@ union wpa_event_data {
                struct wpa_driver_scan_ssid ssids[WPAS_MAX_SCAN_SSIDS];
                size_t num_ssids;
        } scan_info;
+
+       /**
+        * struct mlme_rx - Data for EVENT_MLME_RX events
+        */
+       struct mlme_rx {
+               const u8 *buf;
+               size_t len;
+               int freq;
+               int channel;
+               int ssi;
+       } mlme_rx;
 };
 
 /**
@@ -1998,9 +2010,6 @@ void wpa_supplicant_event(void *ctx, wpa_event_type event,
 void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
                             const u8 *buf, size_t len);
 
-void wpa_supplicant_sta_rx(void *ctx, const u8 *buf, size_t len,
-                          struct ieee80211_rx_status *rx_status);
-
 const u8 * wpa_scan_get_ie(const struct wpa_scan_res *res, u8 ie);
 const u8 * wpa_scan_get_vendor_ie(const struct wpa_scan_res *res,
                                  u32 vendor_type);
index 077f853..d9911e9 100644 (file)
@@ -438,22 +438,6 @@ static void wpa_driver_privsep_event_rx_eapol(void *ctx, u8 *buf, size_t len)
 }
 
 
-static void wpa_driver_privsep_event_sta_rx(void *ctx, u8 *buf, size_t len)
-{
-#ifdef CONFIG_CLIENT_MLME
-       struct ieee80211_rx_status *rx_status;
-
-       if (len < sizeof(*rx_status))
-               return;
-       rx_status = (struct ieee80211_rx_status *) buf;
-       buf += sizeof(*rx_status);
-       len -= sizeof(*rx_status);
-
-       wpa_supplicant_sta_rx(ctx, buf, len, rx_status);
-#endif /* CONFIG_CLIENT_MLME */
-}
-
-
 static void wpa_driver_privsep_receive(int sock, void *eloop_ctx,
                                       void *sock_ctx)
 {
@@ -530,10 +514,6 @@ static void wpa_driver_privsep_receive(int sock, void *eloop_ctx,
                wpa_driver_privsep_event_rx_eapol(drv->ctx, event_buf,
                                                  event_len);
                break;
-       case PRIVSEP_EVENT_STA_RX:
-               wpa_driver_privsep_event_sta_rx(drv->ctx, event_buf,
-                                               event_len);
-               break;
        }
 
        os_free(buf);
index 6a49252..add1e98 100644 (file)
@@ -1790,11 +1790,11 @@ static void wpa_driver_test_mlme(struct wpa_driver_test_data *drv,
                                 socklen_t fromlen,
                                 const u8 *data, size_t data_len)
 {
-#ifdef CONFIG_CLIENT_MLME
-       struct ieee80211_rx_status rx_status;
-       os_memset(&rx_status, 0, sizeof(rx_status));
-       wpa_supplicant_sta_rx(drv->ctx, data, data_len, &rx_status);
-#endif /* CONFIG_CLIENT_MLME */
+       union wpa_event_data event;
+       os_memset(&event, 0, sizeof(event));
+       event.mlme_rx.buf = data;
+       event.mlme_rx.len = data_len;
+       wpa_supplicant_event(drv->ctx, EVENT_MLME_RX, &event);
 }
 
 
index 3c2010c..5d3533a 100644 (file)
@@ -37,6 +37,7 @@
 #include "bgscan.h"
 #include "ap.h"
 #include "bss.h"
+#include "mlme.h"
 
 
 static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
@@ -1503,6 +1504,19 @@ void wpa_supplicant_event(void *ctx, wpa_event_type event,
                           data->rx_mgmt.frame_len, data->rx_mgmt.fi);
                break;
 #endif /* CONFIG_AP */
+#ifdef CONFIG_CLIENT_MLME
+       case EVENT_MLME_RX: {
+               struct ieee80211_rx_status rx_status;
+               os_memset(&rx_status, 0, sizeof(rx_status));
+               rx_status.freq = data->mlme_rx.freq;
+               rx_status.channel = data->mlme_rx.channel;
+               rx_status.ssi = data->mlme_rx.ssi;
+               ieee80211_sta_rx(wpa_s, data->mlme_rx.buf, data->mlme_rx.len,
+                                &rx_status);
+               break;
+       }
+#endif /* CONFIG_CLIENT_MLME */
+
        default:
                wpa_printf(MSG_INFO, "Unknown event %d", event);
                break;
index ee57dfb..5db3665 100644 (file)
 
 struct wpa_supplicant;
 
+struct ieee80211_rx_status {
+       int freq;
+        int channel;
+        int ssi;
+};
+
 #ifdef CONFIG_CLIENT_MLME
 
 int ieee80211_sta_init(struct wpa_supplicant *wpa_s);
index b7825ed..d2a991b 100644 (file)
@@ -915,35 +915,6 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
 }
 
 
-#ifdef CONFIG_CLIENT_MLME
-void wpa_supplicant_sta_rx(void *ctx, const u8 *buf, size_t len,
-                          struct ieee80211_rx_status *rx_status)
-{
-       struct wpa_priv_interface *iface = ctx;
-       struct msghdr msg;
-       struct iovec io[3];
-       int event = PRIVSEP_EVENT_STA_RX;
-
-       wpa_printf(MSG_DEBUG, "STA RX from driver");
-       io[0].iov_base = &event;
-       io[0].iov_len = sizeof(event);
-       io[1].iov_base = (u8 *) rx_status;
-       io[1].iov_len = sizeof(*rx_status);
-       io[2].iov_base = (u8 *) buf;
-       io[2].iov_len = len;
-
-       os_memset(&msg, 0, sizeof(msg));
-       msg.msg_iov = io;
-       msg.msg_iovlen = 3;
-       msg.msg_name = &iface->drv_addr;
-       msg.msg_namelen = sizeof(iface->drv_addr);
-
-       if (sendmsg(iface->fd, &msg, 0) < 0)
-               perror("sendmsg(wpas_socket)");
-}
-#endif /* CONFIG_CLIENT_MLME */
-
-
 static void wpa_priv_terminate(int sig, void *eloop_ctx, void *signal_ctx)
 {
        wpa_printf(MSG_DEBUG, "wpa_priv termination requested");
index fd8a19f..fc42d29 100644 (file)
@@ -1819,14 +1819,6 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
 }
 
 
-void wpa_supplicant_sta_rx(void *ctx, const u8 *buf, size_t len,
-                          struct ieee80211_rx_status *rx_status)
-{
-       struct wpa_supplicant *wpa_s = ctx;
-       ieee80211_sta_rx(wpa_s, buf, len, rx_status);
-}
-
-
 /**
  * wpa_supplicant_driver_init - Initialize driver interface parameters
  * @wpa_s: Pointer to wpa_supplicant data