PATCH: remove hostap_ioctl_prism2param from driver independent part

Gunter Burchardt gbur
Wed Aug 4 02:34:43 PDT 2004


Hello

Next patch to make hostapd more driver independent. Two new
function pointers to driver dependent part:
 * init_1x
 * set_privacy_invoked

hostap_ioctl_prism2param is now static in driver.c.

regards
gunter
-------------- next part --------------
diff -Nur hostap.old/hostapd/driver.c hostap/hostapd/driver.c
--- hostap.old/hostapd/driver.c	2004-08-03 09:35:24.000000000 +0200
+++ hostap/hostapd/driver.c	2004-08-04 11:14:19.000000000 +0200
@@ -250,7 +250,7 @@
 }
 
 
-int hostap_ioctl_prism2param(void *priv, int param, int value)
+static int hostap_ioctl_prism2param(void *priv, int param, int value)
 {
 	struct hostap_driver_data *drv = priv;
 	struct iwreq iwr;
@@ -271,6 +271,41 @@
 }
 
 
+static int hostapd_init_1x(void *priv)
+{
+	struct hostap_driver_data *drv = priv;
+
+	/* enable kernel driver support for IEEE 802.1X */
+	if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_IEEE_802_1X, 1)) {
+		printf("Could not setup IEEE 802.1X support in kernel driver."
+		       "\n");
+		return -1;
+	}
+
+	/* use host driver implementation of encryption to allow
+	 * individual keys and passing plaintext EAPOL frames */
+	if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOST_DECRYPT, 1) ||
+		hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOST_ENCRYPT, 1)) {
+		printf("Could not setup host-based encryption in kernel "
+		       "driver.\n");
+		return -1;
+	}
+
+	return 0;
+}
+
+
+static int hostapd_set_privacy_invoked(void *priv, int flag)
+{
+	struct hostap_drvier_data *drv = priv;
+
+	if (hostap_ioctl_prism2param(drv, PRISM2_PARAM_PRIVACY_INVOKED, flag))
+		return -1;
+
+	return 0;
+}
+
+ 
 int hostap_ioctl_setiwessid(void *priv, char *buf, int len)
 {
 	struct hostap_driver_data *drv = priv;
@@ -674,6 +709,8 @@
 	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;
+	hapd->driver.init_1x = hostapd_init_1x;
+	hapd->driver.set_privacy_invoked = hostapd_set_privacy_invoked;
 
 	return 0;
 }
@@ -691,6 +728,8 @@
 	hapd->driver.add_sta = NULL;
 	hapd->driver.get_inact_sec = NULL;
 	hapd->driver.set_assoc_ap = NULL;
+	hapd->driver.init_1x = NULL;
+	hapd->driver.set_privacy_invoked = 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-08-03 09:35:24.000000000 +0200
+++ hostap/hostapd/driver.h	2004-08-04 11:10:12.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 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,
 			   int idx, u8 *key, size_t key_len);
diff -Nur hostap.old/hostapd/hostapd.h hostap/hostapd/hostapd.h
--- hostap.old/hostapd/hostapd.h	2004-08-03 09:35:24.000000000 +0200
+++ hostap/hostapd/hostapd.h	2004-08-04 11:08:23.000000000 +0200
@@ -53,6 +53,8 @@
 struct driver_info {
 	void *data; /* driver specific data - each driver can store data for
 		     * its own use in this pointer */
+	int (*set_privacy_invoked)(void *priv, int flag);
+	int (*init_1x)(void *priv);
 	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,
diff -Nur hostap.old/hostapd/ieee802_1x.c hostap/hostapd/ieee802_1x.c
--- hostap.old/hostapd/ieee802_1x.c	2004-07-18 21:42:23.000000000 +0200
+++ hostap/hostapd/ieee802_1x.c	2004-08-04 11:13:22.000000000 +0200
@@ -1232,35 +1232,11 @@
 #endif /* HOSTAPD_DUMP_STATE */
 
 
-static int ieee802_1x_init_kernel_1x(hostapd *hapd)
-{
-	/* enable kernel driver support for IEEE 802.1X */
-	if (hostap_ioctl_prism2param(hapd->driver.data,
-				     PRISM2_PARAM_IEEE_802_1X, 1)) {
-		printf("Could not setup IEEE 802.1X support in kernel driver."
-		       "\n");
-		return -1;
-	}
-
-	/* use host driver implementation of encryption to allow
-	 * individual keys and passing plaintext EAPOL frames */
-	if (hostap_ioctl_prism2param(hapd->driver.data,
-				     PRISM2_PARAM_HOST_DECRYPT, 1) ||
-		hostap_ioctl_prism2param(hapd->driver.data,
-					 PRISM2_PARAM_HOST_ENCRYPT, 1)) {
-		printf("Could not setup host-based encryption in kernel "
-		       "driver.\n");
-		return -1;
-	}
-
-	return 0;
-}
-
-
 int ieee802_1x_init(hostapd *hapd)
 {
 	if ((hapd->conf->ieee802_1x || hapd->conf->wpa) &&
-	    ieee802_1x_init_kernel_1x(hapd))
+		hapd->driver.init_1x &&
+		hapd->driver.init_1x(hapd->driver.data))
 		return -1;
 
 	if (radius_client_register(hapd, RADIUS_AUTH, ieee802_1x_receive_auth,
diff -Nur hostap.old/hostapd/wpa.c hostap/hostapd/wpa.c
--- hostap.old/hostapd/wpa.c	2004-07-30 05:56:20.000000000 +0200
+++ hostap/hostapd/wpa.c	2004-08-04 11:12:18.000000000 +0200
@@ -643,8 +643,8 @@
 		free(tmp);
 	}
 
-	if (hostap_ioctl_prism2param(hapd->driver.data,
-				     PRISM2_PARAM_PRIVACY_INVOKED, 1)) {
+	if (hapd->driver.set_privacy_invoked &&
+		hapd->driver.set_privacy_invoked(hapd->driver.data, 1)) {
 		printf("Could not set PrivacyInvoked for interface %s\n",
 		       hapd->conf->iface);
 		return -1;
@@ -731,8 +731,8 @@
 	eloop_cancel_timeout(wpa_rekey_gmk, hapd, NULL);
 	eloop_cancel_timeout(wpa_rekey_gtk, hapd, NULL);
 
-	if (hostap_ioctl_prism2param(hapd->driver.data,
-				     PRISM2_PARAM_PRIVACY_INVOKED, 0)) {
+	if (hapd->driver.set_privacy_invoked &&
+		hapd->driver.set_privacy_invoked(hapd->driver.data, 0)) {
 		printf("Could not disable PrivacyInvoked for interface %s\n",
 		       hapd->conf->iface);
 	}



More information about the Hostap mailing list