ea4b016dc9064886bd7171e0603f4df8b54270b7
[project/luci.git] / modules / luci-mod-admin-full / luasrc / model / cbi / admin_network / wifi.lua
1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Licensed to the public under the Apache License 2.0.
3
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"
9
10 arg[1] = arg[1] or ""
11
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>."))
17
18 m:chain("network")
19 m:chain("firewall")
20 m.redirect = luci.dispatcher.build_url("admin/network/wireless")
21
22 local ifsection
23
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())
29 end
30 end
31
32 nw.init(m.uci)
33
34 local wnet = nw:get_wifinet(arg[1])
35 local wdev = wnet and wnet:get_device()
36
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"))
40 return
41 end
42
43 -- wireless toggle was requested, commit and reload page
44 function m.parse(map)
45 local new_cc = m:formvalue("cbid.wireless.%s.country" % wdev:name())
46 local old_cc = m:get(wdev:name(), "country")
47
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)
51 else
52 wnet:set("disabled", "1")
53 end
54 wdev:set("disabled", nil)
55
56 nw:commit("wireless")
57 luci.sys.call("(env -i /bin/ubus call network reload) >/dev/null 2>/dev/null")
58
59 luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless", arg[1]))
60 return
61 end
62
63 Map.parse(map)
64
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]))
68 return
69 end
70 end
71
72 m.title = luci.util.pcdata(wnet:get_i18n())
73
74
75 local function txpower_list(iw)
76 local list = iw.txpwrlist or { }
77 local off = tonumber(iw.txpower_offset) or 0
78 local new = { }
79 local prev = -1
80 local _, val
81 for _, val in ipairs(list) do
82 local dbm = val.dbm + off
83 local mw = math.floor(10 ^ (dbm / 10))
84 if mw ~= prev then
85 prev = mw
86 new[#new+1] = {
87 display_dbm = dbm,
88 display_mw = mw,
89 driver_dbm = val.dbm,
90 driver_mw = val.mw
91 }
92 end
93 end
94 return new
95 end
96
97 local function txpower_current(pwr, list)
98 pwr = tonumber(pwr)
99 if pwr ~= nil then
100 local _, item
101 for _, item in ipairs(list) do
102 if item.driver_dbm >= pwr then
103 return item.driver_dbm
104 end
105 end
106 end
107 return pwr or ""
108 end
109
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)
114
115 s = m:section(NamedSection, wdev:name(), "wifi-device", translate("Device Configuration"))
116 s.addremove = false
117
118 s:tab("general", translate("General Setup"))
119 s:tab("macfilter", translate("MAC-Filter"))
120 s:tab("advanced", translate("Advanced Settings"))
121
122 --[[
123 back = s:option(DummyValue, "_overview", translate("Overview"))
124 back.value = ""
125 back.titleref = luci.dispatcher.build_url("admin", "network", "wireless")
126 ]]
127
128 st = s:taboption("general", DummyValue, "__status", translate("Status"))
129 st.template = "admin_network/wifi_status"
130 st.ifname = arg[1]
131
132 en = s:taboption("general", Button, "__toggle")
133
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"
138 else
139 en.title = translate("Wireless network is enabled")
140 en.inputtitle = translate("Disable")
141 en.inputstyle = "reset"
142 end
143
144
145 local hwtype = wdev:get("type")
146
147 -- NanoFoo
148 local nsantenna = wdev:get("antenna")
149
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
153 local _, net
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
158 found_sta = {}
159 found_sta.channel = net:channel()
160 found_sta.names = {}
161 end
162 found_sta.names[#found_sta.names+1] = net:shortname()
163 end
164 end
165 end
166
167 if found_sta then
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, ", "))
171 else
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"
177
178 function ch.cfgvalue(self, section)
179 return {
180 m:get(section, "hwmode") or "",
181 m:get(section, "channel") or "auto",
182 m:get(section, "htmode") or ""
183 }
184 end
185
186 function ch.formvalue(self, section)
187 return {
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 ""
191 }
192 end
193
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])
198 end
199 end
200
201 ------------------- MAC80211 Device ------------------
202
203 if hwtype == "mac80211" then
204 if #tx_power_list > 0 then
205 tp = s:taboption("general", ListValue,
206 "txpower", translate("Transmit Power"), "dBm")
207 tp.rmempty = true
208 tp.default = tx_power_cur
209 function tp.cfgvalue(...)
210 return txpower_current(Value.cfgvalue(...), tx_power_list)
211 end
212
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 })
217 end
218 end
219
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 })
226 end
227 else
228 s:taboption("advanced", Value, "country", translate("Country Code"), translate("Use ISO/IEC 3166 alpha2 country codes."))
229 end
230
231 s:taboption("advanced", Value, "distance", translate("Distance Optimization"),
232 translate("Distance to farthest network member in meters."))
233
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 })
240 if eap.selected then
241 ea.default = eap.id
242 end
243 end
244 end
245
246 s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
247 s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
248 end
249
250
251 ------------------- Broadcom Device ------------------
252
253 if hwtype == "broadcom" then
254 tp = s:taboption("general",
255 (#tx_power_list > 0) and ListValue or Value,
256 "txpower", translate("Transmit Power"), "dBm")
257
258 tp.rmempty = true
259 tp.default = tx_power_cur
260
261 function tp.cfgvalue(...)
262 return txpower_current(Value.cfgvalue(...), tx_power_list)
263 end
264
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 })
269 end
270
271 mode = s:taboption("advanced", ListValue, "hwmode", translate("Band"))
272 if hw_modes.b then
273 mode:value("11b", "2.4GHz (802.11b)")
274 if hw_modes.g then
275 mode:value("11bg", "2.4GHz (802.11b+g)")
276 end
277 end
278 if hw_modes.g then
279 mode:value("11g", "2.4GHz (802.11g)")
280 mode:value("11gst", "2.4GHz (802.11g + Turbo)")
281 mode:value("11lrs", "2.4GHz (802.11g Limited Rate Support)")
282 end
283 if hw_modes.a then mode:value("11a", "5GHz (802.11a)") end
284 if hw_modes.n then
285 if hw_modes.g then
286 mode:value("11ng", "2.4GHz (802.11g+n)")
287 mode:value("11n", "2.4GHz (802.11n)")
288 end
289 if hw_modes.a then
290 mode:value("11na", "5GHz (802.11a+n)")
291 mode:value("11n", "5GHz (802.11n)")
292 end
293 htmode = s:taboption("advanced", ListValue, "htmode", translate("HT mode (802.11n)"))
294 htmode:depends("hwmode", "11ng")
295 htmode:depends("hwmode", "11na")
296 htmode:depends("hwmode", "11n")
297 htmode:value("HT20", "20MHz")
298 htmode:value("HT40", "40MHz")
299 end
300
301 ant1 = s:taboption("advanced", ListValue, "txantenna", translate("Transmitter Antenna"))
302 ant1.widget = "radio"
303 ant1:depends("diversity", "")
304 ant1:value("3", translate("auto"))
305 ant1:value("0", translate("Antenna 1"))
306 ant1:value("1", translate("Antenna 2"))
307
308 ant2 = s:taboption("advanced", ListValue, "rxantenna", translate("Receiver Antenna"))
309 ant2.widget = "radio"
310 ant2:depends("diversity", "")
311 ant2:value("3", translate("auto"))
312 ant2:value("0", translate("Antenna 1"))
313 ant2:value("1", translate("Antenna 2"))
314
315 s:taboption("advanced", Flag, "frameburst", translate("Frame Bursting"))
316
317 s:taboption("advanced", Value, "distance", translate("Distance Optimization"))
318 --s:option(Value, "slottime", translate("Slot time"))
319
320 s:taboption("advanced", Value, "country", translate("Country Code"))
321 s:taboption("advanced", Value, "maxassoc", translate("Connection Limit"))
322 end
323
324
325 --------------------- HostAP Device ---------------------
326
327 if hwtype == "prism2" then
328 s:taboption("advanced", Value, "txpower", translate("Transmit Power"), "att units").rmempty = true
329
330 s:taboption("advanced", Flag, "diversity", translate("Diversity")).rmempty = false
331
332 s:taboption("advanced", Value, "txantenna", translate("Transmitter Antenna"))
333 s:taboption("advanced", Value, "rxantenna", translate("Receiver Antenna"))
334 end
335
336
337 ----------------------- Interface -----------------------
338
339 s = m:section(NamedSection, wnet.sid, "wifi-iface", translate("Interface Configuration"))
340 ifsection = s
341 s.addremove = false
342 s.anonymous = true
343 s.defaults.device = wdev:name()
344
345 s:tab("general", translate("General Setup"))
346 s:tab("encryption", translate("Wireless Security"))
347 s:tab("macfilter", translate("MAC-Filter"))
348 s:tab("advanced", translate("Advanced Settings"))
349
350 mode = s:taboption("general", ListValue, "mode", translate("Mode"))
351 mode.override_values = true
352 mode:value("ap", translate("Access Point"))
353 mode:value("sta", translate("Client"))
354 mode:value("adhoc", translate("Ad-Hoc"))
355
356 meshid = s:taboption("general", Value, "mesh_id", translate("Mesh Id"))
357 meshid:depends({mode="mesh"})
358
359 ssid = s:taboption("general", Value, "ssid", translate("<abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
360 ssid.datatype = "maxlength(32)"
361 ssid:depends({mode="ap"})
362 ssid:depends({mode="sta"})
363 ssid:depends({mode="adhoc"})
364 ssid:depends({mode="ahdemo"})
365 ssid:depends({mode="monitor"})
366 ssid:depends({mode="ap-wds"})
367 ssid:depends({mode="sta-wds"})
368 ssid:depends({mode="wds"})
369
370 bssid = s:taboption("general", Value, "bssid", translate("<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"))
371
372 network = s:taboption("general", Value, "network", translate("Network"),
373 translate("Choose the network(s) you want to attach to this wireless interface or " ..
374 "fill out the <em>create</em> field to define a new network."))
375
376 network.rmempty = true
377 network.template = "cbi/network_netlist"
378 network.widget = "checkbox"
379 network.novirtual = true
380
381 function network.write(self, section, value)
382 local i = nw:get_interface(section)
383 if i then
384 if value == '-' then
385 value = m:formvalue(self:cbid(section) .. ".newnet")
386 if value and #value > 0 then
387 local n = nw:add_network(value, {proto="none"})
388 if n then n:add_interface(i) end
389 else
390 local n = i:get_network()
391 if n then n:del_interface(i) end
392 end
393 else
394 local v
395 for _, v in ipairs(i:get_networks()) do
396 v:del_interface(i)
397 end
398 for v in ut.imatch(value) do
399 local n = nw:get_network(v)
400 if n then
401 if not n:is_empty() then
402 n:set("type", "bridge")
403 end
404 n:add_interface(i)
405 end
406 end
407 end
408 end
409 end
410
411 -------------------- MAC80211 Interface ----------------------
412
413 if hwtype == "mac80211" then
414 if fs.access("/usr/sbin/iw") then
415 mode:value("mesh", "802.11s")
416 end
417
418 mode:value("ahdemo", translate("Pseudo Ad-Hoc (ahdemo)"))
419 mode:value("monitor", translate("Monitor"))
420 bssid:depends({mode="adhoc"})
421 bssid:depends({mode="sta"})
422 bssid:depends({mode="sta-wds"})
423
424 mp = s:taboption("macfilter", ListValue, "macfilter", translate("MAC-Address Filter"))
425 mp:depends({mode="ap"})
426 mp:depends({mode="ap-wds"})
427 mp:value("", translate("disable"))
428 mp:value("allow", translate("Allow listed only"))
429 mp:value("deny", translate("Allow all except listed"))
430
431 ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List"))
432 ml.datatype = "macaddr"
433 ml:depends({macfilter="allow"})
434 ml:depends({macfilter="deny"})
435 nt.mac_hints(function(mac, name) ml:value(mac, "%s (%s)" %{ mac, name }) end)
436
437 mode:value("ap-wds", "%s (%s)" % {translate("Access Point"), translate("WDS")})
438 mode:value("sta-wds", "%s (%s)" % {translate("Client"), translate("WDS")})
439
440 function mode.write(self, section, value)
441 if value == "ap-wds" then
442 ListValue.write(self, section, "ap")
443 m.uci:set("wireless", section, "wds", 1)
444 elseif value == "sta-wds" then
445 ListValue.write(self, section, "sta")
446 m.uci:set("wireless", section, "wds", 1)
447 else
448 ListValue.write(self, section, value)
449 m.uci:delete("wireless", section, "wds")
450 end
451 end
452
453 function mode.cfgvalue(self, section)
454 local mode = ListValue.cfgvalue(self, section)
455 local wds = m.uci:get("wireless", section, "wds") == "1"
456
457 if mode == "ap" and wds then
458 return "ap-wds"
459 elseif mode == "sta" and wds then
460 return "sta-wds"
461 else
462 return mode
463 end
464 end
465
466 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
467 hidden:depends({mode="ap"})
468 hidden:depends({mode="ap-wds"})
469
470 wmm = s:taboption("general", Flag, "wmm", translate("WMM Mode"))
471 wmm:depends({mode="ap"})
472 wmm:depends({mode="ap-wds"})
473 wmm.default = wmm.enabled
474
475 isolate = s:taboption("advanced", Flag, "isolate", translate("Isolate Clients"),
476 translate("Prevents client-to-client communication"))
477 isolate:depends({mode="ap"})
478 isolate:depends({mode="ap-wds"})
479
480 ifname = s:taboption("advanced", Value, "ifname", translate("Interface name"), translate("Override default interface name"))
481 ifname.optional = true
482 end
483
484
485 -------------------- Broadcom Interface ----------------------
486
487 if hwtype == "broadcom" then
488 mode:value("wds", translate("WDS"))
489 mode:value("monitor", translate("Monitor"))
490
491 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
492 hidden:depends({mode="ap"})
493 hidden:depends({mode="adhoc"})
494 hidden:depends({mode="wds"})
495
496 isolate = s:taboption("advanced", Flag, "isolate", translate("Separate Clients"),
497 translate("Prevents client-to-client communication"))
498 isolate:depends({mode="ap"})
499
500 s:taboption("advanced", Flag, "doth", "802.11h")
501 s:taboption("advanced", Flag, "wmm", translate("WMM Mode"))
502
503 bssid:depends({mode="wds"})
504 bssid:depends({mode="adhoc"})
505 end
506
507
508 ----------------------- HostAP Interface ---------------------
509
510 if hwtype == "prism2" then
511 mode:value("wds", translate("WDS"))
512 mode:value("monitor", translate("Monitor"))
513
514 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
515 hidden:depends({mode="ap"})
516 hidden:depends({mode="adhoc"})
517 hidden:depends({mode="wds"})
518
519 bssid:depends({mode="sta"})
520
521 mp = s:taboption("macfilter", ListValue, "macpolicy", translate("MAC-Address Filter"))
522 mp:value("", translate("disable"))
523 mp:value("allow", translate("Allow listed only"))
524 mp:value("deny", translate("Allow all except listed"))
525 ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List"))
526 ml:depends({macpolicy="allow"})
527 ml:depends({macpolicy="deny"})
528 nt.mac_hints(function(mac, name) ml:value(mac, "%s (%s)" %{ mac, name }) end)
529
530 s:taboption("advanced", Value, "rate", translate("Transmission Rate"))
531 s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
532 s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
533 end
534
535
536 ------------------- WiFI-Encryption -------------------
537
538 encr = s:taboption("encryption", ListValue, "encryption", translate("Encryption"))
539 encr.override_values = true
540 encr.override_depends = true
541 encr:depends({mode="ap"})
542 encr:depends({mode="sta"})
543 encr:depends({mode="adhoc"})
544 encr:depends({mode="ahdemo"})
545 encr:depends({mode="ap-wds"})
546 encr:depends({mode="sta-wds"})
547 encr:depends({mode="mesh"})
548
549 cipher = s:taboption("encryption", ListValue, "cipher", translate("Cipher"))
550 cipher:depends({encryption="wpa"})
551 cipher:depends({encryption="wpa2"})
552 cipher:depends({encryption="psk"})
553 cipher:depends({encryption="psk2"})
554 cipher:depends({encryption="wpa-mixed"})
555 cipher:depends({encryption="psk-mixed"})
556 cipher:value("auto", translate("auto"))
557 cipher:value("ccmp", translate("Force CCMP (AES)"))
558 cipher:value("tkip", translate("Force TKIP"))
559 cipher:value("tkip+ccmp", translate("Force TKIP and CCMP (AES)"))
560
561 function encr.cfgvalue(self, section)
562 local v = tostring(ListValue.cfgvalue(self, section))
563 if v == "wep" then
564 return "wep-open"
565 elseif v and v:match("%+") then
566 return (v:gsub("%+.+$", ""))
567 end
568 return v
569 end
570
571 function encr.write(self, section, value)
572 local e = tostring(encr:formvalue(section))
573 local c = tostring(cipher:formvalue(section))
574 if value == "wpa" or value == "wpa2" then
575 self.map.uci:delete("wireless", section, "key")
576 end
577 if e and (c == "tkip" or c == "ccmp" or c == "tkip+ccmp") then
578 e = e .. "+" .. c
579 end
580 self.map:set(section, "encryption", e)
581 end
582
583 function cipher.cfgvalue(self, section)
584 local v = tostring(ListValue.cfgvalue(encr, section))
585 if v and v:match("%+") then
586 v = v:gsub("^[^%+]+%+", "")
587 if v == "aes" then v = "ccmp"
588 elseif v == "tkip+aes" then v = "tkip+ccmp"
589 elseif v == "aes+tkip" then v = "tkip+ccmp"
590 elseif v == "ccmp+tkip" then v = "tkip+ccmp"
591 end
592 end
593 return v
594 end
595
596 function cipher.write(self, section)
597 return encr:write(section)
598 end
599
600
601 encr:value("none", "No Encryption")
602 encr:value("wep-open", translate("WEP Open System"), {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"}, {mode="ahdemo"}, {mode="wds"})
603 encr:value("wep-shared", translate("WEP Shared Key"), {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"}, {mode="ahdemo"}, {mode="wds"})
604
605 if hwtype == "mac80211" or hwtype == "prism2" then
606 local supplicant = fs.access("/usr/sbin/wpa_supplicant")
607 local hostapd = fs.access("/usr/sbin/hostapd")
608
609 -- Probe EAP support
610 local has_ap_eap = (os.execute("hostapd -veap >/dev/null 2>/dev/null") == 0)
611 local has_sta_eap = (os.execute("wpa_supplicant -veap >/dev/null 2>/dev/null") == 0)
612
613 if hostapd and supplicant then
614 encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"})
615 encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"})
616 encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"})
617 if has_ap_eap and has_sta_eap then
618 encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
619 encr:value("wpa2", "WPA2-EAP", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
620 end
621 elseif hostapd and not supplicant then
622 encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="ap-wds"})
623 encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="ap-wds"})
624 encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="ap"}, {mode="ap-wds"})
625 if has_ap_eap then
626 encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="ap-wds"})
627 encr:value("wpa2", "WPA2-EAP", {mode="ap"}, {mode="ap-wds"})
628 end
629 encr.description = translate(
630 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
631 "and ad-hoc mode) to be installed."
632 )
633 elseif not hostapd and supplicant then
634 encr:value("psk", "WPA-PSK", {mode="sta"}, {mode="sta-wds"}, {mode="adhoc"})
635 encr:value("psk2", "WPA2-PSK", {mode="sta"}, {mode="sta-wds"}, {mode="adhoc"})
636 encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="sta"}, {mode="sta-wds"}, {mode="adhoc"})
637 if has_sta_eap then
638 encr:value("wpa", "WPA-EAP", {mode="sta"}, {mode="sta-wds"})
639 encr:value("wpa2", "WPA2-EAP", {mode="sta"}, {mode="sta-wds"})
640 end
641 encr.description = translate(
642 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
643 "and ad-hoc mode) to be installed."
644 )
645 else
646 encr.description = translate(
647 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
648 "and ad-hoc mode) to be installed."
649 )
650 end
651 elseif hwtype == "broadcom" then
652 encr:value("psk", "WPA-PSK")
653 encr:value("psk2", "WPA2-PSK")
654 encr:value("psk+psk2", "WPA-PSK/WPA2-PSK Mixed Mode")
655 end
656
657 auth_server = s:taboption("encryption", Value, "auth_server", translate("Radius-Authentication-Server"))
658 auth_server:depends({mode="ap", encryption="wpa"})
659 auth_server:depends({mode="ap", encryption="wpa2"})
660 auth_server:depends({mode="ap-wds", encryption="wpa"})
661 auth_server:depends({mode="ap-wds", encryption="wpa2"})
662 auth_server.rmempty = true
663 auth_server.datatype = "host(0)"
664
665 auth_port = s:taboption("encryption", Value, "auth_port", translate("Radius-Authentication-Port"), translatef("Default %d", 1812))
666 auth_port:depends({mode="ap", encryption="wpa"})
667 auth_port:depends({mode="ap", encryption="wpa2"})
668 auth_port:depends({mode="ap-wds", encryption="wpa"})
669 auth_port:depends({mode="ap-wds", encryption="wpa2"})
670 auth_port.rmempty = true
671 auth_port.datatype = "port"
672
673 auth_secret = s:taboption("encryption", Value, "auth_secret", translate("Radius-Authentication-Secret"))
674 auth_secret:depends({mode="ap", encryption="wpa"})
675 auth_secret:depends({mode="ap", encryption="wpa2"})
676 auth_secret:depends({mode="ap-wds", encryption="wpa"})
677 auth_secret:depends({mode="ap-wds", encryption="wpa2"})
678 auth_secret.rmempty = true
679 auth_secret.password = true
680
681 acct_server = s:taboption("encryption", Value, "acct_server", translate("Radius-Accounting-Server"))
682 acct_server:depends({mode="ap", encryption="wpa"})
683 acct_server:depends({mode="ap", encryption="wpa2"})
684 acct_server:depends({mode="ap-wds", encryption="wpa"})
685 acct_server:depends({mode="ap-wds", encryption="wpa2"})
686 acct_server.rmempty = true
687 acct_server.datatype = "host(0)"
688
689 acct_port = s:taboption("encryption", Value, "acct_port", translate("Radius-Accounting-Port"), translatef("Default %d", 1813))
690 acct_port:depends({mode="ap", encryption="wpa"})
691 acct_port:depends({mode="ap", encryption="wpa2"})
692 acct_port:depends({mode="ap-wds", encryption="wpa"})
693 acct_port:depends({mode="ap-wds", encryption="wpa2"})
694 acct_port.rmempty = true
695 acct_port.datatype = "port"
696
697 acct_secret = s:taboption("encryption", Value, "acct_secret", translate("Radius-Accounting-Secret"))
698 acct_secret:depends({mode="ap", encryption="wpa"})
699 acct_secret:depends({mode="ap", encryption="wpa2"})
700 acct_secret:depends({mode="ap-wds", encryption="wpa"})
701 acct_secret:depends({mode="ap-wds", encryption="wpa2"})
702 acct_secret.rmempty = true
703 acct_secret.password = true
704
705 wpakey = s:taboption("encryption", Value, "_wpa_key", translate("Key"))
706 wpakey:depends("encryption", "psk")
707 wpakey:depends("encryption", "psk2")
708 wpakey:depends("encryption", "psk+psk2")
709 wpakey:depends("encryption", "psk-mixed")
710 wpakey.datatype = "wpakey"
711 wpakey.rmempty = true
712 wpakey.password = true
713
714 wpakey.cfgvalue = function(self, section, value)
715 local key = m.uci:get("wireless", section, "key")
716 if key == "1" or key == "2" or key == "3" or key == "4" then
717 return nil
718 end
719 return key
720 end
721
722 wpakey.write = function(self, section, value)
723 self.map.uci:set("wireless", section, "key", value)
724 self.map.uci:delete("wireless", section, "key1")
725 end
726
727
728 wepslot = s:taboption("encryption", ListValue, "_wep_key", translate("Used Key Slot"))
729 wepslot:depends("encryption", "wep-open")
730 wepslot:depends("encryption", "wep-shared")
731 wepslot:value("1", translatef("Key #%d", 1))
732 wepslot:value("2", translatef("Key #%d", 2))
733 wepslot:value("3", translatef("Key #%d", 3))
734 wepslot:value("4", translatef("Key #%d", 4))
735
736 wepslot.cfgvalue = function(self, section)
737 local slot = tonumber(m.uci:get("wireless", section, "key"))
738 if not slot or slot < 1 or slot > 4 then
739 return 1
740 end
741 return slot
742 end
743
744 wepslot.write = function(self, section, value)
745 self.map.uci:set("wireless", section, "key", value)
746 end
747
748 local slot
749 for slot=1,4 do
750 wepkey = s:taboption("encryption", Value, "key" .. slot, translatef("Key #%d", slot))
751 wepkey:depends("encryption", "wep-open")
752 wepkey:depends("encryption", "wep-shared")
753 wepkey.datatype = "wepkey"
754 wepkey.rmempty = true
755 wepkey.password = true
756
757 function wepkey.write(self, section, value)
758 if value and (#value == 5 or #value == 13) then
759 value = "s:" .. value
760 end
761 return Value.write(self, section, value)
762 end
763 end
764
765
766 if hwtype == "mac80211" or hwtype == "prism2" then
767
768 -- Probe 802.11r support (and EAP support as a proxy for Openwrt)
769 local has_80211r = (os.execute("hostapd -v11r 2>/dev/null || hostapd -veap 2>/dev/null") == 0)
770
771 ieee80211r = s:taboption("encryption", Flag, "ieee80211r",
772 translate("802.11r Fast Transition"),
773 translate("Enables fast roaming among access points that belong " ..
774 "to the same Mobility Domain"))
775 ieee80211r:depends({mode="ap", encryption="wpa"})
776 ieee80211r:depends({mode="ap", encryption="wpa2"})
777 ieee80211r:depends({mode="ap-wds", encryption="wpa"})
778 ieee80211r:depends({mode="ap-wds", encryption="wpa2"})
779 if has_80211r then
780 ieee80211r:depends({mode="ap", encryption="psk"})
781 ieee80211r:depends({mode="ap", encryption="psk2"})
782 ieee80211r:depends({mode="ap", encryption="psk-mixed"})
783 ieee80211r:depends({mode="ap-wds", encryption="psk"})
784 ieee80211r:depends({mode="ap-wds", encryption="psk2"})
785 ieee80211r:depends({mode="ap-wds", encryption="psk-mixed"})
786 end
787 ieee80211r.rmempty = true
788
789 nasid = s:taboption("encryption", Value, "nasid", translate("NAS ID"),
790 translate("Used for two different purposes: RADIUS NAS ID and " ..
791 "802.11r R0KH-ID. Not needed with normal WPA(2)-PSK."))
792 nasid:depends({mode="ap", encryption="wpa"})
793 nasid:depends({mode="ap", encryption="wpa2"})
794 nasid:depends({mode="ap-wds", encryption="wpa"})
795 nasid:depends({mode="ap-wds", encryption="wpa2"})
796 nasid:depends({ieee80211r="1"})
797 nasid.rmempty = true
798
799 mobility_domain = s:taboption("encryption", Value, "mobility_domain",
800 translate("Mobility Domain"),
801 translate("4-character hexadecimal ID"))
802 mobility_domain:depends({ieee80211r="1"})
803 mobility_domain.placeholder = "4f57"
804 mobility_domain.datatype = "and(hexstring,rangelength(4,4))"
805 mobility_domain.rmempty = true
806
807 reassociation_deadline = s:taboption("encryption", Value, "reassociation_deadline",
808 translate("Reassociation Deadline"),
809 translate("time units (TUs / 1.024 ms) [1000-65535]"))
810 reassociation_deadline:depends({ieee80211r="1"})
811 reassociation_deadline.placeholder = "1000"
812 reassociation_deadline.datatype = "range(1000,65535)"
813 reassociation_deadline.rmempty = true
814
815 ft_protocol = s:taboption("encryption", ListValue, "ft_over_ds", translate("FT protocol"))
816 ft_protocol:depends({ieee80211r="1"})
817 ft_protocol:value("1", translatef("FT over DS"))
818 ft_protocol:value("0", translatef("FT over the Air"))
819 ft_protocol.rmempty = true
820
821 ft_psk_generate_local = s:taboption("encryption", Flag, "ft_psk_generate_local",
822 translate("Generate PMK locally"),
823 translate("When using a PSK, the PMK can be generated locally without inter AP communications"))
824 ft_psk_generate_local:depends({ieee80211r="1"})
825
826 r0_key_lifetime = s:taboption("encryption", Value, "r0_key_lifetime",
827 translate("R0 Key Lifetime"), translate("minutes"))
828 r0_key_lifetime:depends({ieee80211r="1", ft_psk_generate_local=""})
829 r0_key_lifetime.placeholder = "10000"
830 r0_key_lifetime.datatype = "uinteger"
831 r0_key_lifetime.rmempty = true
832
833 r1_key_holder = s:taboption("encryption", Value, "r1_key_holder",
834 translate("R1 Key Holder"),
835 translate("6-octet identifier as a hex string - no colons"))
836 r1_key_holder:depends({ieee80211r="1", ft_psk_generate_local=""})
837 r1_key_holder.placeholder = "00004f577274"
838 r1_key_holder.datatype = "and(hexstring,rangelength(12,12))"
839 r1_key_holder.rmempty = true
840
841 pmk_r1_push = s:taboption("encryption", Flag, "pmk_r1_push", translate("PMK R1 Push"))
842 pmk_r1_push:depends({ieee80211r="1", ft_psk_generate_local=""})
843 pmk_r1_push.placeholder = "0"
844 pmk_r1_push.rmempty = true
845
846 r0kh = s:taboption("encryption", DynamicList, "r0kh", translate("External R0 Key Holder List"),
847 translate("List of R0KHs in the same Mobility Domain. " ..
848 "<br />Format: MAC-address,NAS-Identifier,128-bit key as hex string. " ..
849 "<br />This list is used to map R0KH-ID (NAS Identifier) to a destination " ..
850 "MAC address when requesting PMK-R1 key from the R0KH that the STA " ..
851 "used during the Initial Mobility Domain Association."))
852 r0kh:depends({ieee80211r="1", ft_psk_generate_local=""})
853 r0kh.rmempty = true
854
855 r1kh = s:taboption("encryption", DynamicList, "r1kh", translate("External R1 Key Holder List"),
856 translate ("List of R1KHs in the same Mobility Domain. "..
857 "<br />Format: MAC-address,R1KH-ID as 6 octets with colons,128-bit key as hex string. "..
858 "<br />This list is used to map R1KH-ID to a destination MAC address " ..
859 "when sending PMK-R1 key from the R0KH. This is also the " ..
860 "list of authorized R1KHs in the MD that can request PMK-R1 keys."))
861 r1kh:depends({ieee80211r="1", ft_psk_generate_local=""})
862 r1kh.rmempty = true
863 -- End of 802.11r options
864
865 eaptype = s:taboption("encryption", ListValue, "eap_type", translate("EAP-Method"))
866 eaptype:value("tls", "TLS")
867 eaptype:value("ttls", "TTLS")
868 eaptype:value("peap", "PEAP")
869 eaptype:value("fast", "FAST")
870 eaptype:depends({mode="sta", encryption="wpa"})
871 eaptype:depends({mode="sta", encryption="wpa2"})
872 eaptype:depends({mode="sta-wds", encryption="wpa"})
873 eaptype:depends({mode="sta-wds", encryption="wpa2"})
874
875 cacert = s:taboption("encryption", FileUpload, "ca_cert", translate("Path to CA-Certificate"))
876 cacert:depends({mode="sta", encryption="wpa"})
877 cacert:depends({mode="sta", encryption="wpa2"})
878 cacert:depends({mode="sta-wds", encryption="wpa"})
879 cacert:depends({mode="sta-wds", encryption="wpa2"})
880 cacert.rmempty = true
881
882 clientcert = s:taboption("encryption", FileUpload, "client_cert", translate("Path to Client-Certificate"))
883 clientcert:depends({mode="sta", eap_type="tls", encryption="wpa"})
884 clientcert:depends({mode="sta", eap_type="tls", encryption="wpa2"})
885 clientcert:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
886 clientcert:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
887
888 privkey = s:taboption("encryption", FileUpload, "priv_key", translate("Path to Private Key"))
889 privkey:depends({mode="sta", eap_type="tls", encryption="wpa2"})
890 privkey:depends({mode="sta", eap_type="tls", encryption="wpa"})
891 privkey:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
892 privkey:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
893
894 privkeypwd = s:taboption("encryption", Value, "priv_key_pwd", translate("Password of Private Key"))
895 privkeypwd:depends({mode="sta", eap_type="tls", encryption="wpa2"})
896 privkeypwd:depends({mode="sta", eap_type="tls", encryption="wpa"})
897 privkeypwd:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
898 privkeypwd:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
899 privkeypwd.rmempty = true
900 privkeypwd.password = true
901
902 auth = s:taboption("encryption", ListValue, "auth", translate("Authentication"))
903 auth:value("PAP", "PAP", {eap_type="ttls"})
904 auth:value("CHAP", "CHAP", {eap_type="ttls"})
905 auth:value("MSCHAP", "MSCHAP", {eap_type="ttls"})
906 auth:value("MSCHAPV2", "MSCHAPv2", {eap_type="ttls"})
907 auth:value("EAP-GTC")
908 auth:value("EAP-MD5")
909 auth:value("EAP-MSCHAPV2")
910 auth:value("EAP-TLS")
911 auth:depends({mode="sta", eap_type="fast", encryption="wpa2"})
912 auth:depends({mode="sta", eap_type="fast", encryption="wpa"})
913 auth:depends({mode="sta", eap_type="peap", encryption="wpa2"})
914 auth:depends({mode="sta", eap_type="peap", encryption="wpa"})
915 auth:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
916 auth:depends({mode="sta", eap_type="ttls", encryption="wpa"})
917 auth:depends({mode="sta-wds", eap_type="fast", encryption="wpa2"})
918 auth:depends({mode="sta-wds", eap_type="fast", encryption="wpa"})
919 auth:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
920 auth:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
921 auth:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
922 auth:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
923
924 cacert2 = s:taboption("encryption", FileUpload, "ca_cert2", translate("Path to inner CA-Certificate"))
925 cacert2:depends({mode="sta", auth="EAP-TLS", encryption="wpa"})
926 cacert2:depends({mode="sta", auth="EAP-TLS", encryption="wpa2"})
927 cacert2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa"})
928 cacert2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa2"})
929
930 clientcert2 = s:taboption("encryption", FileUpload, "client_cert2", translate("Path to inner Client-Certificate"))
931 clientcert2:depends({mode="sta", auth="EAP-TLS", encryption="wpa"})
932 clientcert2:depends({mode="sta", auth="EAP-TLS", encryption="wpa2"})
933 clientcert2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa"})
934 clientcert2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa2"})
935
936 privkey2 = s:taboption("encryption", FileUpload, "priv_key2", translate("Path to inner Private Key"))
937 privkey2:depends({mode="sta", auth="EAP-TLS", encryption="wpa"})
938 privkey2:depends({mode="sta", auth="EAP-TLS", encryption="wpa2"})
939 privkey2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa"})
940 privkey2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa2"})
941
942 privkeypwd2 = s:taboption("encryption", Value, "priv_key2_pwd", translate("Password of inner Private Key"))
943 privkeypwd2:depends({mode="sta", auth="EAP-TLS", encryption="wpa"})
944 privkeypwd2:depends({mode="sta", auth="EAP-TLS", encryption="wpa2"})
945 privkeypwd2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa"})
946 privkeypwd2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa2"})
947 privkeypwd2.rmempty = true
948 privkeypwd2.password = true
949
950 identity = s:taboption("encryption", Value, "identity", translate("Identity"))
951 identity:depends({mode="sta", eap_type="fast", encryption="wpa2"})
952 identity:depends({mode="sta", eap_type="fast", encryption="wpa"})
953 identity:depends({mode="sta", eap_type="peap", encryption="wpa2"})
954 identity:depends({mode="sta", eap_type="peap", encryption="wpa"})
955 identity:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
956 identity:depends({mode="sta", eap_type="ttls", encryption="wpa"})
957 identity:depends({mode="sta-wds", eap_type="fast", encryption="wpa2"})
958 identity:depends({mode="sta-wds", eap_type="fast", encryption="wpa"})
959 identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
960 identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
961 identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
962 identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
963 identity:depends({mode="sta", eap_type="tls", encryption="wpa2"})
964 identity:depends({mode="sta", eap_type="tls", encryption="wpa"})
965 identity:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
966 identity:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
967
968 anonymous_identity = s:taboption("encryption", Value, "anonymous_identity", translate("Anonymous Identity"))
969 anonymous_identity:depends({mode="sta", eap_type="fast", encryption="wpa2"})
970 anonymous_identity:depends({mode="sta", eap_type="fast", encryption="wpa"})
971 anonymous_identity:depends({mode="sta", eap_type="peap", encryption="wpa2"})
972 anonymous_identity:depends({mode="sta", eap_type="peap", encryption="wpa"})
973 anonymous_identity:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
974 anonymous_identity:depends({mode="sta", eap_type="ttls", encryption="wpa"})
975 anonymous_identity:depends({mode="sta-wds", eap_type="fast", encryption="wpa2"})
976 anonymous_identity:depends({mode="sta-wds", eap_type="fast", encryption="wpa"})
977 anonymous_identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
978 anonymous_identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
979 anonymous_identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
980 anonymous_identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
981 anonymous_identity:depends({mode="sta", eap_type="tls", encryption="wpa2"})
982 anonymous_identity:depends({mode="sta", eap_type="tls", encryption="wpa"})
983 anonymous_identity:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
984 anonymous_identity:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
985
986 password = s:taboption("encryption", Value, "password", translate("Password"))
987 password:depends({mode="sta", eap_type="fast", encryption="wpa2"})
988 password:depends({mode="sta", eap_type="fast", encryption="wpa"})
989 password:depends({mode="sta", eap_type="peap", encryption="wpa2"})
990 password:depends({mode="sta", eap_type="peap", encryption="wpa"})
991 password:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
992 password:depends({mode="sta", eap_type="ttls", encryption="wpa"})
993 password:depends({mode="sta-wds", eap_type="fast", encryption="wpa2"})
994 password:depends({mode="sta-wds", eap_type="fast", encryption="wpa"})
995 password:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
996 password:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
997 password:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
998 password:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
999 password.rmempty = true
1000 password.password = true
1001 end
1002
1003 -- ieee802.11w options
1004 if hwtype == "mac80211" then
1005 local has_80211w = (os.execute("hostapd -v11w 2>/dev/null || hostapd -veap 2>/dev/null") == 0)
1006 if has_80211w then
1007 ieee80211w = s:taboption("encryption", ListValue, "ieee80211w",
1008 translate("802.11w Management Frame Protection"),
1009 translate("Requires the 'full' version of wpad/hostapd " ..
1010 "and support from the wifi driver <br />(as of Feb 2017: " ..
1011 "ath9k and ath10k, in LEDE also mwlwifi and mt76)"))
1012 ieee80211w.default = ""
1013 ieee80211w.rmempty = true
1014 ieee80211w:value("", translate("Disabled (default)"))
1015 ieee80211w:value("1", translate("Optional"))
1016 ieee80211w:value("2", translate("Required"))
1017 ieee80211w:depends({mode="ap", encryption="wpa2"})
1018 ieee80211w:depends({mode="ap-wds", encryption="wpa2"})
1019 ieee80211w:depends({mode="ap", encryption="psk2"})
1020 ieee80211w:depends({mode="ap", encryption="psk-mixed"})
1021 ieee80211w:depends({mode="ap-wds", encryption="psk2"})
1022 ieee80211w:depends({mode="ap-wds", encryption="psk-mixed"})
1023
1024 max_timeout = s:taboption("encryption", Value, "ieee80211w_max_timeout",
1025 translate("802.11w maximum timeout"),
1026 translate("802.11w Association SA Query maximum timeout"))
1027 max_timeout:depends({ieee80211w="1"})
1028 max_timeout:depends({ieee80211w="2"})
1029 max_timeout.datatype = "uinteger"
1030 max_timeout.placeholder = "1000"
1031 max_timeout.rmempty = true
1032
1033 retry_timeout = s:taboption("encryption", Value, "ieee80211w_retry_timeout",
1034 translate("802.11w retry timeout"),
1035 translate("802.11w Association SA Query retry timeout"))
1036 retry_timeout:depends({ieee80211w="1"})
1037 retry_timeout:depends({ieee80211w="2"})
1038 retry_timeout.datatype = "uinteger"
1039 retry_timeout.placeholder = "201"
1040 retry_timeout.rmempty = true
1041 end
1042
1043 local key_retries = s:taboption("encryption", Flag, "wpa_disable_eapol_key_retries",
1044 translate("Enable key reinstallation (KRACK) countermeasures"),
1045 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."))
1046
1047 key_retries:depends({mode="ap", encryption="wpa2"})
1048 key_retries:depends({mode="ap", encryption="psk2"})
1049 key_retries:depends({mode="ap", encryption="psk-mixed"})
1050 key_retries:depends({mode="ap-wds", encryption="wpa2"})
1051 key_retries:depends({mode="ap-wds", encryption="psk2"})
1052 key_retries:depends({mode="ap-wds", encryption="psk-mixed"})
1053 end
1054
1055 if hwtype == "mac80211" or hwtype == "prism2" then
1056 local wpasupplicant = fs.access("/usr/sbin/wpa_supplicant")
1057 local hostcli = fs.access("/usr/sbin/hostapd_cli")
1058 if hostcli and wpasupplicant then
1059 wps = s:taboption("encryption", Flag, "wps_pushbutton", translate("Enable WPS pushbutton, requires WPA(2)-PSK"))
1060 wps.enabled = "1"
1061 wps.disabled = "0"
1062 wps.rmempty = false
1063 wps:depends("encryption", "psk")
1064 wps:depends("encryption", "psk2")
1065 wps:depends("encryption", "psk-mixed")
1066 end
1067 end
1068
1069 return m