PATCH: remove_sta

Gunter Burchardt gbur
Wed Jul 28 23:17:53 PDT 2004


Hello

Here is the next patch to make hostapd more modular to add new drivers.

regards
gunter
-------------- next part --------------
diff -Nur hostap.old/hostapd/driver.c hostap/hostapd/driver.c
--- hostap.old/hostapd/driver.c	2004-07-26 05:55:50.000000000 +0200
+++ hostap/hostapd/driver.c	2004-07-29 07:36:53.000000000 +0200
@@ -340,7 +340,7 @@
 }
 
 
-void remove_sta(void *priv, u8 *addr)
+static void hostapd_remove_sta(void *priv, u8 *addr)
 {
 	struct hostap_driver_data *drv = priv;
 	struct prism2_hostapd_param param;
@@ -618,6 +618,7 @@
 	hapd->driver.send_eapol = hostapd_send_eapol;
 	hapd->driver.send_mgmt_frame = hostapd_send_mgmt_frame;
 	hapd->driver.read_sta_data = hostapd_read_sta_driver_data;
+	hapd->driver.remove_sta = hostapd_remove_sta;
 
 	return 0;
 }
@@ -631,6 +632,7 @@
 	hapd->driver.send_eapol = NULL;
 	hapd->driver.send_mgmt_frame = NULL;
 	hapd->driver.read_sta_data = NULL;
+	hapd->driver.remove_sta = NULL;
 
 	(void) hostapd_set_iface_flags(drv, 0);
 	(void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 0);
diff -Nur hostap.old/hostapd/driver.h hostap/hostapd/driver.h
--- hostap.old/hostapd/driver.h	2004-07-26 05:55:50.000000000 +0200
+++ hostap/hostapd/driver.h	2004-07-29 07:37:02.000000000 +0200
@@ -20,7 +20,6 @@
 int hostapd_set_encryption(void *priv, const char *alg, u8 *addr,
 			   int idx, u8 *key, size_t key_len);
 int hostapd_get_seqnum(void *priv, u8 *addr, int idx, u8 *seq);
-void remove_sta(void *priv, u8 *addr);
 int hostapd_flush(void *priv);
 int hostapd_set_generic_elem(void *priv,
 			     const char *elem, size_t elem_len);
diff -Nur hostap.old/hostapd/hostapd.h hostap/hostapd/hostapd.h
--- hostap.old/hostapd/hostapd.h	2004-07-26 05:55:50.000000000 +0200
+++ hostap/hostapd/hostapd.h	2004-07-29 07:38:04.000000000 +0200
@@ -53,6 +53,7 @@
 struct driver_info {
 	void *data; /* driver specific data - each driver can store data for
 		     * its own use in this pointer */
+	void (*remove_sta)(void *priv, u8 *addr);
 	int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
 			     u8 *addr);
 	int (*send_mgmt_frame)(void *priv, const void *msg, size_t len,
diff -Nur hostap.old/hostapd/iapp.c hostap/hostapd/iapp.c
--- hostap.old/hostapd/iapp.c	2004-06-17 06:37:40.000000000 +0200
+++ hostap/hostapd/iapp.c	2004-07-29 07:39:49.000000000 +0200
@@ -151,7 +151,8 @@
 	printf("Removing STA " MACSTR " due to IAPP-ADD notification from "
 	       "%s\n", MAC2STR(sta->addr), inet_ntoa(from->sin_addr));
 	sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
-	remove_sta(hapd->driver.data, sta->addr);
+	if (hapd->driver.remove_sta)
+		hapd->driver.remove_sta(hapd->driver.data, sta->addr);
 }
 
 
diff -Nur hostap.old/hostapd/ieee802_11.c hostap/hostapd/ieee802_11.c
--- hostap.old/hostapd/ieee802_11.c	2004-07-18 01:25:08.000000000 +0200
+++ hostap/hostapd/ieee802_11.c	2004-07-29 07:41:34.000000000 +0200
@@ -902,7 +902,8 @@
 	 * authenticated. */
 	accounting_sta_stop(hapd, sta);
 	ieee802_1x_free_station(sta);
-	remove_sta(hapd->driver.data, sta->addr);
+	if (hapd->driver.remove_sta)
+		hapd->driver.remove_sta(hapd->driver.data, sta->addr);
 }
 
 
@@ -1215,7 +1216,8 @@
 				       WLAN_REASON_MICHAEL_MIC_FAILURE);
 		sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
 				WLAN_STA_AUTHORIZED);
-		remove_sta(hapd->driver.data, sta->addr);
+		if (hapd->driver.remove_sta)
+			hapd->driver.remove_sta(hapd->driver.data, sta->addr);
 	}
 }
 
diff -Nur hostap.old/hostapd/sta_info.c hostap/hostapd/sta_info.c
--- hostap.old/hostapd/sta_info.c	2004-06-21 05:09:39.000000000 +0200
+++ hostap/hostapd/sta_info.c	2004-07-29 07:42:38.000000000 +0200
@@ -107,8 +107,9 @@
 void ap_free_sta(hostapd *hapd, struct sta_info *sta)
 {
 	accounting_sta_stop(hapd, sta);
-	if (!(sta->flags & WLAN_STA_PREAUTH))
-		remove_sta(hapd->driver.data, sta->addr);
+	if (!(sta->flags & WLAN_STA_PREAUTH) &&
+		hapd->driver.remove_sta)
+		hapd->driver.remove_sta(hapd->driver.data, sta->addr);
 
 	ap_sta_hash_del(hapd, sta);
 	ap_sta_list_del(hapd, sta);
diff -Nur hostap.old/hostapd/wpa.c hostap/hostapd/wpa.c
--- hostap.old/hostapd/wpa.c	2004-06-21 04:53:40.000000000 +0200
+++ hostap/hostapd/wpa.c	2004-07-29 07:44:30.000000000 +0200
@@ -347,7 +347,8 @@
 	ieee802_11_send_deauth(hapd, sta->addr,
 			       WLAN_REASON_PREV_AUTH_NOT_VALID);
 	sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_AUTHORIZED);
-	remove_sta(hapd->driver.data, sta->addr);
+	if (hapd->driver.remove_sta)
+		hapd->driver.remove_sta(hapd->driver.data, sta->addr);
 	eloop_cancel_timeout(ap_handle_timer, hapd, sta);
 	eloop_register_timeout(0, 0, ap_handle_timer, hapd, sta);
 	sta->timeout_next = STA_REMOVE;



More information about the Hostap mailing list