]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Replace hostapd_notif_new_sta() with new driver event, EVENT_NEW_STA
authorJouni Malinen <j@w1.fi>
Sun, 3 Jan 2010 14:46:18 +0000 (16:46 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Jan 2010 14:46:18 +0000 (16:46 +0200)
src/ap/drv_callbacks.c
src/drivers/driver.h
src/drivers/driver_wired.c

index ef0b2259c35097269efe17c2550c0821d5859d10..09d4b1dbedf0ad46780c6f6f6943dbbc18dbfbba 100644 (file)
@@ -31,7 +31,7 @@
 #include "ap_config.h"
 
 
-int hostapd_notif_new_sta(struct hostapd_data *hapd, const u8 *addr)
+static int hostapd_notif_new_sta(struct hostapd_data *hapd, const u8 *addr)
 {
        struct sta_info *sta = ap_get_sta(hapd, addr);
        if (sta)
@@ -395,6 +395,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                                     data->rx_probe_req.ie,
                                     data->rx_probe_req.ie_len);
                break;
+       case EVENT_NEW_STA:
+               hostapd_notif_new_sta(hapd, data->new_sta.addr);
        default:
                wpa_printf(MSG_DEBUG, "Unknown event %d", event);
                break;
index da17e55ef86d4f37719f944ea6e9fbd07f05d840..d467eb208a02484c0cb2ac355d3dcf9f242e2c45 100644 (file)
@@ -1871,7 +1871,18 @@ enum wpa_event_type {
         * in station mode. In AP mode, Probe Request frames should always be
         * reported.
         */
-       EVENT_RX_PROBE_REQ
+       EVENT_RX_PROBE_REQ,
+
+       /**
+        * EVENT_NEW_STA - New wired device noticed
+        *
+        * This event is used to indicate that a new device has been detected
+        * in a network that does not use association-like functionality (i.e.,
+        * mainly wired Ethernet). This can be used to start EAPOL
+        * authenticator when receiving a frame from a device. The address of
+        * the device is included in union wpa_event_data::new_sta.
+        */
+       EVENT_NEW_STA
 };
 
 
@@ -2192,6 +2203,13 @@ union wpa_event_data {
                 */
                size_t ie_len;
        } rx_probe_req;
+
+       /**
+        * struct new_sta - Data for EVENT_NEW_STA events
+        */
+       struct new_sta {
+               const u8 *addr;
+       } new_sta;
 };
 
 /**
@@ -2235,7 +2253,6 @@ void wpa_scan_sort_results(struct wpa_scan_results *res);
 
 /* hostapd functions for driver wrappers */
 
-int hostapd_notif_new_sta(struct hostapd_data *hapd, const u8 *addr);
 int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
                        const u8 *ie, size_t ielen);
 void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
index 68a3d73826fcbbb73986e76589dd301d5fe96be0..4a596a1c69adf074c1e666e5d36ee7705f496d5a 100644 (file)
@@ -118,6 +118,7 @@ static void handle_data(void *ctx, unsigned char *buf, size_t len)
        struct ieee8023_hdr *hdr;
        u8 *pos, *sa;
        size_t left;
+       union wpa_event_data event;
 
        /* must contain at least ieee8023_hdr 6 byte source, 6 byte dest,
         * 2 byte ethertype */
@@ -133,7 +134,9 @@ static void handle_data(void *ctx, unsigned char *buf, size_t len)
                case ETH_P_PAE:
                        wpa_printf(MSG_MSGDUMP, "Received EAPOL packet");
                        sa = hdr->src;
-                       hostapd_notif_new_sta(ctx, sa);
+                       os_memset(&event, 0, sizeof(event));
+                       event.new_sta.addr = sa;
+                       wpa_supplicant_event(ctx, EVENT_NEW_STA, &event);
 
                        pos = (u8 *) (hdr + 1);
                        left = len - sizeof(*hdr);
@@ -167,11 +170,11 @@ static void handle_read(int sock, void *eloop_ctx, void *sock_ctx)
 
 static void handle_dhcp(int sock, void *eloop_ctx, void *sock_ctx)
 {
-#ifdef HOSTAPD
        int len;
        unsigned char buf[3000];
        struct dhcp_message *msg;
        u8 *mac_address;
+       union wpa_event_data event;
 
        len = recv(sock, buf, sizeof(buf), 0);
        if (len < 0) {
@@ -191,8 +194,9 @@ static void handle_dhcp(int sock, void *eloop_ctx, void *sock_ctx)
        wpa_printf(MSG_MSGDUMP, "Got DHCP broadcast packet from " MACSTR,
                   MAC2STR(mac_address));
 
-       hostapd_notif_new_sta(eloop_ctx, mac_address);
-#endif /* HOSTAPD */
+       os_memset(&event, 0, sizeof(event));
+       event.new_sta.addr = mac_address;
+       wpa_supplicant_event(eloop_ctx, EVENT_NEW_STA, &event);
 }