]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Make vlan_file optional if dynamic_vlan is used
authorMichael Braun <michael-dev@fami-braun.de>
Sat, 27 Apr 2013 19:53:34 +0000 (22:53 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 27 Apr 2013 19:53:34 +0000 (22:53 +0300)
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
<device>.<vlan> 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 <michael-dev@fami-braun.de>

hostapd/hostapd.conf
src/ap/vlan_init.c

index d4425866b79286cb20c82a6559c247cf6509ede3..6a1c500bda0e0d9da52bee2a21a977ba5f5ce45f 100644 (file)
@@ -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 <bss-iface>.<vlan-id> interfaces.
 #vlan_file=/etc/hostapd.vlan
 
 # Interface where 802.1q tagged packets should appear when a RADIUS server is
index 7b1a9e6711a5c3ae90a510545009113930ce35b4..6390e8bdc7a759d440b7825581c844dc6899390b 100644 (file)
@@ -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;