From 7ca902b53ed69d2dc047c83fc1e396de2f6e9429 Mon Sep 17 00:00:00 2001 From: Michael Braun Date: Sat, 27 Apr 2013 22:53:34 +0300 Subject: [PATCH] Make vlan_file optional if dynamic_vlan is used My APs generate their configuration on their own using a different number of (vlan-enabled) bss. Currently, all my vlan_file files consist of a single line: the wildcard line. Configuration file generation would be easier, if the hostapd configuration file would not depend on those simple vlan_file files. This patch removes the need for those one-line files by using the . naming scheme if no vlan_file is given (or that file is empty). This should not break any existing setup, as using dynamic_vlan with no vlan configured does not make sense anyway. Signed-hostap: Michael Braun --- hostapd/hostapd.conf | 7 ++++--- src/ap/vlan_init.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf index d4425866b..6a1c500bd 100644 --- a/hostapd/hostapd.conf +++ b/hostapd/hostapd.conf @@ -814,9 +814,8 @@ own_ip_addr=127.0.0.1 # is used for the stations. This information is parsed from following RADIUS # attributes based on RFC 3580 and RFC 2868: Tunnel-Type (value 13 = VLAN), # Tunnel-Medium-Type (value 6 = IEEE 802), Tunnel-Private-Group-ID (value -# VLANID as a string). vlan_file option below must be configured if dynamic -# VLANs are used. Optionally, the local MAC ACL list (accept_mac_file) can be -# used to set static client MAC address to VLAN ID mapping. +# VLANID as a string). Optionally, the local MAC ACL list (accept_mac_file) can +# be used to set static client MAC address to VLAN ID mapping. # 0 = disabled (default) # 1 = option; use default interface if RADIUS server does not include VLAN ID # 2 = required; reject authentication if RADIUS server does not include VLAN ID @@ -828,6 +827,8 @@ own_ip_addr=127.0.0.1 # multiple BSSIDs or SSIDs. Each line in this text file is defining a new # interface and the line must include VLAN ID and interface name separated by # white space (space or tab). +# If no entries are provided by this file, the station is statically mapped +# to . interfaces. #vlan_file=/etc/hostapd.vlan # Interface where 802.1q tagged packets should appear when a RADIUS server is diff --git a/src/ap/vlan_init.c b/src/ap/vlan_init.c index 7b1a9e671..6390e8bdc 100644 --- a/src/ap/vlan_init.c +++ b/src/ap/vlan_init.c @@ -837,6 +837,27 @@ int vlan_init(struct hostapd_data *hapd) hapd->full_dynamic_vlan = full_dynamic_vlan_init(hapd); #endif /* CONFIG_FULL_DYNAMIC_VLAN */ + if (hapd->conf->ssid.dynamic_vlan != DYNAMIC_VLAN_DISABLED && + !hapd->conf->vlan) { + /* dynamic vlans enabled but no (or empty) vlan_file given */ + struct hostapd_vlan *vlan; + vlan = os_zalloc(sizeof(*vlan)); + if (vlan == NULL) { + wpa_printf(MSG_ERROR, "Out of memory while assigning " + "VLAN interfaces"); + return -1; + } + + vlan->vlan_id = VLAN_ID_WILDCARD; + os_snprintf(vlan->ifname, sizeof(vlan->ifname), "%s.#", + hapd->conf->iface); + if (hapd->conf->vlan_tail) + hapd->conf->vlan_tail->next = vlan; + else + hapd->conf->vlan = vlan; + hapd->conf->vlan_tail = vlan; + } + if (vlan_dynamic_add(hapd, hapd->conf->vlan)) return -1;