Move RX-from-unknown-STA processing away from driver_*.c
authorJouni Malinen <jouni.malinen@atheros.com>
Fri, 9 Jan 2009 13:44:45 +0000 (15:44 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 9 Jan 2009 13:44:45 +0000 (15:44 +0200)
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
hostapd/driver_hostap.c
hostapd/driver_nl80211.c
hostapd/hostapd.c

index 12fb897..29cc91b 100644 (file)
@@ -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 */
index 65e0b28..fcc8e9f 100644 (file)
@@ -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);
index b7f47fc..6d29095 100644 (file)
@@ -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;
        }
 }
index 13124a0..04b78f8 100644 (file)
@@ -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)