[PATCH v5 09/22] VLAN: Use new VLAN data type in src_ap_sta_info
Michael Braun
michael-dev
Tue Nov 19 11:47:25 PST 2013
Signed-hostap: Michael Braun <michael-dev at fami-braun.de>
---
src/ap/sta_info.c | 40 ++++++++++++++++++++++++----------------
src/ap/sta_info.h | 6 ++++--
2 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
index a6775f3..58aafb2 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -271,6 +271,8 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
os_free(sta->sae);
#endif /* CONFIG_SAE */
+ vlan_free(&sta->vlan_id);
+
os_free(sta);
}
@@ -698,7 +700,7 @@ int ap_sta_wps_cancel(struct hostapd_data *hapd,
int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
- int old_vlanid)
+ struct vlan_description old_vlanid)
{
#ifndef CONFIG_NO_VLAN
const char *iface;
@@ -709,14 +711,14 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
* Do not proceed furthur if the vlan id remains same. We do not want
* duplicate dynamic vlan entries.
*/
- if (sta->vlan_id == old_vlanid)
+ if (vlan_cmp(&sta->vlan_id, &old_vlanid))
return 0;
/*
* During 1x reauth, if the vlan id changes, then remove the old id and
* proceed furthur to add the new one.
*/
- if (old_vlanid > 0)
+ if (vlan_notempty(&old_vlanid) && vlan_untagged(&old_vlanid) >= 0)
vlan_remove_dynamic(hapd, old_vlanid);
iface = hapd->conf->iface;
@@ -724,14 +726,15 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
iface = sta->ssid->vlan;
if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_DISABLED)
- sta->vlan_id = 0;
- else if (sta->vlan_id > 0) {
+ vlan_free(&sta->vlan_id);
+ else if (vlan_notempty(&sta->vlan_id) &&
+ vlan_untagged(&sta->vlan_id) >= 0) {
struct hostapd_vlan *wildcard_vlan = NULL;
vlan = hapd->conf->vlan;
while (vlan) {
- if (vlan->vlan_id == sta->vlan_id)
+ if (vlan_cmp(&vlan->vlan_id, &sta->vlan_id))
break;
- if (vlan->vlan_id == VLAN_ID_WILDCARD)
+ if (vlan_untagged(&vlan->vlan_id) == VLAN_ID_WILDCARD)
wildcard_vlan = vlan;
vlan = vlan->next;
}
@@ -741,20 +744,23 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
iface = vlan->ifname;
}
- if (sta->vlan_id > 0 && vlan == NULL) {
+ if (vlan_notempty(&sta->vlan_id) &&
+ vlan_untagged(&sta->vlan_id) >= 0 && vlan == NULL) {
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_DEBUG, "could not find VLAN for "
"binding station to (vlan_id=%d)",
- sta->vlan_id);
+ vlan_untagged(&sta->vlan_id));
return -1;
- } else if (sta->vlan_id > 0 && vlan->vlan_id == VLAN_ID_WILDCARD) {
+ } else if (vlan_notempty(&sta->vlan_id) &&
+ vlan_untagged(&sta->vlan_id) >= 0 &&
+ vlan_untagged(&vlan->vlan_id) == VLAN_ID_WILDCARD) {
vlan = vlan_add_dynamic(hapd, vlan, sta->vlan_id);
if (vlan == NULL) {
hostapd_logger(hapd, sta->addr,
HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_DEBUG, "could not add "
"dynamic VLAN interface for vlan_id=%d",
- sta->vlan_id);
+ vlan_untagged(&sta->vlan_id));
return -1;
}
@@ -765,14 +771,15 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
HOSTAPD_LEVEL_DEBUG, "could not "
"configure encryption for dynamic VLAN "
"interface for vlan_id=%d",
- sta->vlan_id);
+ vlan_untagged(&sta->vlan_id));
}
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_DEBUG, "added new dynamic VLAN "
"interface '%s'", iface);
- } else if (vlan && vlan->vlan_id == sta->vlan_id) {
- if (sta->vlan_id > 0) {
+ } else if (vlan && vlan_cmp(&vlan->vlan_id, &sta->vlan_id)) {
+ if (vlan_notempty(&sta->vlan_id) &&
+ vlan_untagged(&sta->vlan_id) >= 0) {
vlan->dynamic_vlan++;
hostapd_logger(hapd, sta->addr,
HOSTAPD_MODULE_IEEE80211,
@@ -792,7 +799,7 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
HOSTAPD_LEVEL_DEBUG, "could not "
"configure encryption for VLAN "
"interface for vlan_id=%d",
- sta->vlan_id);
+ vlan_untagged(&sta->vlan_id));
}
}
@@ -807,7 +814,8 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
if (ret < 0) {
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_DEBUG, "could not bind the STA "
- "entry to vlan_id=%d", sta->vlan_id);
+ "entry to vlan_id=%d",
+ vlan_untagged(&sta->vlan_id));
}
return ret;
#else /* CONFIG_NO_VLAN */
diff --git a/src/ap/sta_info.h b/src/ap/sta_info.h
index dc74219..0bc50c4 100644
--- a/src/ap/sta_info.h
+++ b/src/ap/sta_info.h
@@ -9,6 +9,8 @@
#ifndef STA_INFO_H
#define STA_INFO_H
+#include "common/vlan.h"
+
/* STA flags */
#define WLAN_STA_AUTH BIT(0)
#define WLAN_STA_ASSOC BIT(1)
@@ -96,7 +98,7 @@ struct sta_info {
struct hostapd_ssid *ssid; /* SSID selection based on (Re)AssocReq */
struct hostapd_ssid *ssid_probe; /* SSID selection based on ProbeReq */
- int vlan_id;
+ struct vlan_description vlan_id;
/* PSKs from RADIUS authentication server */
struct hostapd_sta_wpa_psk_short *psk;
@@ -178,7 +180,7 @@ int ap_sta_wps_cancel(struct hostapd_data *hapd,
struct sta_info *sta, void *ctx);
#endif /* CONFIG_WPS */
int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
- int old_vlanid);
+ struct vlan_description old_vlanid);
void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta);
void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta);
int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta);
More information about the Hostap
mailing list