[PATCH v5 07/22] VLAN: Use new VLAN data type in src_ap_ieee802_1x.c
Michael Braun
michael-dev
Tue Nov 19 11:47:14 PST 2013
Signed-hostap: Michael Braun <michael-dev at fami-braun.de>
---
src/ap/ieee802_1x.c | 33 +++++++++++++++++++++++----------
1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c
index 7874332..fe1f3b2 100644
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
@@ -191,6 +191,9 @@ void ieee802_1x_tx_key(struct hostapd_data *hapd, struct sta_info *sta)
{
struct eapol_authenticator *eapol = hapd->eapol_auth;
struct eapol_state_machine *sm = sta->eapol_sm;
+#ifndef CONFIG_NO_VLAN
+ struct vlan_description *vlan_id = NULL;
+#endif /* CONFIG_NO_VLAN */
if (sm == NULL || !sm->eap_if->eapKeyData)
return;
@@ -199,7 +202,12 @@ void ieee802_1x_tx_key(struct hostapd_data *hapd, struct sta_info *sta)
MAC2STR(sta->addr));
#ifndef CONFIG_NO_VLAN
- if (sta->vlan_id > 0 && sta->vlan_id <= MAX_VLAN_ID) {
+ vlan_id = &sta->vlan_id;
+ if (!vlan_notempty(vlan_id) || vlan_untagged(vlan_id) < 0 ||
+ vlan_untagged(vlan_id) > MAX_VLAN_ID)
+ vlan_id = NULL;
+
+ if (vlan_id) {
wpa_printf(MSG_ERROR, "Using WEP with vlans is not supported.");
return;
}
@@ -912,7 +920,7 @@ void ieee802_1x_new_station(struct hostapd_data *hapd, struct sta_info *sta)
pmksa = wpa_auth_sta_get_pmksa(sta->wpa_sm);
if (pmksa) {
- int old_vlanid;
+ struct vlan_description old_vlanid = VLAN_NULL;
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
HOSTAPD_LEVEL_DEBUG,
@@ -927,11 +935,12 @@ void ieee802_1x_new_station(struct hostapd_data *hapd, struct sta_info *sta)
sta->eapol_sm->authFail = FALSE;
if (sta->eapol_sm->eap)
eap_sm_notify_cached(sta->eapol_sm->eap);
- old_vlanid = sta->vlan_id;
+ vlan_alloc_copy(&old_vlanid, &sta->vlan_id);
pmksa_cache_to_eapol_data(pmksa, sta->eapol_sm);
if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_DISABLED)
- sta->vlan_id = 0;
+ vlan_free(&sta->vlan_id);
ap_sta_bind_vlan(hapd, sta, old_vlanid);
+ vlan_free(&old_vlanid);
} else {
if (reassoc) {
/*
@@ -1252,7 +1261,8 @@ ieee802_1x_receive_auth(struct radius_msg *msg, struct radius_msg *req,
struct hostapd_data *hapd = data;
struct sta_info *sta;
u32 session_timeout = 0, termination_action, acct_interim_interval;
- int session_timeout_set, old_vlanid = 0;
+ int session_timeout_set;
+ struct vlan_description old_vlanid = VLAN_NULL;
struct eapol_state_machine *sm;
int override_eapReq = 0;
struct radius_hdr *hdr = radius_msg_get_hdr(msg);
@@ -1320,18 +1330,20 @@ ieee802_1x_receive_auth(struct radius_msg *msg, struct radius_msg *req,
switch (hdr->code) {
case RADIUS_CODE_ACCESS_ACCEPT:
if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_DISABLED)
- sta->vlan_id = 0;
+ vlan_free(&sta->vlan_id);
#ifndef CONFIG_NO_VLAN
else {
- old_vlanid = sta->vlan_id;
- sta->vlan_id = radius_msg_get_vlanid(msg);
+ vlan_alloc_copy(&old_vlanid, &sta->vlan_id);
+ vlan_alloc(&sta->vlan_id, radius_msg_get_vlanid(msg));
}
- if (sta->vlan_id > 0 &&
+ if (vlan_notempty(&sta->vlan_id) &&
+ vlan_untagged(&sta->vlan_id) > 0 &&
hostapd_vlan_id_valid(hapd->conf->vlan, sta->vlan_id)) {
hostapd_logger(hapd, sta->addr,
HOSTAPD_MODULE_RADIUS,
HOSTAPD_LEVEL_INFO,
- "VLAN ID %d", sta->vlan_id);
+ "VLAN ID %d",
+ vlan_untagged(&sta->vlan_id));
} else if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_REQUIRED) {
sta->eapol_sm->authFail = TRUE;
hostapd_logger(hapd, sta->addr,
@@ -1345,6 +1357,7 @@ ieee802_1x_receive_auth(struct radius_msg *msg, struct radius_msg *req,
if (ap_sta_bind_vlan(hapd, sta, old_vlanid) < 0)
break;
+ vlan_free(&old_vlanid);
/* RFC 3580, Ch. 3.17 */
if (session_timeout_set && termination_action ==
More information about the Hostap
mailing list