PATCH: remove set_encryption from driver independent part
Gunter Burchardt
gbur
Thu Aug 19 04:16:17 PDT 2004
Hello
This patch moves hostap_set_encryption to driver dependent part. A
function pointer to this function is defined in driver_info .
regards
gunter
-------------- next part --------------
diff -Nur hostap.old/hostapd/driver.c hostap/hostapd/driver.c
--- hostap.old/hostapd/driver.c 2004-08-10 03:01:20.000000000 +0200
+++ hostap/hostapd/driver.c 2004-08-18 15:10:16.000000000 +0200
@@ -179,8 +179,8 @@
}
-int hostapd_set_encryption(void *priv, const char *alg, u8 *addr,
- int idx, u8 *key, size_t key_len)
+static int hostapd_set_encryption(void *priv, const char *alg, u8 *addr,
+ int idx, u8 *key, size_t key_len)
{
struct hostap_driver_data *drv = priv;
struct prism2_hostapd_param *param;
@@ -709,6 +709,7 @@
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;
+ hapd->driver.set_encryption = hostapd_set_encryption;
return 0;
}
@@ -728,6 +729,7 @@
hapd->driver.set_assoc_ap = NULL;
hapd->driver.init_1x = NULL;
hapd->driver.set_privacy_invoked = NULL;
+ hapd->driver.set_encryption = 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-10 03:01:20.000000000 +0200
+++ hostap/hostapd/driver.h 2004-08-19 12:46:58.000000000 +0200
@@ -15,8 +15,6 @@
void hostapd_driver_deinit(struct hostapd_data *hapd);
int hostapd_set_iface_flags(void *priv, int dev_up);
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);
int hostapd_get_seqnum(void *priv, u8 *addr, int idx, u8 *seq);
int hostapd_flush(void *priv);
int hostapd_set_generic_elem(void *priv,
diff -Nur hostap.old/hostapd/hostapd.c hostap/hostapd/hostapd.c
--- hostap.old/hostapd/hostapd.c 2004-07-18 21:42:23.000000000 +0200
+++ hostap/hostapd/hostapd.c 2004-08-18 15:26:36.000000000 +0200
@@ -327,10 +327,11 @@
/* TODO: Could setup key for RX here, but change default TX keyid only
* after new broadcast key has been sent to all stations. */
- if (hostapd_set_encryption(hapd->driver.data, "WEP", NULL,
- hapd->default_wep_key_idx,
- hapd->default_wep_key,
- hapd->conf->default_wep_key_len)) {
+ if (hapd->driver.set_encryption &&
+ hapd->driver.set_encryption(hapd->driver.data, "WEP", NULL,
+ hapd->default_wep_key_idx,
+ hapd->default_wep_key,
+ hapd->conf->default_wep_key_len)) {
printf("Could not set WEP encryption.\n");
}
@@ -384,12 +385,15 @@
hostapd_hexdump("Default WEP key", hapd->default_wep_key,
hapd->conf->default_wep_key_len);
- hostapd_set_encryption(hapd->driver.data, "none", NULL, 0, NULL, 0);
-
- if (hostapd_set_encryption(hapd->driver.data, "WEP", NULL,
- hapd->default_wep_key_idx,
- hapd->default_wep_key,
- hapd->conf->default_wep_key_len)) {
+ if (hapd->driver.set_encryption)
+ hapd->driver.set_encryption(hapd->driver.data, "none", NULL,
+ 0, NULL, 0);
+
+ if (hapd->driver.set_encryption &&
+ hapd->driver.set_encryption(hapd->driver.data, "WEP", NULL,
+ hapd->default_wep_key_idx,
+ hapd->default_wep_key,
+ hapd->conf->default_wep_key_len)) {
printf("Could not set WEP encryption.\n");
return -1;
}
diff -Nur hostap.old/hostapd/hostapd.h hostap/hostapd/hostapd.h
--- hostap.old/hostapd/hostapd.h 2004-08-10 03:01:20.000000000 +0200
+++ hostap/hostapd/hostapd.h 2004-08-19 12:47:40.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_encryption)(void *priv, const char *alg, u8 *addr,
+ int idx, u8 *key, size_t key_len);
int (*set_privacy_invoked)(void *priv, int flag);
int (*init_1x)(void *priv);
int (*set_assoc_ap)(void *priv, u8 *addr);
diff -Nur hostap.old/hostapd/ieee802_1x.c hostap/hostapd/ieee802_1x.c
--- hostap.old/hostapd/ieee802_1x.c 2004-08-10 03:01:20.000000000 +0200
+++ hostap/hostapd/ieee802_1x.c 2004-08-18 15:28:26.000000000 +0200
@@ -328,10 +328,11 @@
/* TODO: set encryption in TX callback, i.e., only after STA
* has ACKed EAPOL-Key frame */
- if (hostapd_set_encryption(hapd->driver.data, "WEP",
- sta->addr, 0, ikey,
- hapd->conf->
- individual_wep_key_len)) {
+ if (hapd->driver.set_encryption &&
+ hapd->driver.set_encryption(hapd->driver.data, "WEP",
+ sta->addr, 0, ikey,
+ hapd->conf->
+ individual_wep_key_len)) {
printf("Could not set individual WEP encryption.\n");
}
diff -Nur hostap.old/hostapd/wpa.c hostap/hostapd/wpa.c
--- hostap.old/hostapd/wpa.c 2004-08-10 03:01:20.000000000 +0200
+++ hostap/hostapd/wpa.c 2004-08-19 12:50:07.000000000 +0200
@@ -1880,8 +1880,9 @@
sm->pairwise_set = FALSE;
sm->PTK_valid = FALSE;
memset(&sm->PTK, 0, sizeof(sm->PTK));
- hostapd_set_encryption(sm->hapd->driver.data, "none",
- sm->sta->addr, 0, "", 0);
+ if (hapd->driver.set_encryption)
+ hapd->driver.set_encryption(sm->hapd->driver.data, "none",
+ sm->sta->addr, 0, "", 0);
wpa_sm_step(sm);
}
@@ -1945,8 +1946,9 @@
sm->Pair = TRUE;
}
ieee802_1x_notify_port_enabled(sm->sta->eapol_sm, 0);
- hostapd_set_encryption(sm->hapd->driver.data, "none",
- sm->sta->addr, 0, "", 0);
+ if (hapd->driver.set_encryption)
+ hapd->driver.set_encryption(sm->hapd->driver.data, "none",
+ sm->sta->addr, 0, "", 0);
sm->pairwise_set = FALSE;
sm->PTK_valid = FALSE;
memset(&sm->PTK, 0, sizeof(sm->PTK));
@@ -2134,9 +2136,10 @@
alg = "CCMP";
klen = 16;
}
- if (hostapd_set_encryption(sm->hapd->driver.data,
- alg, sm->sta->addr, 0,
- sm->PTK.tk1, klen)) {
+ if (sm->hapd->driver.set_encryption &&
+ sm->hapd->driver.set_encryption(sm->hapd->driver.data,
+ alg, sm->sta->addr, 0,
+ sm->PTK.tk1, klen)) {
wpa_sta_disconnect(sm->hapd, sm->sta);
return;
}
@@ -2392,10 +2395,11 @@
"entering state SETKEYSDONE\n");
sm->changed = TRUE;
sm->wpa_group_state = WPA_GROUP_SETKEYSDONE;
- hostapd_set_encryption(hapd->driver.data,
- wpa_alg_txt(hapd->conf->wpa_group),
- NULL, sm->GN, sm->GTK[sm->GN - 1],
- sm->GTK_len);
+ if (hapd->driver.set_encryption)
+ hapd->driver.set_encryption(hapd->driver.data,
+ wpa_alg_txt(hapd->conf->wpa_group),
+ NULL, sm->GN, sm->GTK[sm->GN - 1],
+ sm->GTK_len);
}
More information about the Hostap
mailing list