From 214021f585398d1908f6c221f56b3f0e3590acf4 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 9 Jan 2009 15:44:45 +0200 Subject: [PATCH] Move RX-from-unknown-STA processing away from driver_*.c This cleans up the driver wrapper interface by getting rid of sta_info.h dependency in all drivers that use MLME implementation in hostapd (driver_hostap.c and driver_nl80211.c). --- hostapd/driver.h | 1 + hostapd/driver_hostap.c | 17 +---------------- hostapd/driver_nl80211.c | 25 ++----------------------- hostapd/hostapd.c | 20 ++++++++++++++++++++ 4 files changed, 24 insertions(+), 39 deletions(-) diff --git a/hostapd/driver.h b/hostapd/driver.h index 12fb897ec..29cc91b31 100644 --- a/hostapd/driver.h +++ b/hostapd/driver.h @@ -215,5 +215,6 @@ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta, int reassoc); void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr, const u8 *buf, size_t len, int ack); +void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd, const u8 *addr); #endif /* DRIVER_H */ diff --git a/hostapd/driver_hostap.c b/hostapd/driver_hostap.c index 65e0b28d2..fcc8e9ffe 100644 --- a/hostapd/driver_hostap.c +++ b/hostapd/driver_hostap.c @@ -38,7 +38,6 @@ #include "eloop.h" #include "priv_netlink.h" #include "ieee802_11.h" -#include "sta_info.h" #include "hostap_common.h" #include "hw_features.h" @@ -74,7 +73,6 @@ static void handle_data(struct hostap_driver_data *drv, u8 *buf, size_t len, u16 fc, ethertype; u8 *pos, *sa; size_t left; - struct sta_info *sta; if (len < sizeof(struct ieee80211_hdr)) return; @@ -88,20 +86,7 @@ static void handle_data(struct hostap_driver_data *drv, u8 *buf, size_t len, } sa = hdr->addr2; - sta = ap_get_sta(drv->hapd, sa); - if (!sta || !(sta->flags & WLAN_STA_ASSOC)) { - printf("Data frame from not associated STA " MACSTR "\n", - MAC2STR(sa)); - if (sta && (sta->flags & WLAN_STA_AUTH)) - hostap_sta_disassoc( - drv, sa, - WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); - else - hostap_sta_deauth( - drv, sa, - WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); - return; - } + hostapd_rx_from_unknown_sta(drv->hapd, sa); pos = (u8 *) (hdr + 1); left = len - sizeof(*hdr); diff --git a/hostapd/driver_nl80211.c b/hostapd/driver_nl80211.c index b7f47fca9..6d29095bf 100644 --- a/hostapd/driver_nl80211.c +++ b/hostapd/driver_nl80211.c @@ -34,7 +34,6 @@ #include "ieee802_1x.h" #include "eloop.h" #include "ieee802_11.h" -#include "sta_info.h" #include "hw_features.h" #include "mlme.h" #include "radiotap.h" @@ -1636,26 +1635,6 @@ static int i802_set_country(void *priv, const char *country) } -static void handle_unknown_sta(struct i802_driver_data *drv, u8 *ta) -{ - struct sta_info *sta; - - sta = ap_get_sta(drv->hapd, ta); - if (!sta || !(sta->flags & WLAN_STA_ASSOC)) { - printf("Data/PS-poll frame from not associated STA " - MACSTR "\n", MAC2STR(ta)); - if (sta && (sta->flags & WLAN_STA_AUTH)) - i802_sta_disassoc( - drv, ta, - WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); - else - i802_sta_deauth( - drv, ta, - WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); - } -} - - static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len, int ok) { @@ -1797,10 +1776,10 @@ static void handle_frame(struct i802_driver_data *drv, case WLAN_FC_TYPE_CTRL: /* can only get here with PS-Poll frames */ wpa_printf(MSG_DEBUG, "CTRL"); - handle_unknown_sta(drv, hdr->addr2); + hostapd_rx_from_unknown_sta(drv->hapd, hdr->addr2); break; case WLAN_FC_TYPE_DATA: - handle_unknown_sta(drv, hdr->addr2); + hostapd_rx_from_unknown_sta(drv->hapd, hdr->addr2); break; } } diff --git a/hostapd/hostapd.c b/hostapd/hostapd.c index 13124a0f5..04b78f81d 100644 --- a/hostapd/hostapd.c +++ b/hostapd/hostapd.c @@ -278,6 +278,26 @@ void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr, } +void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd, const u8 *addr) +{ + struct sta_info *sta; + + sta = ap_get_sta(hapd, addr); + if (!sta || !(sta->flags & WLAN_STA_ASSOC)) { + wpa_printf(MSG_DEBUG, "Data/PS-poll frame from not associated " + "STA " MACSTR, MAC2STR(addr)); + if (sta && (sta->flags & WLAN_STA_AUTH)) + hostapd_sta_disassoc( + hapd, addr, + WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); + else + hostapd_sta_deauth( + hapd, addr, + WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); + } +} + + #ifdef EAP_SERVER static int hostapd_sim_db_cb_sta(struct hostapd_data *hapd, struct sta_info *sta, void *ctx)