diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua | 22 | ||||
-rw-r--r-- | modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua | 100 | ||||
-rw-r--r-- | modules/admin-full/luasrc/view/cbi/wireless_modefreq.htm | 167 | ||||
-rw-r--r-- | modules/base/luasrc/dispatcher.lua | 4 | ||||
-rw-r--r-- | modules/base/luasrc/model/network.lua | 16 | ||||
-rw-r--r-- | modules/base/luasrc/sys.lua | 1 | ||||
-rw-r--r-- | modules/base/luasrc/view/cbi/footer.htm | 2 | ||||
-rw-r--r-- | modules/base/luasrc/view/sysauth.htm | 6 |
8 files changed, 249 insertions, 69 deletions
diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua b/modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua index 155722669a..fbea03af98 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/vlan.lua @@ -25,6 +25,7 @@ m.uci:foreach("network", "switch", local has_learn = nil local has_vlan4k = nil local has_jumbo3 = nil + local has_mirror = nil local min_vid = 0 local max_vid = 16 local num_vlans = 16 @@ -74,6 +75,9 @@ m.uci:foreach("network", "switch", elseif line:match(": enable_learning") then has_learn = "enable_learning" + elseif line:match(": enable_mirror_rx") then + has_mirror = "enable_mirror_rx" + elseif line:match(": max_length") then has_jumbo3 = "max_length" end @@ -105,6 +109,24 @@ m.uci:foreach("network", "switch", x.rmempty = true end + -- Does this switch support port mirroring? + if has_mirror then + s:option(Flag, "enable_mirror_rx", translate("Enable mirroring of incoming packets")) + s:option(Flag, "enable_mirror_tx", translate("Enable mirroring of outgoing packets")) + + local sp = s:option(ListValue, "mirror_source_port", translate("Mirror source port")) + local mp = s:option(ListValue, "mirror_monitor_port", translate("Mirror monitor port")) + + local pt + for pt = 0, num_ports - 1 do + local name + + name = (pt == cpu_port) and translate("CPU") or translatef("Port %d", pt) + + sp:value(pt, name) + mp:value(pt, name) + end + end -- VLAN table s = m:section(TypedSection, "switch_vlan", diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua index 2253752f4f..f61fda3737 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua @@ -169,12 +169,31 @@ if found_sta then ch.value = translatef("Locked to channel %d used by: %s", found_sta.channel, table.concat(found_sta.names, ", ")) else - ch = s:taboption("general", Value, "channel", translate("Channel")) - ch:value("auto", translate("auto")) - for _, f in ipairs(iw and iw.freqlist or { }) do - if not f.restricted then - ch:value(f.channel, "%i (%.3f GHz)" %{ f.channel, f.mhz / 1000 }) - end + ch = s:taboption("general", Value, "_mode_freq", '<br />'..translate("Operating frequency")) + ch.hwmodes = iw.hwmodelist + ch.freqlist = iw.freqlist + ch.template = "cbi/wireless_modefreq" + + function ch.cfgvalue(self, section) + return { + m:get(section, "hwmode") or "", + m:get(section, "channel") or "auto", + m:get(section, "htmode") or "" + } + end + + function ch.formvalue(self, section) + return { + m:formvalue(self:cbid(section) .. ".band") or (iw.hwmodelist.g and "11g" or "11a"), + m:formvalue(self:cbid(section) .. ".channel") or "auto", + m:formvalue(self:cbid(section) .. ".htmode") or "" + } + end + + function ch.write(self, section, value) + m:set(section, "hwmode", value[1]) + m:set(section, "channel", value[2]) + m:set(section, "htmode", value[3]) end end @@ -196,45 +215,6 @@ if hwtype == "mac80211" then end end - mode = s:taboption("advanced", ListValue, "hwmode", translate("Band")) - - if hw_modes.ac then - if hw_modes.ac then mode:value("11a", "5GHz (802.11n+ac)") end - - htmode = s:taboption("advanced", ListValue, "htmode", translate("VHT mode (802.11ac)")) - htmode:value("", translate("disabled")) - htmode:value("VHT20", "20MHz") - htmode:value("VHT40", "40MHz") - htmode:value("VHT80", "80MHz") - - elseif hw_modes.n then - if hw_modes.g then mode:value("11g", "2.4GHz (802.11g+n)") end - if hw_modes.a then mode:value("11a", "5GHz (802.11a+n)") end - - htmode = s:taboption("advanced", ListValue, "htmode", translate("HT mode (802.11n)")) - htmode:value("", translate("disabled")) - htmode:value("HT20", "20MHz") - htmode:value("HT40", "40MHz") - - function mode.cfgvalue(...) - local v = Value.cfgvalue(...) - if v == "11na" then - return "11a" - elseif v == "11ng" then - return "11g" - end - return v - end - - noscan = s:taboption("advanced", Flag, "noscan", translate("Force 40MHz mode"), - translate("Always use 40MHz channels even if the secondary channel overlaps. Using this option does not comply with IEEE 802.11n-2009!")) - noscan:depends("htmode", "HT40") - noscan.default = noscan.disabled - else - if hw_modes.g then mode:value("11g", "2.4GHz (802.11g)") end - if hw_modes.a then mode:value("11a", "5GHz (802.11a)") end - end - local cl = iw and iw.countrylist if cl and #cl > 0 then cc = s:taboption("advanced", ListValue, "country", translate("Country Code"), translate("Use ISO/IEC 3166 alpha2 country codes.")) @@ -285,16 +265,6 @@ if hwtype == "atheros" then %{ p.display_dbm, p.display_mw }) end - mode = s:taboption("advanced", ListValue, "hwmode", translate("Mode")) - mode:value("", translate("auto")) - if hw_modes.b then mode:value("11b", "802.11b") end - if hw_modes.g then mode:value("11g", "802.11g") end - if hw_modes.a then mode:value("11a", "802.11a") end - if hw_modes.g then mode:value("11bg", "802.11b+g") end - if hw_modes.g then mode:value("11gst", "802.11g + Turbo") end - if hw_modes.a then mode:value("11ast", "802.11a + Turbo") end - mode:value("fh", translate("Frequency Hopping")) - s:taboption("advanced", Flag, "diversity", translate("Diversity")).rmempty = false if not nsantenna then @@ -352,12 +322,6 @@ if hwtype == "broadcom" then %{ p.display_dbm, p.display_mw }) end - mode = s:taboption("advanced", ListValue, "hwmode", translate("Mode")) - mode:value("11bg", "802.11b+g") - mode:value("11b", "802.11b") - mode:value("11g", "802.11g") - mode:value("11gst", "802.11g + Turbo") - ant1 = s:taboption("advanced", ListValue, "txantenna", translate("Transmitter Antenna")) ant1.widget = "radio" ant1:depends("diversity", "") @@ -975,4 +939,18 @@ if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then password:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"}) end +if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then + local wpasupplicant = fs.access("/usr/sbin/wpa_supplicant") + local hostcli = fs.access("/usr/sbin/hostapd_cli") + if hostcli and wpasupplicant then + wps = s:taboption("encryption", Flag, "wps_pushbutton", translate("Enable WPS pushbutton, requires WPA(2)-PSK")) + wps.enabled = "1" + wps.disabled = "0" + wps.rmempty = false + wps:depends("encryption", "psk") + wps:depends("encryption", "psk2") + wps:depends("encryption", "psk-mixed") + end +end + return m diff --git a/modules/admin-full/luasrc/view/cbi/wireless_modefreq.htm b/modules/admin-full/luasrc/view/cbi/wireless_modefreq.htm new file mode 100644 index 0000000000..39db482dd3 --- /dev/null +++ b/modules/admin-full/luasrc/view/cbi/wireless_modefreq.htm @@ -0,0 +1,167 @@ +<%+cbi/valueheader%> + +<script type="text/javascript"> + var freqlist = <%= luci.http.write_json(self.freqlist) %>; + var hwmodes = <%= luci.http.write_json(self.hwmodes) %>; + + var channels = { + '11g': [ + 'auto', 'auto', true + ], + '11a': [ + 'auto', 'auto', true + ] + }; + + for (var i = 0; i < freqlist.length; i++) + channels[(freqlist[i].mhz > 2484) ? '11a' : '11g'].push( + freqlist[i].channel, + '%d (%d MHz)'.format(freqlist[i].channel, freqlist[i].mhz), + !freqlist[i].restricted + ); + + var modes = [ + '', 'Legacy', true, + 'n', 'N', hwmodes.n, + 'ac', 'AC', hwmodes.ac + ]; + + var htmodes = { + '': [ + '', '-', true + ], + 'n': [ + 'HT20', '20 MHz', true, + 'HT40', '40 MHz', true + ], + 'ac': [ + 'VHT20', '20 MHz', true, + 'VHT40', '40 MHz', true, + 'VHT80', '80 MHz', true, + 'VHT160', '160 MHz', true + ] + }; + + var bands = { + '': [ + '11g', '2.4 GHz', (channels['11g'].length > 3), + '11a', '5 GHz', (channels['11a'].length > 3) + ], + 'n': [ + '11g', '2.4 GHz', (channels['11g'].length > 3), + '11a', '5 GHz', (channels['11a'].length > 3) + ], + 'ac': [ + '11a', '5 GHz', true + ] + }; + + function cbi_set_values(sel, vals) + { + if (sel.vals) + sel.vals.selected = sel.selectedIndex; + + while (sel.options[0]) + sel.remove(0); + + for (var i = 0; vals && i < vals.length; i += 3) + { + if (!vals[i+2]) + continue; + + var opt = document.createElement('option'); + opt.value = vals[i+0]; + opt.text = vals[i+1]; + + sel.add(opt); + } + + if (!isNaN(vals.selected)) + sel.selectedIndex = vals.selected; + + sel.parentNode.style.display = (sel.options.length <= 1) ? 'none' : ''; + sel.vals = vals; + } + + function cbi_toggle_wifi_mode(id) + { + cbi_toggle_wifi_htmode(id); + cbi_toggle_wifi_band(id); + } + + function cbi_toggle_wifi_htmode(id) + { + var mode = document.getElementById(id + '.mode'); + var bwdt = document.getElementById(id + '.htmode'); + + cbi_set_values(bwdt, htmodes[mode.value]); + } + + function cbi_toggle_wifi_band(id) + { + var mode = document.getElementById(id + '.mode'); + var band = document.getElementById(id + '.band'); + + cbi_set_values(band, bands[mode.value]); + cbi_toggle_wifi_channel(id); + } + + function cbi_toggle_wifi_channel(id) + { + var band = document.getElementById(id + '.band'); + var chan = document.getElementById(id + '.channel'); + + cbi_set_values(chan, channels[band.value]); + } + + function cbi_init_wifi(id) + { + var mode = document.getElementById(id + '.mode'); + var band = document.getElementById(id + '.band'); + var chan = document.getElementById(id + '.channel'); + var bwdt = document.getElementById(id + '.htmode'); + + cbi_set_values(mode, modes); + + if (/VHT20|VHT40|VHT80|VHT160/.test(<%= luci.http.write_json(self.map:get(section, "htmode")) %>)) + mode.value = 'ac'; + else if (/HT20|HT40/.test(<%= luci.http.write_json(self.map:get(section, "htmode")) %>)) + mode.value = 'n'; + else + mode.value = ''; + + cbi_toggle_wifi_mode(id); + + if (/a/.test(<%= luci.http.write_json(self.map:get(section, "hwmode")) %>)) + band.value = '11a'; + else + band.value = '11g'; + + cbi_toggle_wifi_band(id); + + bwdt.value = <%= luci.http.write_json(self.map:get(section, "htmode")) %>; + chan.value = <%= luci.http.write_json(self.map:get(section, "channel")) %>; + } +</script> + +<label style="float:left; margin-right:3px"> + <%:Mode%><br /> + <select style="width:auto" id="<%= cbid %>.mode" name="<%= cbid %>.mode" onchange="cbi_toggle_wifi_mode('<%= cbid %>')"></select> +</label> +<label style="float:left; margin-right:3px"> + <%:Band%><br /> + <select style="width:auto" id="<%= cbid %>.band" name="<%= cbid %>.band" onchange="cbi_toggle_wifi_band('<%= cbid %>')"></select> +</label> +<label style="float:left; margin-right:3px"> + <%:Channel%><br /> + <select style="width:auto" id="<%= cbid %>.channel" name="<%= cbid %>.channel"></select> +</label> +<label style="float:left; margin-right:3px"> + <%:Width%><br /> + <select style="width:auto" id="<%= cbid %>.htmode" name="<%= cbid %>.htmode"></select> +</label> +<br style="clear:left" /> + +<script type="text/javascript">cbi_init_wifi('<%= cbid %>');</script> + +<%+cbi/valuefooter%> diff --git a/modules/base/luasrc/dispatcher.lua b/modules/base/luasrc/dispatcher.lua index 9e5b78d5e9..f7e16e77b6 100644 --- a/modules/base/luasrc/dispatcher.lua +++ b/modules/base/luasrc/dispatcher.lua @@ -145,8 +145,8 @@ function error500(message) end function authenticator.htmlauth(validator, accs, default) - local user = luci.http.formvalue("username") - local pass = luci.http.formvalue("password") + local user = luci.http.formvalue("luci_username") + local pass = luci.http.formvalue("luci_password") if user and validator(user, pass) then return user diff --git a/modules/base/luasrc/model/network.lua b/modules/base/luasrc/model/network.lua index 0aac416ace..6119abd73c 100644 --- a/modules/base/luasrc/model/network.lua +++ b/modules/base/luasrc/model/network.lua @@ -135,13 +135,25 @@ function _wifi_iface(x) end function _wifi_state(key, val, field) + local radio, radiostate, ifc, ifcstate + if not next(_ubuswificache) then _ubuswificache = _ubus:call("network.wireless", "status", {}) or {} + + -- workaround extended section format + for radio, radiostate in pairs(_ubuswificache) do + for ifc, ifcstate in pairs(radiostate.interfaces) do + if ifcstate.section and ifcstate.section:sub(1, 1) == '@' then + local s = _uci_real:get_all('wireless.%s' % ifcstate.section) + if s then + ifcstate.section = s['.name'] + end + end + end + end end - local radio, radiostate for radio, radiostate in pairs(_ubuswificache) do - local ifc, ifcstate for ifc, ifcstate in pairs(radiostate.interfaces) do if ifcstate[key] == val then return ifcstate[field] diff --git a/modules/base/luasrc/sys.lua b/modules/base/luasrc/sys.lua index df6280dda0..3a04f6bada 100644 --- a/modules/base/luasrc/sys.lua +++ b/modules/base/luasrc/sys.lua @@ -186,6 +186,7 @@ function sysinfo() cpuinfo:match("model name\t+: ([^\n]+)") local model = + fs.readfile("/proc/device-tree/model") or luci.util.pcdata(fs.readfile("/tmp/sysinfo/model")) or cpuinfo:match("machine\t+: ([^\n]+)") or cpuinfo:match("Hardware\t+: ([^\n]+)") or diff --git a/modules/base/luasrc/view/cbi/footer.htm b/modules/base/luasrc/view/cbi/footer.htm index 2c34028e58..115250a82d 100644 --- a/modules/base/luasrc/view/cbi/footer.htm +++ b/modules/base/luasrc/view/cbi/footer.htm @@ -16,7 +16,7 @@ <input class="cbi-button cbi-button-save" type="submit" value="<%:Save%>" /> <% end %> <% if not flow.hideresetbtn then %> - <input class="cbi-button cbi-button-reset" type="reset" value="<%:Reset%>" /> + <input class="cbi-button cbi-button-reset" type="button" value="<%:Reset%>" onclick="location.href='<%=REQUEST_URI%>'" /> <% end %> <script type="text/javascript">cbi_d_update();</script> diff --git a/modules/base/luasrc/view/sysauth.htm b/modules/base/luasrc/view/sysauth.htm index 7c39f0da51..e87f26c2c8 100644 --- a/modules/base/luasrc/view/sysauth.htm +++ b/modules/base/luasrc/view/sysauth.htm @@ -27,13 +27,13 @@ You may obtain a copy of the License at <div class="cbi-value"> <label class="cbi-value-title"><%:Username%></label> <div class="cbi-value-field"> - <input class="cbi-input-user" type="text" name="username" value="<%=duser%>" /> + <input class="cbi-input-user" type="text" name="luci_username" value="<%=duser%>" /> </div> </div> <div class="cbi-value cbi-value-last"> <label class="cbi-value-title"><%:Password%></label> <div class="cbi-value-field"> - <input id="focus_password" class="cbi-input-password" type="password" name="password" /> + <input class="cbi-input-password" type="password" name="luci_password" /> </div> </div> </fieldset></fieldset> @@ -45,7 +45,7 @@ You may obtain a copy of the License at </div> </form> <script type="text/javascript">//<![CDATA[ - var input = document.getElementById('focus_password'); + var input = document.getElementsByName('luci_password')[0]; if (input) input.focus(); //]]></script> |