From a70a5d6d0644c623346af907292157a03f2297ed Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 3 Jan 2010 16:46:18 +0200 Subject: [PATCH] Replace hostapd_notif_new_sta() with new driver event, EVENT_NEW_STA --- src/ap/drv_callbacks.c | 4 +++- src/drivers/driver.h | 21 +++++++++++++++++++-- src/drivers/driver_wired.c | 12 ++++++++---- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index ef0b2259c..09d4b1dbe 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -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; diff --git a/src/drivers/driver.h b/src/drivers/driver.h index da17e55ef..d467eb208 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -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); diff --git a/src/drivers/driver_wired.c b/src/drivers/driver_wired.c index 68a3d7382..4a596a1c6 100644 --- a/src/drivers/driver_wired.c +++ b/src/drivers/driver_wired.c @@ -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); }