Browse Source

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).
Jouni Malinen 16 years ago
parent
commit
214021f585
4 changed files with 24 additions and 39 deletions
  1. 1 0
      hostapd/driver.h
  2. 1 16
      hostapd/driver_hostap.c
  3. 2 23
      hostapd/driver_nl80211.c
  4. 20 0
      hostapd/hostapd.c

+ 1 - 0
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 */

+ 1 - 16
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);

+ 2 - 23
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;
 	}
 }

+ 20 - 0
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)