From patchwork Sat Jul 27 16:13:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: michael-dev X-Patchwork-Id: 262472 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id 83F192C00C0 for ; Sun, 28 Jul 2013 02:14:24 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 8761E9D3B7; Sat, 27 Jul 2013 12:14:22 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lP8QHjY01yqJ; Sat, 27 Jul 2013 12:14:22 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 818DE9D3B8; Sat, 27 Jul 2013 12:14:04 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 98B059D3B5 for ; Sat, 27 Jul 2013 12:14:03 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pvOGhxRY-QeF for ; Sat, 27 Jul 2013 12:13:59 -0400 (EDT) Received: from mail.fem.tu-ilmenau.de (mail.fem.tu-ilmenau.de [141.24.101.79]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 5041D17C0BC for ; Sat, 27 Jul 2013 12:13:51 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.fem.tu-ilmenau.de (Postfix) with ESMTP id D2EA4656D for ; Sat, 27 Jul 2013 18:13:50 +0200 (CEST) X-Virus-Scanned: amavisd-new at fem.tu-ilmenau.de Received: from mail.fem.tu-ilmenau.de ([127.0.0.1]) by localhost (mail.fem.tu-ilmenau.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SauuCxDDxfd9; Sat, 27 Jul 2013 18:13:50 +0200 (CEST) Received: from a234.fem.tu-ilmenau.de (unknown [10.42.51.234]) by mail.fem.tu-ilmenau.de (Postfix) with ESMTP; Sat, 27 Jul 2013 18:13:50 +0200 (CEST) Received: from [10.42.51.234] (localhost [127.0.0.1]) by a234.fem.tu-ilmenau.de (Postfix) with ESMTP id 20088BD0; Sat, 27 Jul 2013 18:13:50 +0200 (CEST) Subject: [PATCH v3 11/25] VLAN: Use new VLAN data type in src_ap_sta_info To: hostap@lists.shmoo.com From: Michael Braun Date: Sat, 27 Jul 2013 18:13:50 +0200 Message-ID: <20130727161349.1152.34790.stgit@ray-controller> In-Reply-To: <20130727160024.1152.46147.stgit@ray-controller> References: <20130727160024.1152.46147.stgit@ray-controller> User-Agent: StGit/0.16 MIME-Version: 1.0 Cc: projekt-wlan@fem.tu-ilmenau.de X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com Signed-hostap: Michael Braun --- 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 39c9eb8..1082a3a 100644 --- a/src/ap/sta_info.c +++ b/src/ap/sta_info.c @@ -246,6 +246,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); } @@ -661,7 +663,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) + vlan_t old_vlanid) { #ifndef CONFIG_NO_VLAN const char *iface; @@ -672,14 +674,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; @@ -687,14 +689,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) { vlan = hapd->conf->vlan; struct hostapd_vlan *wildcard_vlan = NULL; 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; } @@ -704,20 +707,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; } @@ -728,14 +734,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, @@ -755,7 +762,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)); } } @@ -770,7 +777,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 f8f5a83..c2d1525 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) @@ -95,7 +97,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; + vlan_t vlan_id; /* PSKs from RADIUS authentication server */ struct hostapd_sta_wpa_psk_short *psk; @@ -174,7 +176,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); + vlan_t 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);