From: Jouni Malinen Date: Fri, 9 Jan 2009 13:44:45 +0000 (+0200) Subject: Move RX-from-unknown-STA processing away from driver_*.c X-Git-Tag: hostap_0_7_0~671 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;h=214021f585398d1908f6c221f56b3f0e3590acf4;p=libeap.git 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). --- diff --git a/hostapd/driver.h b/hostapd/driver.h index 12fb897..29cc91b 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 65e0b28..fcc8e9f 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 b7f47fc..6d29095 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 13124a0..04b78f8 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)