[luci] [PATCH] Dynamic VLAN Support / Wifi

Jon Agland jon at sftwales.com
Sun Sep 28 14:11:14 CEST 2014


Hi,

Using the list as the capture @ http://luci.subsignal.org/trac/newticket 
doesn't want to play ball...

OpenWRT has Dynamic VLAN support as of r41872, this patch adds the 
relevant menu options to LuCI.  Therefore majority of changes are lines 
added to 
trunk/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua (see 
attached wifi-patch.txt)

It's likely that choosing 'VLAN Naming' to disabled won't work for 
anyone setting up their interfaces in LuCI, but that's a bug in OpenWRT 
handling the hostapd config and I'll submit the fix for that shortly.

There is a minor change to 
trunk/modules/base/luasrc/view/cbi/network_ifacelist.htm (see attached 
network_ifacelist-patch.txt).  This change is to add a check for 
interface types, so that we can select only interfaces with a 'switch' 
type for the VLAN tagged interface, which eventually ends up in hostapd.

Hopefully this is enough info to get it committed into SVN/trac?  If 
not, then let me know

Thanks,

Jon Agland
-------------- next part --------------
--- src/network_ifacelist.htm	2014-06-11 15:00:09.000000000 +0100
+++ vlan/network_ifacelist.htm	2014-09-28 12:48:15.050003675 +0100
@@ -36,6 +36,7 @@
 <ul style="margin:0; list-style-type:none">
 	<% for _, iface in ipairs(ifaces) do
 	     local link = iface:adminlink()
+	 if (self.type == nil ) or (self.type == iface:type()) then
          if (not self.nobridges  or not iface:is_bridge()) and
 		    (not self.noinactive or iface:is_up()) and
 		    iface:name() ~= self.exclude
@@ -60,7 +61,7 @@
 			)<% end %>
 		</label>
 	</li>
-	<% end end %>
+	<% end end end %>
 	<% if not self.nocreate then %>
 	<li>
 		<input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=
-------------- next part --------------
--- src/wifi.lua	2014-08-05 11:21:03.000000000 +0100
+++ vlan/wifi.lua	2014-09-28 12:46:57.150000362 +0100
@@ -960,4 +960,46 @@
 	password:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
 end
 
+----------------------------- Dynamic VLAN Assignment ------------------------
+
+dynamic_vlan = s:taboption("advanced", ListValue, "dynamic_vlan", translate("Dynamic VLAN Assignment"),translate("VLAN assigned based on RADIUS attribute as per RFC 3580 and RFC 2868, also called a VSA (Vendor Specific Attribute); <br><b>Disabled</b> - will only use the network specified in <i>General Setup</i> and will ignore the attribute. <br><b>Optional</b> - if not attribute recieved, will use the network specified in <i>General Setup</i><br>  <b>Required</b> - will drop connection if no VSA is recieved."))
+dynamic_vlan:depends({mode="ap", encryption="wpa"})
+dynamic_vlan:depends({mode="ap", encryption="wpa2"})
+dynamic_vlan:depends({mode="ap-wds", encryption="wpa"})
+dynamic_vlan:depends({mode="ap-wds", encryption="wpa2"})
+dynamic_vlan:value("0", translate("Disabled"))
+dynamic_vlan:value("1", translate("Optional"))
+dynamic_vlan:value("2", translate("Required"))
+
+vlan_naming = s:taboption("advanced", Flag, "vlan_naming", translate("VLAN Naming"), translate("Decide how a VLAN Interface is created;<br><b>Enabled</b> - will add VLANs to the <i>VLAN Tagged Interface</i> e.g. <i>eth0.yyy</i>.<br><b>Disabled</b> - you will need bridge interfaces called <i>vlanyyy</i> for each VLAN you expect to use."))
+vlan_naming:depends({mode="ap", encryption="wpa", dynamic_vlan="1"})
+vlan_naming:depends({mode="ap", encryption="wpa2", dynamic_vlan="1"})
+vlan_naming:depends({mode="ap-wds", encryption="wpa", dynamic_vlan="1"})
+vlan_naming:depends({mode="ap-wds", encryption="wpa2", dynamic_vlan="1"})
+vlan_naming:depends({mode="ap", encryption="wpa", dynamic_vlan="2"})
+vlan_naming:depends({mode="ap", encryption="wpa2", dynamic_vlan="2"})
+vlan_naming:depends({mode="ap-wds", encryption="wpa", dynamic_vlan="2"})
+vlan_naming:depends({mode="ap-wds", encryption="wpa2", dynamic_vlan="2"})
+vlan_naming.default = vlan_naming.enabled
+
+vlan_tagged_interface = s:taboption("advanced", Value, "vlan_tagged_interface", translate("VLAN Tagged Interface"))  
+vlan_tagged_interface.template = "cbi/network_ifacelist" 
+vlan_tagged_interface.widget = "radio"   
+vlan_tagged_interface.nobridges = true
+vlan_tagged_interface.noinactive = true   
+vlan_tagged_interface.novirtual = true   
+vlan_tagged_interface.nocreate = true   
+vlan_tagged_interface.rmempty = true
+vlan_tagged_interface.network = arg[1]
+vlan_tagged_interface.type = "switch"
+
+vlan_tagged_interface:depends({mode="ap", encryption="wpa", vlan_naming="1", dynamic_vlan="1"})
+vlan_tagged_interface:depends({mode="ap", encryption="wpa2", vlan_naming="1", dynamic_vlan="1"})
+vlan_tagged_interface:depends({mode="ap-wds", encryption="wpa", vlan_naming="1", dynamic_vlan="1"})
+vlan_tagged_interface:depends({mode="ap-wds", encryption="wpa2", vlan_naming="1", dynamic_vlan="1"})
+vlan_tagged_interface:depends({mode="ap", encryption="wpa", vlan_naming="1", dynamic_vlan="2"})
+vlan_tagged_interface:depends({mode="ap", encryption="wpa2", vlan_naming="1", dynamic_vlan="2"})
+vlan_tagged_interface:depends({mode="ap-wds", encryption="wpa", vlan_naming="1",  dynamic_vlan="2"})
+vlan_tagged_interface:depends({mode="ap-wds", encryption="wpa2", vlan_naming="1",  dynamic_vlan="2"})
+
 return m


More information about the luci mailing list