PATCH: remove hostapd_ioctl (part 2)

Gunter Burchardt gbur at informatik.uni-rostock.de
Mon Aug 2 07:44:18 EDT 2004


Hello

Here the second (and last) patch to remove hostapd_ioctl from driver
indepentent part. hostapd_ioctl is static now.

regards
gunter
-------------- next part --------------
diff -Nur hostap.old/hostapd/driver.c hostap/hostapd/driver.c
--- hostap.old/hostapd/driver.c	2004-08-01 20:06:56.000000000 +0200
+++ hostap/hostapd/driver.c	2004-08-02 08:34:05.000000000 +0200
@@ -94,6 +94,26 @@
 }
 
 
+static int hostapd_ioctl(void *priv, struct prism2_hostapd_param *param,
+			 int len)
+{
+	struct hostap_driver_data *drv = priv;
+	struct iwreq iwr;
+
+	memset(&iwr, 0, sizeof(iwr));
+	strncpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
+	iwr.u.data.pointer = (caddr_t) param;
+	iwr.u.data.length = len;
+
+	if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_HOSTAPD, &iwr) < 0) {
+		perror("ioctl[PRISM2_IOCTL_HOSTAPD]");
+		return -1;
+	}
+
+	return 0;
+}
+
+
 static void hostapd_set_sta_authorized(void *priv, u8 *addr, int authorized)
 {
 	struct hostap_driver_data *drv = priv;
@@ -155,25 +175,6 @@
 }
 
 
-int hostapd_ioctl(void *priv, struct prism2_hostapd_param *param, int len)
-{
-	struct hostap_driver_data *drv = priv;
-	struct iwreq iwr;
-
-	memset(&iwr, 0, sizeof(iwr));
-	strncpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
-	iwr.u.data.pointer = (caddr_t) param;
-	iwr.u.data.length = len;
-
-	if (ioctl(drv->ioctl_sock, PRISM2_IOCTL_HOSTAPD, &iwr) < 0) {
-		perror("ioctl[PRISM2_IOCTL_HOSTAPD]");
-		return -1;
-	}
-
-	return 0;
-}
-
-
 int hostapd_set_encryption(void *priv, const char *alg, u8 *addr,
 			   int idx, u8 *key, size_t key_len)
 {
@@ -380,14 +381,28 @@
 	memset(&param, 0, sizeof(param));
 	param.cmd = PRISM2_HOSTAPD_GET_INFO_STA;
 	memcpy(param.sta_addr, addr, ETH_ALEN);
-	if (hostapd_ioctl(drv, &param, sizeof(param))) {
+	if (hostapd_ioctl(drv, &param, sizeof(param))) 
 		return -1;
-	}
 
 	return param.u.get_info_sta.inactive_sec;
 }
 
 
+static int hostapd_set_assoc_ap(void *priv, u8 *addr)
+{
+ 	struct hostap_driver_data *drv = priv;
+	struct prism2_hostapd_param param;
+
+    memset(&param, 0, sizeof(param));
+	param.cmd = PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR;
+	memcpy(param.sta_addr, addr, ETH_ALEN);
+	if (hostapd_ioctl(drv, &param, sizeof(param)))
+		return -1;
+
+	return 0;
+}
+
+
 int hostapd_set_generic_elem(void *priv,
 			     const char *elem, size_t elem_len)
 {
@@ -653,6 +668,7 @@
 	hapd->driver.remove_sta = hostapd_remove_sta;
 	hapd->driver.add_sta = hostapd_add_sta;
 	hapd->driver.get_inact_sec = hostapd_get_inact_sec;
+	hapd->driver.set_assoc_ap = hostapd_set_assoc_ap;
 
 	return 0;
 }
@@ -669,6 +685,7 @@
 	hapd->driver.remove_sta = NULL;
 	hapd->driver.add_sta = NULL;
 	hapd->driver.get_inact_sec = NULL;
+	hapd->driver.set_assoc_ap = 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-30 05:56:20.000000000 +0200
+++ hostap/hostapd/driver.h	2004-08-02 08:31:55.000000000 +0200
@@ -14,7 +14,6 @@
 int hostapd_driver_init(struct hostapd_data *hapd);
 void hostapd_driver_deinit(struct hostapd_data *hapd);
 int hostapd_set_iface_flags(void *priv, int dev_up);
-int hostapd_ioctl(void *priv, struct prism2_hostapd_param *param, int len);
 int hostap_ioctl_prism2param(void *priv, int param, int value);
 int hostap_ioctl_setiwessid(void *priv, char *buf, int len);
 int hostapd_set_encryption(void *priv, const char *alg, u8 *addr,
diff -Nur hostap.old/hostapd/hostapd.h hostap/hostapd/hostapd.h
--- hostap.old/hostapd/hostapd.h	2004-08-01 20:06:56.000000000 +0200
+++ hostap/hostapd/hostapd.h	2004-08-02 08:23:08.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 */
+	int (*set_assoc_ap)(void *priv, u8 *addr);
 	int (*get_inact_sec)(void *priv, u8 *addr);
 	int (*add_sta)(void *priv, u8 *addr, u16 aid, u16 capability,
 		       u8 tx_supp_rates);
diff -Nur hostap.old/hostapd/ieee802_11.c hostap/hostapd/ieee802_11.c
--- hostap.old/hostapd/ieee802_11.c	2004-08-01 20:06:56.000000000 +0200
+++ hostap/hostapd/ieee802_11.c	2004-08-02 08:25:20.000000000 +0200
@@ -806,7 +806,6 @@
 			      size_t len)
 {
 	u16 status_code, aid;
-	struct prism2_hostapd_param param;
 
 	if (hapd->assoc_ap_state != ASSOCIATE) {
 		printf("Unexpected association response received from " MACSTR
@@ -847,13 +846,11 @@
 	hapd->assoc_ap_aid = aid;
 	hapd->assoc_ap_state = ASSOCIATED;
 
-	memset(&param, 0, sizeof(param));
-	param.cmd = PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR;
-	memcpy(param.sta_addr, hapd->conf->assoc_ap_addr, ETH_ALEN);
-	if (hostapd_ioctl(hapd->driver.data, &param, sizeof(param))) {
-		printf("Could not set associated AP address to kernel "
-		       "driver.\n");
-	}
+	if (hapd->driver.set_assoc_ap &&
+		hapd->driver.set_assoc_ap(hapd->driver.data, 
+					  hapd->conf->assoc_ap_addr) )
+			printf("Could not set associated AP address to kernel "
+			       "driver.\n");
 }
 
 


More information about the HostAP mailing list