1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Licensed to the public under the Apache License 2.0.
4 local wa = require "luci.tools.webadmin"
5 local nw = require "luci.model.network"
6 local ut = require "luci.util"
7 local nt = require "luci.sys".net
8 local fs = require "nixio.fs"
12 m = Map("wireless", "",
13 translate("The <em>Device Configuration</em> section covers physical settings of the radio " ..
14 "hardware such as channel, transmit power or antenna selection which are shared among all " ..
15 "defined wireless networks (if the radio hardware is multi-SSID capable). Per network settings " ..
16 "like encryption or operation mode are grouped in the <em>Interface Configuration</em>."))
20 m.redirect = luci.dispatcher.build_url("admin/network/wireless")
24 function m.on_commit(map)
25 local wnet = nw:get_wifinet(arg[1])
26 if ifsection and wnet then
27 ifsection.section = wnet.sid
28 m.title = luci.util.pcdata(wnet:get_i18n())
34 local wnet = nw:get_wifinet(arg[1])
35 local wdev = wnet and wnet:get_device()
37 -- redirect to overview page if network does not exist anymore (e.g. after a revert)
38 if not wnet or not wdev then
39 luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
43 -- wireless toggle was requested, commit and reload page
45 local new_cc = m:formvalue("cbid.wireless.%s.country" % wdev:name())
46 local old_cc = m:get(wdev:name(), "country")
48 if m:formvalue("cbid.wireless.%s.__toggle" % wdev:name()) then
49 if wdev:get("disabled") == "1" or wnet:get("disabled") == "1" then
50 wnet:set("disabled", nil)
52 wnet:set("disabled", "1")
54 wdev:set("disabled", nil)
57 luci.sys.call("(env -i /bin/ubus call network reload) >/dev/null 2>/dev/null")
59 luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless", arg[1]))
65 if m:get(wdev:name(), "type") == "mac80211" and new_cc and new_cc ~= old_cc then
66 luci.sys.call("iw reg set %q" % new_cc)
67 luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless", arg[1]))
72 m.title = luci.util.pcdata(wnet:get_i18n())
75 local function txpower_list(iw)
76 local list = iw.txpwrlist or { }
77 local off = tonumber(iw.txpower_offset) or 0
81 for _, val in ipairs(list) do
82 local dbm = val.dbm + off
83 local mw = math.floor(10 ^ (dbm / 10))
97 local function txpower_current(pwr, list)
101 for _, item in ipairs(list) do
102 if item.driver_dbm >= pwr then
103 return item.driver_dbm
110 local iw = luci.sys.wifi.getiwinfo(arg[1])
111 local hw_modes = iw.hwmodelist or { }
112 local tx_power_list = txpower_list(iw)
113 local tx_power_cur = txpower_current(wdev:get("txpower"), tx_power_list)
115 s = m:section(NamedSection, wdev:name(), "wifi-device", translate("Device Configuration"))
118 s:tab("general", translate("General Setup"))
119 s:tab("macfilter", translate("MAC-Filter"))
120 s:tab("advanced", translate("Advanced Settings"))
123 back = s:option(DummyValue, "_overview", translate("Overview"))
125 back.titleref = luci.dispatcher.build_url("admin", "network", "wireless")
128 st = s:taboption("general", DummyValue, "__status", translate("Status"))
129 st.template = "admin_network/wifi_status"
132 en = s:taboption("general", Button, "__toggle")
134 if wdev:get("disabled") == "1" or wnet:get("disabled") == "1" then
135 en.title = translate("Wireless network is disabled")
136 en.inputtitle = translate("Enable")
137 en.inputstyle = "apply"
139 en.title = translate("Wireless network is enabled")
140 en.inputtitle = translate("Disable")
141 en.inputstyle = "reset"
145 local hwtype = wdev:get("type")
148 local nsantenna = wdev:get("antenna")
150 -- Check whether there are client interfaces on the same radio,
151 -- if yes, lock the channel choice as these stations will dicatate the freq
152 local found_sta = nil
154 if wnet:mode() ~= "sta" then
155 for _, net in ipairs(wdev:get_wifinets()) do
156 if net:mode() == "sta" and net:get("disabled") ~= "1" then
157 if not found_sta then
159 found_sta.channel = net:channel()
162 found_sta.names[#found_sta.names+1] = net:shortname()
168 ch = s:taboption("general", DummyValue, "choice", translate("Channel"))
169 ch.value = translatef("Locked to channel %s used by: %s",
170 found_sta.channel or "(auto)", table.concat(found_sta.names, ", "))
172 ch = s:taboption("general", Value, "_mode_freq", '<br />'..translate("Operating frequency"))
173 ch.hwmodes = hw_modes
174 ch.htmodes = iw.htmodelist
175 ch.freqlist = iw.freqlist
176 ch.template = "cbi/wireless_modefreq"
178 function ch.cfgvalue(self, section)
180 m:get(section, "hwmode") or "",
181 m:get(section, "channel") or "auto",
182 m:get(section, "htmode") or ""
186 function ch.formvalue(self, section)
188 m:formvalue(self:cbid(section) .. ".band") or (hw_modes.g and "11g" or "11a"),
189 m:formvalue(self:cbid(section) .. ".channel") or "auto",
190 m:formvalue(self:cbid(section) .. ".htmode") or ""
194 function ch.write(self, section, value)
195 m:set(section, "hwmode", value[1])
196 m:set(section, "channel", value[2])
197 m:set(section, "htmode", value[3])
201 ------------------- MAC80211 Device ------------------
203 if hwtype == "mac80211" then
204 if #tx_power_list > 0 then
205 tp = s:taboption("general", ListValue,
206 "txpower", translate("Transmit Power"), "dBm")
208 tp.default = tx_power_cur
209 function tp.cfgvalue(...)
210 return txpower_current(Value.cfgvalue(...), tx_power_list)
213 tp:value("", translate("auto"))
214 for _, p in ipairs(tx_power_list) do
215 tp:value(p.driver_dbm, "%i dBm (%i mW)"
216 %{ p.display_dbm, p.display_mw })
220 local cl = iw and iw.countrylist
221 if cl and #cl > 0 then
222 cc = s:taboption("advanced", ListValue, "country", translate("Country Code"), translate("Use ISO/IEC 3166 alpha2 country codes."))
223 cc.default = tostring(iw and iw.country or "00")
224 for _, c in ipairs(cl) do
225 cc:value(c.alpha2, "%s - %s" %{ c.alpha2, c.name })
228 s:taboption("advanced", Value, "country", translate("Country Code"), translate("Use ISO/IEC 3166 alpha2 country codes."))
231 s:taboption("advanced", Value, "distance", translate("Distance Optimization"),
232 translate("Distance to farthest network member in meters."))
234 -- external antenna profiles
235 local eal = iw and iw.extant
236 if eal and #eal > 0 then
237 ea = s:taboption("advanced", ListValue, "extant", translate("Antenna Configuration"))
238 for _, eap in ipairs(eal) do
239 ea:value(eap.id, "%s (%s)" %{ eap.name, eap.description })
246 s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
247 s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
251 ------------------- Madwifi Device ------------------
253 if hwtype == "atheros" then
254 tp = s:taboption("general",
255 (#tx_power_list > 0) and ListValue or Value,
256 "txpower", translate("Transmit Power"), "dBm")
259 tp.default = tx_power_cur
261 function tp.cfgvalue(...)
262 return txpower_current(Value.cfgvalue(...), tx_power_list)
265 tp:value("", translate("auto"))
266 for _, p in ipairs(tx_power_list) do
267 tp:value(p.driver_dbm, "%i dBm (%i mW)"
268 %{ p.display_dbm, p.display_mw })
271 s:taboption("advanced", Flag, "diversity", translate("Diversity")).rmempty = false
273 if not nsantenna then
274 ant1 = s:taboption("advanced", ListValue, "txantenna", translate("Transmitter Antenna"))
275 ant1.widget = "radio"
276 ant1.orientation = "horizontal"
277 ant1:depends("diversity", "")
278 ant1:value("0", translate("auto"))
279 ant1:value("1", translate("Antenna 1"))
280 ant1:value("2", translate("Antenna 2"))
282 ant2 = s:taboption("advanced", ListValue, "rxantenna", translate("Receiver Antenna"))
283 ant2.widget = "radio"
284 ant2.orientation = "horizontal"
285 ant2:depends("diversity", "")
286 ant2:value("0", translate("auto"))
287 ant2:value("1", translate("Antenna 1"))
288 ant2:value("2", translate("Antenna 2"))
291 local ant = s:taboption("advanced", ListValue, "antenna", translate("Transmitter Antenna"))
293 ant:value("vertical")
294 ant:value("horizontal")
295 ant:value("external")
298 s:taboption("advanced", Value, "distance", translate("Distance Optimization"),
299 translate("Distance to farthest network member in meters."))
300 s:taboption("advanced", Value, "regdomain", translate("Regulatory Domain"))
301 s:taboption("advanced", Value, "country", translate("Country Code"))
302 s:taboption("advanced", Flag, "outdoor", translate("Outdoor Channels"))
304 --s:option(Flag, "nosbeacon", translate("Disable HW-Beacon timer"))
309 ------------------- Broadcom Device ------------------
311 if hwtype == "broadcom" then
312 tp = s:taboption("general",
313 (#tx_power_list > 0) and ListValue or Value,
314 "txpower", translate("Transmit Power"), "dBm")
317 tp.default = tx_power_cur
319 function tp.cfgvalue(...)
320 return txpower_current(Value.cfgvalue(...), tx_power_list)
323 tp:value("", translate("auto"))
324 for _, p in ipairs(tx_power_list) do
325 tp:value(p.driver_dbm, "%i dBm (%i mW)"
326 %{ p.display_dbm, p.display_mw })
329 mode = s:taboption("advanced", ListValue, "hwmode", translate("Band"))
331 mode:value("11b", "2.4GHz (802.11b)")
333 mode:value("11bg", "2.4GHz (802.11b+g)")
337 mode:value("11g", "2.4GHz (802.11g)")
338 mode:value("11gst", "2.4GHz (802.11g + Turbo)")
339 mode:value("11lrs", "2.4GHz (802.11g Limited Rate Support)")
341 if hw_modes.a then mode:value("11a", "5GHz (802.11a)") end
344 mode:value("11ng", "2.4GHz (802.11g+n)")
345 mode:value("11n", "2.4GHz (802.11n)")
348 mode:value("11na", "5GHz (802.11a+n)")
349 mode:value("11n", "5GHz (802.11n)")
351 htmode = s:taboption("advanced", ListValue, "htmode", translate("HT mode (802.11n)"))
352 htmode:depends("hwmode", "11ng")
353 htmode:depends("hwmode", "11na")
354 htmode:depends("hwmode", "11n")
355 htmode:value("HT20", "20MHz")
356 htmode:value("HT40", "40MHz")
359 ant1 = s:taboption("advanced", ListValue, "txantenna", translate("Transmitter Antenna"))
360 ant1.widget = "radio"
361 ant1:depends("diversity", "")
362 ant1:value("3", translate("auto"))
363 ant1:value("0", translate("Antenna 1"))
364 ant1:value("1", translate("Antenna 2"))
366 ant2 = s:taboption("advanced", ListValue, "rxantenna", translate("Receiver Antenna"))
367 ant2.widget = "radio"
368 ant2:depends("diversity", "")
369 ant2:value("3", translate("auto"))
370 ant2:value("0", translate("Antenna 1"))
371 ant2:value("1", translate("Antenna 2"))
373 s:taboption("advanced", Flag, "frameburst", translate("Frame Bursting"))
375 s:taboption("advanced", Value, "distance", translate("Distance Optimization"))
376 --s:option(Value, "slottime", translate("Slot time"))
378 s:taboption("advanced", Value, "country", translate("Country Code"))
379 s:taboption("advanced", Value, "maxassoc", translate("Connection Limit"))
383 --------------------- HostAP Device ---------------------
385 if hwtype == "prism2" then
386 s:taboption("advanced", Value, "txpower", translate("Transmit Power"), "att units").rmempty = true
388 s:taboption("advanced", Flag, "diversity", translate("Diversity")).rmempty = false
390 s:taboption("advanced", Value, "txantenna", translate("Transmitter Antenna"))
391 s:taboption("advanced", Value, "rxantenna", translate("Receiver Antenna"))
395 ----------------------- Interface -----------------------
397 s = m:section(NamedSection, wnet.sid, "wifi-iface", translate("Interface Configuration"))
401 s.defaults.device = wdev:name()
403 s:tab("general", translate("General Setup"))
404 s:tab("encryption", translate("Wireless Security"))
405 s:tab("macfilter", translate("MAC-Filter"))
406 s:tab("advanced", translate("Advanced Settings"))
408 mode = s:taboption("general", ListValue, "mode", translate("Mode"))
409 mode.override_values = true
410 mode:value("ap", translate("Access Point"))
411 mode:value("sta", translate("Client"))
412 mode:value("adhoc", translate("Ad-Hoc"))
414 meshid = s:taboption("general", Value, "mesh_id", translate("Mesh Id"))
415 meshid:depends({mode="mesh"})
417 ssid = s:taboption("general", Value, "ssid", translate("<abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
418 ssid.datatype = "maxlength(32)"
419 ssid:depends({mode="ap"})
420 ssid:depends({mode="sta"})
421 ssid:depends({mode="adhoc"})
422 ssid:depends({mode="ahdemo"})
423 ssid:depends({mode="monitor"})
424 ssid:depends({mode="ap-wds"})
425 ssid:depends({mode="sta-wds"})
426 ssid:depends({mode="wds"})
428 bssid = s:taboption("general", Value, "bssid", translate("<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"))
430 network = s:taboption("general", Value, "network", translate("Network"),
431 translate("Choose the network(s) you want to attach to this wireless interface or " ..
432 "fill out the <em>create</em> field to define a new network."))
434 network.rmempty = true
435 network.template = "cbi/network_netlist"
436 network.widget = "checkbox"
437 network.novirtual = true
439 function network.write(self, section, value)
440 local i = nw:get_interface(section)
443 value = m:formvalue(self:cbid(section) .. ".newnet")
444 if value and #value > 0 then
445 local n = nw:add_network(value, {proto="none"})
446 if n then n:add_interface(i) end
448 local n = i:get_network()
449 if n then n:del_interface(i) end
453 for _, v in ipairs(i:get_networks()) do
456 for v in ut.imatch(value) do
457 local n = nw:get_network(v)
459 if not n:is_empty() then
460 n:set("type", "bridge")
469 -------------------- MAC80211 Interface ----------------------
471 if hwtype == "mac80211" then
472 if fs.access("/usr/sbin/iw") then
473 mode:value("mesh", "802.11s")
476 mode:value("ahdemo", translate("Pseudo Ad-Hoc (ahdemo)"))
477 mode:value("monitor", translate("Monitor"))
478 bssid:depends({mode="adhoc"})
479 bssid:depends({mode="sta"})
480 bssid:depends({mode="sta-wds"})
482 mp = s:taboption("macfilter", ListValue, "macfilter", translate("MAC-Address Filter"))
483 mp:depends({mode="ap"})
484 mp:depends({mode="ap-wds"})
485 mp:value("", translate("disable"))
486 mp:value("allow", translate("Allow listed only"))
487 mp:value("deny", translate("Allow all except listed"))
489 ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List"))
490 ml.datatype = "macaddr"
491 ml:depends({macfilter="allow"})
492 ml:depends({macfilter="deny"})
493 nt.mac_hints(function(mac, name) ml:value(mac, "%s (%s)" %{ mac, name }) end)
495 mode:value("ap-wds", "%s (%s)" % {translate("Access Point"), translate("WDS")})
496 mode:value("sta-wds", "%s (%s)" % {translate("Client"), translate("WDS")})
498 function mode.write(self, section, value)
499 if value == "ap-wds" then
500 ListValue.write(self, section, "ap")
501 m.uci:set("wireless", section, "wds", 1)
502 elseif value == "sta-wds" then
503 ListValue.write(self, section, "sta")
504 m.uci:set("wireless", section, "wds", 1)
506 ListValue.write(self, section, value)
507 m.uci:delete("wireless", section, "wds")
511 function mode.cfgvalue(self, section)
512 local mode = ListValue.cfgvalue(self, section)
513 local wds = m.uci:get("wireless", section, "wds") == "1"
515 if mode == "ap" and wds then
517 elseif mode == "sta" and wds then
524 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
525 hidden:depends({mode="ap"})
526 hidden:depends({mode="ap-wds"})
528 wmm = s:taboption("general", Flag, "wmm", translate("WMM Mode"))
529 wmm:depends({mode="ap"})
530 wmm:depends({mode="ap-wds"})
531 wmm.default = wmm.enabled
533 ifname = s:taboption("advanced", Value, "ifname", translate("Interface name"), translate("Override default interface name"))
534 ifname.optional = true
539 -------------------- Madwifi Interface ----------------------
541 if hwtype == "atheros" then
542 mode:value("ahdemo", translate("Pseudo Ad-Hoc (ahdemo)"))
543 mode:value("monitor", translate("Monitor"))
544 mode:value("ap-wds", "%s (%s)" % {translate("Access Point"), translate("WDS")})
545 mode:value("sta-wds", "%s (%s)" % {translate("Client"), translate("WDS")})
546 mode:value("wds", translate("Static WDS"))
548 function mode.write(self, section, value)
549 if value == "ap-wds" then
550 ListValue.write(self, section, "ap")
551 m.uci:set("wireless", section, "wds", 1)
552 elseif value == "sta-wds" then
553 ListValue.write(self, section, "sta")
554 m.uci:set("wireless", section, "wds", 1)
556 ListValue.write(self, section, value)
557 m.uci:delete("wireless", section, "wds")
561 function mode.cfgvalue(self, section)
562 local mode = ListValue.cfgvalue(self, section)
563 local wds = m.uci:get("wireless", section, "wds") == "1"
565 if mode == "ap" and wds then
567 elseif mode == "sta" and wds then
574 bssid:depends({mode="adhoc"})
575 bssid:depends({mode="ahdemo"})
576 bssid:depends({mode="wds"})
578 wdssep = s:taboption("advanced", Flag, "wdssep", translate("Separate WDS"))
579 wdssep:depends({mode="ap-wds"})
581 s:taboption("advanced", Flag, "doth", "802.11h")
582 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
583 hidden:depends({mode="ap"})
584 hidden:depends({mode="adhoc"})
585 hidden:depends({mode="ap-wds"})
586 hidden:depends({mode="sta-wds"})
587 isolate = s:taboption("advanced", Flag, "isolate", translate("Separate Clients"),
588 translate("Prevents client-to-client communication"))
589 isolate:depends({mode="ap"})
590 s:taboption("advanced", Flag, "bgscan", translate("Background Scan"))
592 mp = s:taboption("macfilter", ListValue, "macpolicy", translate("MAC-Address Filter"))
593 mp:value("", translate("disable"))
594 mp:value("allow", translate("Allow listed only"))
595 mp:value("deny", translate("Allow all except listed"))
597 ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List"))
598 ml.datatype = "macaddr"
599 ml:depends({macpolicy="allow"})
600 ml:depends({macpolicy="deny"})
601 nt.mac_hints(function(mac, name) ml:value(mac, "%s (%s)" %{ mac, name }) end)
603 s:taboption("advanced", Value, "rate", translate("Transmission Rate"))
604 s:taboption("advanced", Value, "mcast_rate", translate("Multicast Rate"))
605 s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
606 s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
607 s:taboption("advanced", Value, "minrate", translate("Minimum Rate"))
608 s:taboption("advanced", Value, "maxrate", translate("Maximum Rate"))
609 s:taboption("advanced", Flag, "compression", translate("Compression"))
611 s:taboption("advanced", Flag, "bursting", translate("Frame Bursting"))
612 s:taboption("advanced", Flag, "turbo", translate("Turbo Mode"))
613 s:taboption("advanced", Flag, "ff", translate("Fast Frames"))
615 s:taboption("advanced", Flag, "wmm", translate("WMM Mode"))
616 s:taboption("advanced", Flag, "xr", translate("XR Support"))
617 s:taboption("advanced", Flag, "ar", translate("AR Support"))
619 local swm = s:taboption("advanced", Flag, "sw_merge", translate("Disable HW-Beacon timer"))
620 swm:depends({mode="adhoc"})
622 local nos = s:taboption("advanced", Flag, "nosbeacon", translate("Disable HW-Beacon timer"))
623 nos:depends({mode="sta"})
624 nos:depends({mode="sta-wds"})
626 local probereq = s:taboption("advanced", Flag, "probereq", translate("Do not send probe responses"))
627 probereq.enabled = "0"
628 probereq.disabled = "1"
632 -------------------- Broadcom Interface ----------------------
634 if hwtype == "broadcom" then
635 mode:value("wds", translate("WDS"))
636 mode:value("monitor", translate("Monitor"))
638 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
639 hidden:depends({mode="ap"})
640 hidden:depends({mode="adhoc"})
641 hidden:depends({mode="wds"})
643 isolate = s:taboption("advanced", Flag, "isolate", translate("Separate Clients"),
644 translate("Prevents client-to-client communication"))
645 isolate:depends({mode="ap"})
647 s:taboption("advanced", Flag, "doth", "802.11h")
648 s:taboption("advanced", Flag, "wmm", translate("WMM Mode"))
650 bssid:depends({mode="wds"})
651 bssid:depends({mode="adhoc"})
655 ----------------------- HostAP Interface ---------------------
657 if hwtype == "prism2" then
658 mode:value("wds", translate("WDS"))
659 mode:value("monitor", translate("Monitor"))
661 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
662 hidden:depends({mode="ap"})
663 hidden:depends({mode="adhoc"})
664 hidden:depends({mode="wds"})
666 bssid:depends({mode="sta"})
668 mp = s:taboption("macfilter", ListValue, "macpolicy", translate("MAC-Address Filter"))
669 mp:value("", translate("disable"))
670 mp:value("allow", translate("Allow listed only"))
671 mp:value("deny", translate("Allow all except listed"))
672 ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List"))
673 ml:depends({macpolicy="allow"})
674 ml:depends({macpolicy="deny"})
675 nt.mac_hints(function(mac, name) ml:value(mac, "%s (%s)" %{ mac, name }) end)
677 s:taboption("advanced", Value, "rate", translate("Transmission Rate"))
678 s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
679 s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
683 ------------------- WiFI-Encryption -------------------
685 encr = s:taboption("encryption", ListValue, "encryption", translate("Encryption"))
686 encr.override_values = true
687 encr.override_depends = true
688 encr:depends({mode="ap"})
689 encr:depends({mode="sta"})
690 encr:depends({mode="adhoc"})
691 encr:depends({mode="ahdemo"})
692 encr:depends({mode="ap-wds"})
693 encr:depends({mode="sta-wds"})
694 encr:depends({mode="mesh"})
696 cipher = s:taboption("encryption", ListValue, "cipher", translate("Cipher"))
697 cipher:depends({encryption="wpa"})
698 cipher:depends({encryption="wpa2"})
699 cipher:depends({encryption="psk"})
700 cipher:depends({encryption="psk2"})
701 cipher:depends({encryption="wpa-mixed"})
702 cipher:depends({encryption="psk-mixed"})
703 cipher:value("auto", translate("auto"))
704 cipher:value("ccmp", translate("Force CCMP (AES)"))
705 cipher:value("tkip", translate("Force TKIP"))
706 cipher:value("tkip+ccmp", translate("Force TKIP and CCMP (AES)"))
708 function encr.cfgvalue(self, section)
709 local v = tostring(ListValue.cfgvalue(self, section))
712 elseif v and v:match("%+") then
713 return (v:gsub("%+.+$", ""))
718 function encr.write(self, section, value)
719 local e = tostring(encr:formvalue(section))
720 local c = tostring(cipher:formvalue(section))
721 if value == "wpa" or value == "wpa2" then
722 self.map.uci:delete("wireless", section, "key")
724 if e and (c == "tkip" or c == "ccmp" or c == "tkip+ccmp") then
727 self.map:set(section, "encryption", e)
730 function cipher.cfgvalue(self, section)
731 local v = tostring(ListValue.cfgvalue(encr, section))
732 if v and v:match("%+") then
733 v = v:gsub("^[^%+]+%+", "")
734 if v == "aes" then v = "ccmp"
735 elseif v == "tkip+aes" then v = "tkip+ccmp"
736 elseif v == "aes+tkip" then v = "tkip+ccmp"
737 elseif v == "ccmp+tkip" then v = "tkip+ccmp"
743 function cipher.write(self, section)
744 return encr:write(section)
748 encr:value("none", "No Encryption")
749 encr:value("wep-open", translate("WEP Open System"), {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"}, {mode="ahdemo"}, {mode="wds"})
750 encr:value("wep-shared", translate("WEP Shared Key"), {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"}, {mode="ahdemo"}, {mode="wds"})
752 if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
753 local supplicant = fs.access("/usr/sbin/wpa_supplicant")
754 local hostapd = fs.access("/usr/sbin/hostapd")
757 local has_ap_eap = (os.execute("hostapd -veap >/dev/null 2>/dev/null") == 0)
758 local has_sta_eap = (os.execute("wpa_supplicant -veap >/dev/null 2>/dev/null") == 0)
760 if hostapd and supplicant then
761 encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
762 encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
763 encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
764 if has_ap_eap and has_sta_eap then
765 encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
766 encr:value("wpa2", "WPA2-EAP", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
768 elseif hostapd and not supplicant then
769 encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="ap-wds"})
770 encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="ap-wds"})
771 encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="ap"}, {mode="ap-wds"})
773 encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="ap-wds"})
774 encr:value("wpa2", "WPA2-EAP", {mode="ap"}, {mode="ap-wds"})
776 encr.description = translate(
777 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
778 "and ad-hoc mode) to be installed."
780 elseif not hostapd and supplicant then
781 encr:value("psk", "WPA-PSK", {mode="sta"}, {mode="sta-wds"})
782 encr:value("psk2", "WPA2-PSK", {mode="sta"}, {mode="sta-wds"})
783 encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="sta"}, {mode="sta-wds"})
785 encr:value("wpa", "WPA-EAP", {mode="sta"}, {mode="sta-wds"})
786 encr:value("wpa2", "WPA2-EAP", {mode="sta"}, {mode="sta-wds"})
788 encr.description = translate(
789 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
790 "and ad-hoc mode) to be installed."
793 encr.description = translate(
794 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
795 "and ad-hoc mode) to be installed."
798 elseif hwtype == "broadcom" then
799 encr:value("psk", "WPA-PSK")
800 encr:value("psk2", "WPA2-PSK")
801 encr:value("psk+psk2", "WPA-PSK/WPA2-PSK Mixed Mode")
804 auth_server = s:taboption("encryption", Value, "auth_server", translate("Radius-Authentication-Server"))
805 auth_server:depends({mode="ap", encryption="wpa"})
806 auth_server:depends({mode="ap", encryption="wpa2"})
807 auth_server:depends({mode="ap-wds", encryption="wpa"})
808 auth_server:depends({mode="ap-wds", encryption="wpa2"})
809 auth_server.rmempty = true
810 auth_server.datatype = "host(0)"
812 auth_port = s:taboption("encryption", Value, "auth_port", translate("Radius-Authentication-Port"), translatef("Default %d", 1812))
813 auth_port:depends({mode="ap", encryption="wpa"})
814 auth_port:depends({mode="ap", encryption="wpa2"})
815 auth_port:depends({mode="ap-wds", encryption="wpa"})
816 auth_port:depends({mode="ap-wds", encryption="wpa2"})
817 auth_port.rmempty = true
818 auth_port.datatype = "port"
820 auth_secret = s:taboption("encryption", Value, "auth_secret", translate("Radius-Authentication-Secret"))
821 auth_secret:depends({mode="ap", encryption="wpa"})
822 auth_secret:depends({mode="ap", encryption="wpa2"})
823 auth_secret:depends({mode="ap-wds", encryption="wpa"})
824 auth_secret:depends({mode="ap-wds", encryption="wpa2"})
825 auth_secret.rmempty = true
826 auth_secret.password = true
828 acct_server = s:taboption("encryption", Value, "acct_server", translate("Radius-Accounting-Server"))
829 acct_server:depends({mode="ap", encryption="wpa"})
830 acct_server:depends({mode="ap", encryption="wpa2"})
831 acct_server:depends({mode="ap-wds", encryption="wpa"})
832 acct_server:depends({mode="ap-wds", encryption="wpa2"})
833 acct_server.rmempty = true
834 acct_server.datatype = "host(0)"
836 acct_port = s:taboption("encryption", Value, "acct_port", translate("Radius-Accounting-Port"), translatef("Default %d", 1813))
837 acct_port:depends({mode="ap", encryption="wpa"})
838 acct_port:depends({mode="ap", encryption="wpa2"})
839 acct_port:depends({mode="ap-wds", encryption="wpa"})
840 acct_port:depends({mode="ap-wds", encryption="wpa2"})
841 acct_port.rmempty = true
842 acct_port.datatype = "port"
844 acct_secret = s:taboption("encryption", Value, "acct_secret", translate("Radius-Accounting-Secret"))
845 acct_secret:depends({mode="ap", encryption="wpa"})
846 acct_secret:depends({mode="ap", encryption="wpa2"})
847 acct_secret:depends({mode="ap-wds", encryption="wpa"})
848 acct_secret:depends({mode="ap-wds", encryption="wpa2"})
849 acct_secret.rmempty = true
850 acct_secret.password = true
852 wpakey = s:taboption("encryption", Value, "_wpa_key", translate("Key"))
853 wpakey:depends("encryption", "psk")
854 wpakey:depends("encryption", "psk2")
855 wpakey:depends("encryption", "psk+psk2")
856 wpakey:depends("encryption", "psk-mixed")
857 wpakey.datatype = "wpakey"
858 wpakey.rmempty = true
859 wpakey.password = true
861 wpakey.cfgvalue = function(self, section, value)
862 local key = m.uci:get("wireless", section, "key")
863 if key == "1" or key == "2" or key == "3" or key == "4" then
869 wpakey.write = function(self, section, value)
870 self.map.uci:set("wireless", section, "key", value)
871 self.map.uci:delete("wireless", section, "key1")
875 wepslot = s:taboption("encryption", ListValue, "_wep_key", translate("Used Key Slot"))
876 wepslot:depends("encryption", "wep-open")
877 wepslot:depends("encryption", "wep-shared")
878 wepslot:value("1", translatef("Key #%d", 1))
879 wepslot:value("2", translatef("Key #%d", 2))
880 wepslot:value("3", translatef("Key #%d", 3))
881 wepslot:value("4", translatef("Key #%d", 4))
883 wepslot.cfgvalue = function(self, section)
884 local slot = tonumber(m.uci:get("wireless", section, "key"))
885 if not slot or slot < 1 or slot > 4 then
891 wepslot.write = function(self, section, value)
892 self.map.uci:set("wireless", section, "key", value)
897 wepkey = s:taboption("encryption", Value, "key" .. slot, translatef("Key #%d", slot))
898 wepkey:depends("encryption", "wep-open")
899 wepkey:depends("encryption", "wep-shared")
900 wepkey.datatype = "wepkey"
901 wepkey.rmempty = true
902 wepkey.password = true
904 function wepkey.write(self, section, value)
905 if value and (#value == 5 or #value == 13) then
906 value = "s:" .. value
908 return Value.write(self, section, value)
913 if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
915 -- Probe 802.11r support (and EAP support as a proxy for Openwrt)
916 local has_80211r = (os.execute("hostapd -v11r 2>/dev/null || hostapd -veap 2>/dev/null") == 0)
918 ieee80211r = s:taboption("encryption", Flag, "ieee80211r",
919 translate("802.11r Fast Transition"),
920 translate("Enables fast roaming among access points that belong " ..
921 "to the same Mobility Domain"))
922 ieee80211r:depends({mode="ap", encryption="wpa"})
923 ieee80211r:depends({mode="ap", encryption="wpa2"})
924 ieee80211r:depends({mode="ap-wds", encryption="wpa"})
925 ieee80211r:depends({mode="ap-wds", encryption="wpa2"})
927 ieee80211r:depends({mode="ap", encryption="psk"})
928 ieee80211r:depends({mode="ap", encryption="psk2"})
929 ieee80211r:depends({mode="ap", encryption="psk-mixed"})
931 ieee80211r.rmempty = true
933 nasid = s:taboption("encryption", Value, "nasid", translate("NAS ID"),
934 translate("Used for two different purposes: RADIUS NAS ID and " ..
935 "802.11r R0KH-ID. Not needed with normal WPA(2)-PSK."))
936 nasid:depends({mode="ap", encryption="wpa"})
937 nasid:depends({mode="ap", encryption="wpa2"})
938 nasid:depends({mode="ap-wds", encryption="wpa"})
939 nasid:depends({mode="ap-wds", encryption="wpa2"})
940 nasid:depends({ieee80211r="1"})
943 mobility_domain = s:taboption("encryption", Value, "mobility_domain",
944 translate("Mobility Domain"),
945 translate("4-character hexadecimal ID"))
946 mobility_domain:depends({ieee80211r="1"})
947 mobility_domain.placeholder = "4f57"
948 mobility_domain.datatype = "and(hexstring,rangelength(4,4))"
949 mobility_domain.rmempty = true
951 r0_key_lifetime = s:taboption("encryption", Value, "r0_key_lifetime",
952 translate("R0 Key Lifetime"), translate("minutes"))
953 r0_key_lifetime:depends({ieee80211r="1"})
954 r0_key_lifetime.placeholder = "10000"
955 r0_key_lifetime.datatype = "uinteger"
956 r0_key_lifetime.rmempty = true
958 r1_key_holder = s:taboption("encryption", Value, "r1_key_holder",
959 translate("R1 Key Holder"),
960 translate("6-octet identifier as a hex string - no colons"))
961 r1_key_holder:depends({ieee80211r="1"})
962 r1_key_holder.placeholder = "00004f577274"
963 r1_key_holder.datatype = "and(hexstring,rangelength(12,12))"
964 r1_key_holder.rmempty = true
966 reassociation_deadline = s:taboption("encryption", Value, "reassociation_deadline",
967 translate("Reassociation Deadline"),
968 translate("time units (TUs / 1.024 ms) [1000-65535]"))
969 reassociation_deadline:depends({ieee80211r="1"})
970 reassociation_deadline.placeholder = "1000"
971 reassociation_deadline.datatype = "range(1000,65535)"
972 reassociation_deadline.rmempty = true
974 pmk_r1_push = s:taboption("encryption", Flag, "pmk_r1_push", translate("PMK R1 Push"))
975 pmk_r1_push:depends({ieee80211r="1"})
976 pmk_r1_push.placeholder = "0"
977 pmk_r1_push.rmempty = true
979 r0kh = s:taboption("encryption", DynamicList, "r0kh", translate("External R0 Key Holder List"),
980 translate("List of R0KHs in the same Mobility Domain. " ..
981 "<br />Format: MAC-address,NAS-Identifier,128-bit key as hex string. " ..
982 "<br />This list is used to map R0KH-ID (NAS Identifier) to a destination " ..
983 "MAC address when requesting PMK-R1 key from the R0KH that the STA " ..
984 "used during the Initial Mobility Domain Association."))
986 r0kh:depends({ieee80211r="1"})
989 r1kh = s:taboption("encryption", DynamicList, "r1kh", translate("External R1 Key Holder List"),
990 translate ("List of R1KHs in the same Mobility Domain. "..
991 "<br />Format: MAC-address,R1KH-ID as 6 octets with colons,128-bit key as hex string. "..
992 "<br />This list is used to map R1KH-ID to a destination MAC address " ..
993 "when sending PMK-R1 key from the R0KH. This is also the " ..
994 "list of authorized R1KHs in the MD that can request PMK-R1 keys."))
995 r1kh:depends({ieee80211r="1"})
997 -- End of 802.11r options
999 eaptype = s:taboption("encryption", ListValue, "eap_type", translate("EAP-Method"))
1000 eaptype:value("tls", "TLS")
1001 eaptype:value("ttls", "TTLS")
1002 eaptype:value("peap", "PEAP")
1003 eaptype:value("fast", "FAST")
1004 eaptype:depends({mode="sta", encryption="wpa"})
1005 eaptype:depends({mode="sta", encryption="wpa2"})
1006 eaptype:depends({mode="sta-wds", encryption="wpa"})
1007 eaptype:depends({mode="sta-wds", encryption="wpa2"})
1009 cacert = s:taboption("encryption", FileUpload, "ca_cert", translate("Path to CA-Certificate"))
1010 cacert:depends({mode="sta", encryption="wpa"})
1011 cacert:depends({mode="sta", encryption="wpa2"})
1012 cacert:depends({mode="sta-wds", encryption="wpa"})
1013 cacert:depends({mode="sta-wds", encryption="wpa2"})
1014 cacert.rmempty = true
1016 clientcert = s:taboption("encryption", FileUpload, "client_cert", translate("Path to Client-Certificate"))
1017 clientcert:depends({mode="sta", eap_type="tls", encryption="wpa"})
1018 clientcert:depends({mode="sta", eap_type="tls", encryption="wpa2"})
1019 clientcert:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
1020 clientcert:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
1022 privkey = s:taboption("encryption", FileUpload, "priv_key", translate("Path to Private Key"))
1023 privkey:depends({mode="sta", eap_type="tls", encryption="wpa2"})
1024 privkey:depends({mode="sta", eap_type="tls", encryption="wpa"})
1025 privkey:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
1026 privkey:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
1028 privkeypwd = s:taboption("encryption", Value, "priv_key_pwd", translate("Password of Private Key"))
1029 privkeypwd:depends({mode="sta", eap_type="tls", encryption="wpa2"})
1030 privkeypwd:depends({mode="sta", eap_type="tls", encryption="wpa"})
1031 privkeypwd:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
1032 privkeypwd:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
1033 privkeypwd.rmempty = true
1034 privkeypwd.password = true
1036 auth = s:taboption("encryption", ListValue, "auth", translate("Authentication"))
1037 auth:value("PAP", "PAP", {eap_type="ttls"})
1038 auth:value("CHAP", "CHAP", {eap_type="ttls"})
1039 auth:value("MSCHAP", "MSCHAP", {eap_type="ttls"})
1040 auth:value("MSCHAPV2", "MSCHAPv2", {eap_type="ttls"})
1041 auth:value("EAP-GTC")
1042 auth:value("EAP-MD5")
1043 auth:value("EAP-MSCHAPV2")
1044 auth:value("EAP-TLS")
1045 auth:depends({mode="sta", eap_type="fast", encryption="wpa2"})
1046 auth:depends({mode="sta", eap_type="fast", encryption="wpa"})
1047 auth:depends({mode="sta", eap_type="peap", encryption="wpa2"})
1048 auth:depends({mode="sta", eap_type="peap", encryption="wpa"})
1049 auth:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
1050 auth:depends({mode="sta", eap_type="ttls", encryption="wpa"})
1051 auth:depends({mode="sta-wds", eap_type="fast", encryption="wpa2"})
1052 auth:depends({mode="sta-wds", eap_type="fast", encryption="wpa"})
1053 auth:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
1054 auth:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
1055 auth:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
1056 auth:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
1058 cacert2 = s:taboption("encryption", FileUpload, "ca_cert2", translate("Path to inner CA-Certificate"))
1059 cacert2:depends({mode="sta", auth="EAP-TLS", encryption="wpa"})
1060 cacert2:depends({mode="sta", auth="EAP-TLS", encryption="wpa2"})
1061 cacert2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa"})
1062 cacert2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa2"})
1064 clientcert2 = s:taboption("encryption", FileUpload, "client_cert2", translate("Path to inner Client-Certificate"))
1065 clientcert2:depends({mode="sta", auth="EAP-TLS", encryption="wpa"})
1066 clientcert2:depends({mode="sta", auth="EAP-TLS", encryption="wpa2"})
1067 clientcert2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa"})
1068 clientcert2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa2"})
1070 privkey2 = s:taboption("encryption", FileUpload, "priv_key2", translate("Path to inner Private Key"))
1071 privkey2:depends({mode="sta", auth="EAP-TLS", encryption="wpa"})
1072 privkey2:depends({mode="sta", auth="EAP-TLS", encryption="wpa2"})
1073 privkey2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa"})
1074 privkey2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa2"})
1076 privkeypwd2 = s:taboption("encryption", Value, "priv_key2_pwd", translate("Password of inner Private Key"))
1077 privkeypwd2:depends({mode="sta", auth="EAP-TLS", encryption="wpa"})
1078 privkeypwd2:depends({mode="sta", auth="EAP-TLS", encryption="wpa2"})
1079 privkeypwd2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa"})
1080 privkeypwd2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa2"})
1081 privkeypwd2.rmempty = true
1082 privkeypwd2.password = true
1084 identity = s:taboption("encryption", Value, "identity", translate("Identity"))
1085 identity:depends({mode="sta", eap_type="fast", encryption="wpa2"})
1086 identity:depends({mode="sta", eap_type="fast", encryption="wpa"})
1087 identity:depends({mode="sta", eap_type="peap", encryption="wpa2"})
1088 identity:depends({mode="sta", eap_type="peap", encryption="wpa"})
1089 identity:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
1090 identity:depends({mode="sta", eap_type="ttls", encryption="wpa"})
1091 identity:depends({mode="sta-wds", eap_type="fast", encryption="wpa2"})
1092 identity:depends({mode="sta-wds", eap_type="fast", encryption="wpa"})
1093 identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
1094 identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
1095 identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
1096 identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
1097 identity:depends({mode="sta", eap_type="tls", encryption="wpa2"})
1098 identity:depends({mode="sta", eap_type="tls", encryption="wpa"})
1099 identity:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
1100 identity:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
1102 anonymous_identity = s:taboption("encryption", Value, "anonymous_identity", translate("Anonymous Identity"))
1103 anonymous_identity:depends({mode="sta", eap_type="fast", encryption="wpa2"})
1104 anonymous_identity:depends({mode="sta", eap_type="fast", encryption="wpa"})
1105 anonymous_identity:depends({mode="sta", eap_type="peap", encryption="wpa2"})
1106 anonymous_identity:depends({mode="sta", eap_type="peap", encryption="wpa"})
1107 anonymous_identity:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
1108 anonymous_identity:depends({mode="sta", eap_type="ttls", encryption="wpa"})
1109 anonymous_identity:depends({mode="sta-wds", eap_type="fast", encryption="wpa2"})
1110 anonymous_identity:depends({mode="sta-wds", eap_type="fast", encryption="wpa"})
1111 anonymous_identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
1112 anonymous_identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
1113 anonymous_identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
1114 anonymous_identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
1115 anonymous_identity:depends({mode="sta", eap_type="tls", encryption="wpa2"})
1116 anonymous_identity:depends({mode="sta", eap_type="tls", encryption="wpa"})
1117 anonymous_identity:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
1118 anonymous_identity:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
1120 password = s:taboption("encryption", Value, "password", translate("Password"))
1121 password:depends({mode="sta", eap_type="fast", encryption="wpa2"})
1122 password:depends({mode="sta", eap_type="fast", encryption="wpa"})
1123 password:depends({mode="sta", eap_type="peap", encryption="wpa2"})
1124 password:depends({mode="sta", eap_type="peap", encryption="wpa"})
1125 password:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
1126 password:depends({mode="sta", eap_type="ttls", encryption="wpa"})
1127 password:depends({mode="sta-wds", eap_type="fast", encryption="wpa2"})
1128 password:depends({mode="sta-wds", eap_type="fast", encryption="wpa"})
1129 password:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
1130 password:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
1131 password:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
1132 password:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
1133 password.rmempty = true
1134 password.password = true
1137 -- ieee802.11w options
1138 if hwtype == "mac80211" then
1139 local has_80211w = (os.execute("hostapd -v11w 2>/dev/null || hostapd -veap 2>/dev/null") == 0)
1141 ieee80211w = s:taboption("encryption", ListValue, "ieee80211w",
1142 translate("802.11w Management Frame Protection"),
1143 translate("Requires the 'full' version of wpad/hostapd " ..
1144 "and support from the wifi driver <br />(as of Feb 2017: " ..
1145 "ath9k and ath10k, in LEDE also mwlwifi and mt76)"))
1146 ieee80211w.default = ""
1147 ieee80211w.rmempty = true
1148 ieee80211w:value("", translate("Disabled (default)"))
1149 ieee80211w:value("1", translate("Optional"))
1150 ieee80211w:value("2", translate("Required"))
1151 ieee80211w:depends({mode="ap", encryption="wpa2"})
1152 ieee80211w:depends({mode="ap-wds", encryption="wpa2"})
1153 ieee80211w:depends({mode="ap", encryption="psk2"})
1154 ieee80211w:depends({mode="ap", encryption="psk-mixed"})
1155 ieee80211w:depends({mode="ap-wds", encryption="psk2"})
1156 ieee80211w:depends({mode="ap-wds", encryption="psk-mixed"})
1158 max_timeout = s:taboption("encryption", Value, "ieee80211w_max_timeout",
1159 translate("802.11w maximum timeout"),
1160 translate("802.11w Association SA Query maximum timeout"))
1161 max_timeout:depends({ieee80211w="1"})
1162 max_timeout:depends({ieee80211w="2"})
1163 max_timeout.datatype = "uinteger"
1164 max_timeout.placeholder = "1000"
1165 max_timeout.rmempty = true
1167 retry_timeout = s:taboption("encryption", Value, "ieee80211w_retry_timeout",
1168 translate("802.11w retry timeout"),
1169 translate("802.11w Association SA Query retry timeout"))
1170 retry_timeout:depends({ieee80211w="1"})
1171 retry_timeout:depends({ieee80211w="2"})
1172 retry_timeout.datatype = "uinteger"
1173 retry_timeout.placeholder = "201"
1174 retry_timeout.rmempty = true
1177 local key_retries = s:taboption("encryption", Flag, "wpa_disable_eapol_key_retries",
1178 translate("Enable key reinstallation (KRACK) countermeasures"),
1179 translate("Complicates key reinstallation attacks on the client side by disabling retransmission of EAPOL-Key frames that are used to install keys. This workaround might cause interoperability issues and reduced robustness of key negotiation especially in environments with heavy traffic load."))
1181 key_retries:depends({mode="ap", encryption="wpa2"})
1182 key_retries:depends({mode="ap", encryption="psk2"})
1183 key_retries:depends({mode="ap", encryption="psk-mixed"})
1184 key_retries:depends({mode="ap-wds", encryption="wpa2"})
1185 key_retries:depends({mode="ap-wds", encryption="psk2"})
1186 key_retries:depends({mode="ap-wds", encryption="psk-mixed"})
1189 if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
1190 local wpasupplicant = fs.access("/usr/sbin/wpa_supplicant")
1191 local hostcli = fs.access("/usr/sbin/hostapd_cli")
1192 if hostcli and wpasupplicant then
1193 wps = s:taboption("encryption", Flag, "wps_pushbutton", translate("Enable WPS pushbutton, requires WPA(2)-PSK"))
1197 wps:depends("encryption", "psk")
1198 wps:depends("encryption", "psk2")
1199 wps:depends("encryption", "psk-mixed")