luci-mod-admin-full: place 80211w options behind a check for wpad-full
[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 ------------------- Madwifi Device ------------------
252
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")
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 s:taboption("advanced", Flag, "diversity", translate("Diversity")).rmempty = false
272
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"))
281
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"))
289
290 else -- NanoFoo
291 local ant = s:taboption("advanced", ListValue, "antenna", translate("Transmitter Antenna"))
292 ant:value("auto")
293 ant:value("vertical")
294 ant:value("horizontal")
295 ant:value("external")
296 end
297
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"))
303
304 --s:option(Flag, "nosbeacon", translate("Disable HW-Beacon timer"))
305 end
306
307
308
309 ------------------- Broadcom Device ------------------
310
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")
315
316 tp.rmempty = true
317 tp.default = tx_power_cur
318
319 function tp.cfgvalue(...)
320 return txpower_current(Value.cfgvalue(...), tx_power_list)
321 end
322
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 })
327 end
328
329 mode = s:taboption("advanced", ListValue, "hwmode", translate("Band"))
330 if hw_modes.b then
331 mode:value("11b", "2.4GHz (802.11b)")
332 if hw_modes.g then
333 mode:value("11bg", "2.4GHz (802.11b+g)")
334 end
335 end
336 if hw_modes.g then
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)")
340 end
341 if hw_modes.a then mode:value("11a", "5GHz (802.11a)") end
342 if hw_modes.n then
343 if hw_modes.g then
344 mode:value("11ng", "2.4GHz (802.11g+n)")
345 mode:value("11n", "2.4GHz (802.11n)")
346 end
347 if hw_modes.a then
348 mode:value("11na", "5GHz (802.11a+n)")
349 mode:value("11n", "5GHz (802.11n)")
350 end
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")
357 end
358
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"))
365
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"))
372
373 s:taboption("advanced", Flag, "frameburst", translate("Frame Bursting"))
374
375 s:taboption("advanced", Value, "distance", translate("Distance Optimization"))
376 --s:option(Value, "slottime", translate("Slot time"))
377
378 s:taboption("advanced", Value, "country", translate("Country Code"))
379 s:taboption("advanced", Value, "maxassoc", translate("Connection Limit"))
380 end
381
382
383 --------------------- HostAP Device ---------------------
384
385 if hwtype == "prism2" then
386 s:taboption("advanced", Value, "txpower", translate("Transmit Power"), "att units").rmempty = true
387
388 s:taboption("advanced", Flag, "diversity", translate("Diversity")).rmempty = false
389
390 s:taboption("advanced", Value, "txantenna", translate("Transmitter Antenna"))
391 s:taboption("advanced", Value, "rxantenna", translate("Receiver Antenna"))
392 end
393
394
395 ----------------------- Interface -----------------------
396
397 s = m:section(NamedSection, wnet.sid, "wifi-iface", translate("Interface Configuration"))
398 ifsection = s
399 s.addremove = false
400 s.anonymous = true
401 s.defaults.device = wdev:name()
402
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"))
407
408 ssid = s:taboption("general", Value, "ssid", translate("<abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
409 ssid.datatype = "maxlength(32)"
410
411 mode = s:taboption("general", ListValue, "mode", translate("Mode"))
412 mode.override_values = true
413 mode:value("ap", translate("Access Point"))
414 mode:value("sta", translate("Client"))
415 mode:value("adhoc", translate("Ad-Hoc"))
416
417 bssid = s:taboption("general", Value, "bssid", translate("<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"))
418
419 network = s:taboption("general", Value, "network", translate("Network"),
420 translate("Choose the network(s) you want to attach to this wireless interface or " ..
421 "fill out the <em>create</em> field to define a new network."))
422
423 network.rmempty = true
424 network.template = "cbi/network_netlist"
425 network.widget = "checkbox"
426 network.novirtual = true
427
428 function network.write(self, section, value)
429 local i = nw:get_interface(section)
430 if i then
431 if value == '-' then
432 value = m:formvalue(self:cbid(section) .. ".newnet")
433 if value and #value > 0 then
434 local n = nw:add_network(value, {proto="none"})
435 if n then n:add_interface(i) end
436 else
437 local n = i:get_network()
438 if n then n:del_interface(i) end
439 end
440 else
441 local v
442 for _, v in ipairs(i:get_networks()) do
443 v:del_interface(i)
444 end
445 for v in ut.imatch(value) do
446 local n = nw:get_network(v)
447 if n then
448 if not n:is_empty() then
449 n:set("type", "bridge")
450 end
451 n:add_interface(i)
452 end
453 end
454 end
455 end
456 end
457
458 -------------------- MAC80211 Interface ----------------------
459
460 if hwtype == "mac80211" then
461 if fs.access("/usr/sbin/iw") then
462 mode:value("mesh", "802.11s")
463 end
464
465 mode:value("ahdemo", translate("Pseudo Ad-Hoc (ahdemo)"))
466 mode:value("monitor", translate("Monitor"))
467 bssid:depends({mode="adhoc"})
468 bssid:depends({mode="sta"})
469 bssid:depends({mode="sta-wds"})
470
471 mp = s:taboption("macfilter", ListValue, "macfilter", translate("MAC-Address Filter"))
472 mp:depends({mode="ap"})
473 mp:depends({mode="ap-wds"})
474 mp:value("", translate("disable"))
475 mp:value("allow", translate("Allow listed only"))
476 mp:value("deny", translate("Allow all except listed"))
477
478 ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List"))
479 ml.datatype = "macaddr"
480 ml:depends({macfilter="allow"})
481 ml:depends({macfilter="deny"})
482 nt.mac_hints(function(mac, name) ml:value(mac, "%s (%s)" %{ mac, name }) end)
483
484 mode:value("ap-wds", "%s (%s)" % {translate("Access Point"), translate("WDS")})
485 mode:value("sta-wds", "%s (%s)" % {translate("Client"), translate("WDS")})
486
487 function mode.write(self, section, value)
488 if value == "ap-wds" then
489 ListValue.write(self, section, "ap")
490 m.uci:set("wireless", section, "wds", 1)
491 elseif value == "sta-wds" then
492 ListValue.write(self, section, "sta")
493 m.uci:set("wireless", section, "wds", 1)
494 else
495 ListValue.write(self, section, value)
496 m.uci:delete("wireless", section, "wds")
497 end
498 end
499
500 function mode.cfgvalue(self, section)
501 local mode = ListValue.cfgvalue(self, section)
502 local wds = m.uci:get("wireless", section, "wds") == "1"
503
504 if mode == "ap" and wds then
505 return "ap-wds"
506 elseif mode == "sta" and wds then
507 return "sta-wds"
508 else
509 return mode
510 end
511 end
512
513 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
514 hidden:depends({mode="ap"})
515 hidden:depends({mode="ap-wds"})
516
517 wmm = s:taboption("general", Flag, "wmm", translate("WMM Mode"))
518 wmm:depends({mode="ap"})
519 wmm:depends({mode="ap-wds"})
520 wmm.default = wmm.enabled
521
522 ifname = s:taboption("advanced", Value, "ifname", translate("Interface name"), translate("Override default interface name"))
523 ifname.optional = true
524 end
525
526
527
528 -------------------- Madwifi Interface ----------------------
529
530 if hwtype == "atheros" then
531 mode:value("ahdemo", translate("Pseudo Ad-Hoc (ahdemo)"))
532 mode:value("monitor", translate("Monitor"))
533 mode:value("ap-wds", "%s (%s)" % {translate("Access Point"), translate("WDS")})
534 mode:value("sta-wds", "%s (%s)" % {translate("Client"), translate("WDS")})
535 mode:value("wds", translate("Static WDS"))
536
537 function mode.write(self, section, value)
538 if value == "ap-wds" then
539 ListValue.write(self, section, "ap")
540 m.uci:set("wireless", section, "wds", 1)
541 elseif value == "sta-wds" then
542 ListValue.write(self, section, "sta")
543 m.uci:set("wireless", section, "wds", 1)
544 else
545 ListValue.write(self, section, value)
546 m.uci:delete("wireless", section, "wds")
547 end
548 end
549
550 function mode.cfgvalue(self, section)
551 local mode = ListValue.cfgvalue(self, section)
552 local wds = m.uci:get("wireless", section, "wds") == "1"
553
554 if mode == "ap" and wds then
555 return "ap-wds"
556 elseif mode == "sta" and wds then
557 return "sta-wds"
558 else
559 return mode
560 end
561 end
562
563 bssid:depends({mode="adhoc"})
564 bssid:depends({mode="ahdemo"})
565 bssid:depends({mode="wds"})
566
567 wdssep = s:taboption("advanced", Flag, "wdssep", translate("Separate WDS"))
568 wdssep:depends({mode="ap-wds"})
569
570 s:taboption("advanced", Flag, "doth", "802.11h")
571 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
572 hidden:depends({mode="ap"})
573 hidden:depends({mode="adhoc"})
574 hidden:depends({mode="ap-wds"})
575 hidden:depends({mode="sta-wds"})
576 isolate = s:taboption("advanced", Flag, "isolate", translate("Separate Clients"),
577 translate("Prevents client-to-client communication"))
578 isolate:depends({mode="ap"})
579 s:taboption("advanced", Flag, "bgscan", translate("Background Scan"))
580
581 mp = s:taboption("macfilter", ListValue, "macpolicy", translate("MAC-Address Filter"))
582 mp:value("", translate("disable"))
583 mp:value("allow", translate("Allow listed only"))
584 mp:value("deny", translate("Allow all except listed"))
585
586 ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List"))
587 ml.datatype = "macaddr"
588 ml:depends({macpolicy="allow"})
589 ml:depends({macpolicy="deny"})
590 nt.mac_hints(function(mac, name) ml:value(mac, "%s (%s)" %{ mac, name }) end)
591
592 s:taboption("advanced", Value, "rate", translate("Transmission Rate"))
593 s:taboption("advanced", Value, "mcast_rate", translate("Multicast Rate"))
594 s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
595 s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
596 s:taboption("advanced", Value, "minrate", translate("Minimum Rate"))
597 s:taboption("advanced", Value, "maxrate", translate("Maximum Rate"))
598 s:taboption("advanced", Flag, "compression", translate("Compression"))
599
600 s:taboption("advanced", Flag, "bursting", translate("Frame Bursting"))
601 s:taboption("advanced", Flag, "turbo", translate("Turbo Mode"))
602 s:taboption("advanced", Flag, "ff", translate("Fast Frames"))
603
604 s:taboption("advanced", Flag, "wmm", translate("WMM Mode"))
605 s:taboption("advanced", Flag, "xr", translate("XR Support"))
606 s:taboption("advanced", Flag, "ar", translate("AR Support"))
607
608 local swm = s:taboption("advanced", Flag, "sw_merge", translate("Disable HW-Beacon timer"))
609 swm:depends({mode="adhoc"})
610
611 local nos = s:taboption("advanced", Flag, "nosbeacon", translate("Disable HW-Beacon timer"))
612 nos:depends({mode="sta"})
613 nos:depends({mode="sta-wds"})
614
615 local probereq = s:taboption("advanced", Flag, "probereq", translate("Do not send probe responses"))
616 probereq.enabled = "0"
617 probereq.disabled = "1"
618 end
619
620
621 -------------------- Broadcom Interface ----------------------
622
623 if hwtype == "broadcom" then
624 mode:value("wds", translate("WDS"))
625 mode:value("monitor", translate("Monitor"))
626
627 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
628 hidden:depends({mode="ap"})
629 hidden:depends({mode="adhoc"})
630 hidden:depends({mode="wds"})
631
632 isolate = s:taboption("advanced", Flag, "isolate", translate("Separate Clients"),
633 translate("Prevents client-to-client communication"))
634 isolate:depends({mode="ap"})
635
636 s:taboption("advanced", Flag, "doth", "802.11h")
637 s:taboption("advanced", Flag, "wmm", translate("WMM Mode"))
638
639 bssid:depends({mode="wds"})
640 bssid:depends({mode="adhoc"})
641 end
642
643
644 ----------------------- HostAP Interface ---------------------
645
646 if hwtype == "prism2" then
647 mode:value("wds", translate("WDS"))
648 mode:value("monitor", translate("Monitor"))
649
650 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
651 hidden:depends({mode="ap"})
652 hidden:depends({mode="adhoc"})
653 hidden:depends({mode="wds"})
654
655 bssid:depends({mode="sta"})
656
657 mp = s:taboption("macfilter", ListValue, "macpolicy", translate("MAC-Address Filter"))
658 mp:value("", translate("disable"))
659 mp:value("allow", translate("Allow listed only"))
660 mp:value("deny", translate("Allow all except listed"))
661 ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List"))
662 ml:depends({macpolicy="allow"})
663 ml:depends({macpolicy="deny"})
664 nt.mac_hints(function(mac, name) ml:value(mac, "%s (%s)" %{ mac, name }) end)
665
666 s:taboption("advanced", Value, "rate", translate("Transmission Rate"))
667 s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
668 s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
669 end
670
671
672 ------------------- WiFI-Encryption -------------------
673
674 encr = s:taboption("encryption", ListValue, "encryption", translate("Encryption"))
675 encr.override_values = true
676 encr.override_depends = true
677 encr:depends({mode="ap"})
678 encr:depends({mode="sta"})
679 encr:depends({mode="adhoc"})
680 encr:depends({mode="ahdemo"})
681 encr:depends({mode="ap-wds"})
682 encr:depends({mode="sta-wds"})
683 encr:depends({mode="mesh"})
684
685 cipher = s:taboption("encryption", ListValue, "cipher", translate("Cipher"))
686 cipher:depends({encryption="wpa"})
687 cipher:depends({encryption="wpa2"})
688 cipher:depends({encryption="psk"})
689 cipher:depends({encryption="psk2"})
690 cipher:depends({encryption="wpa-mixed"})
691 cipher:depends({encryption="psk-mixed"})
692 cipher:value("auto", translate("auto"))
693 cipher:value("ccmp", translate("Force CCMP (AES)"))
694 cipher:value("tkip", translate("Force TKIP"))
695 cipher:value("tkip+ccmp", translate("Force TKIP and CCMP (AES)"))
696
697 function encr.cfgvalue(self, section)
698 local v = tostring(ListValue.cfgvalue(self, section))
699 if v == "wep" then
700 return "wep-open"
701 elseif v and v:match("%+") then
702 return (v:gsub("%+.+$", ""))
703 end
704 return v
705 end
706
707 function encr.write(self, section, value)
708 local e = tostring(encr:formvalue(section))
709 local c = tostring(cipher:formvalue(section))
710 if value == "wpa" or value == "wpa2" then
711 self.map.uci:delete("wireless", section, "key")
712 end
713 if e and (c == "tkip" or c == "ccmp" or c == "tkip+ccmp") then
714 e = e .. "+" .. c
715 end
716 self.map:set(section, "encryption", e)
717 end
718
719 function cipher.cfgvalue(self, section)
720 local v = tostring(ListValue.cfgvalue(encr, section))
721 if v and v:match("%+") then
722 v = v:gsub("^[^%+]+%+", "")
723 if v == "aes" then v = "ccmp"
724 elseif v == "tkip+aes" then v = "tkip+ccmp"
725 elseif v == "aes+tkip" then v = "tkip+ccmp"
726 elseif v == "ccmp+tkip" then v = "tkip+ccmp"
727 end
728 end
729 return v
730 end
731
732 function cipher.write(self, section)
733 return encr:write(section)
734 end
735
736
737 encr:value("none", "No Encryption")
738 encr:value("wep-open", translate("WEP Open System"), {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"}, {mode="ahdemo"}, {mode="wds"})
739 encr:value("wep-shared", translate("WEP Shared Key"), {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"}, {mode="ahdemo"}, {mode="wds"})
740
741 if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
742 local supplicant = fs.access("/usr/sbin/wpa_supplicant")
743 local hostapd = fs.access("/usr/sbin/hostapd")
744
745 -- Probe EAP support
746 local has_ap_eap = (os.execute("hostapd -veap >/dev/null 2>/dev/null") == 0)
747 local has_sta_eap = (os.execute("wpa_supplicant -veap >/dev/null 2>/dev/null") == 0)
748
749 if hostapd and supplicant then
750 encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
751 encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
752 encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
753 if has_ap_eap and has_sta_eap then
754 encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
755 encr:value("wpa2", "WPA2-EAP", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
756 end
757 elseif hostapd and not supplicant then
758 encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="ap-wds"})
759 encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="ap-wds"})
760 encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="ap"}, {mode="ap-wds"})
761 if has_ap_eap then
762 encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="ap-wds"})
763 encr:value("wpa2", "WPA2-EAP", {mode="ap"}, {mode="ap-wds"})
764 end
765 encr.description = translate(
766 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
767 "and ad-hoc mode) to be installed."
768 )
769 elseif not hostapd and supplicant then
770 encr:value("psk", "WPA-PSK", {mode="sta"}, {mode="sta-wds"})
771 encr:value("psk2", "WPA2-PSK", {mode="sta"}, {mode="sta-wds"})
772 encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="sta"}, {mode="sta-wds"})
773 if has_sta_eap then
774 encr:value("wpa", "WPA-EAP", {mode="sta"}, {mode="sta-wds"})
775 encr:value("wpa2", "WPA2-EAP", {mode="sta"}, {mode="sta-wds"})
776 end
777 encr.description = translate(
778 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
779 "and ad-hoc mode) to be installed."
780 )
781 else
782 encr.description = translate(
783 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
784 "and ad-hoc mode) to be installed."
785 )
786 end
787 elseif hwtype == "broadcom" then
788 encr:value("psk", "WPA-PSK")
789 encr:value("psk2", "WPA2-PSK")
790 encr:value("psk+psk2", "WPA-PSK/WPA2-PSK Mixed Mode")
791 end
792
793 auth_server = s:taboption("encryption", Value, "auth_server", translate("Radius-Authentication-Server"))
794 auth_server:depends({mode="ap", encryption="wpa"})
795 auth_server:depends({mode="ap", encryption="wpa2"})
796 auth_server:depends({mode="ap-wds", encryption="wpa"})
797 auth_server:depends({mode="ap-wds", encryption="wpa2"})
798 auth_server.rmempty = true
799 auth_server.datatype = "host(0)"
800
801 auth_port = s:taboption("encryption", Value, "auth_port", translate("Radius-Authentication-Port"), translatef("Default %d", 1812))
802 auth_port:depends({mode="ap", encryption="wpa"})
803 auth_port:depends({mode="ap", encryption="wpa2"})
804 auth_port:depends({mode="ap-wds", encryption="wpa"})
805 auth_port:depends({mode="ap-wds", encryption="wpa2"})
806 auth_port.rmempty = true
807 auth_port.datatype = "port"
808
809 auth_secret = s:taboption("encryption", Value, "auth_secret", translate("Radius-Authentication-Secret"))
810 auth_secret:depends({mode="ap", encryption="wpa"})
811 auth_secret:depends({mode="ap", encryption="wpa2"})
812 auth_secret:depends({mode="ap-wds", encryption="wpa"})
813 auth_secret:depends({mode="ap-wds", encryption="wpa2"})
814 auth_secret.rmempty = true
815 auth_secret.password = true
816
817 acct_server = s:taboption("encryption", Value, "acct_server", translate("Radius-Accounting-Server"))
818 acct_server:depends({mode="ap", encryption="wpa"})
819 acct_server:depends({mode="ap", encryption="wpa2"})
820 acct_server:depends({mode="ap-wds", encryption="wpa"})
821 acct_server:depends({mode="ap-wds", encryption="wpa2"})
822 acct_server.rmempty = true
823 acct_server.datatype = "host(0)"
824
825 acct_port = s:taboption("encryption", Value, "acct_port", translate("Radius-Accounting-Port"), translatef("Default %d", 1813))
826 acct_port:depends({mode="ap", encryption="wpa"})
827 acct_port:depends({mode="ap", encryption="wpa2"})
828 acct_port:depends({mode="ap-wds", encryption="wpa"})
829 acct_port:depends({mode="ap-wds", encryption="wpa2"})
830 acct_port.rmempty = true
831 acct_port.datatype = "port"
832
833 acct_secret = s:taboption("encryption", Value, "acct_secret", translate("Radius-Accounting-Secret"))
834 acct_secret:depends({mode="ap", encryption="wpa"})
835 acct_secret:depends({mode="ap", encryption="wpa2"})
836 acct_secret:depends({mode="ap-wds", encryption="wpa"})
837 acct_secret:depends({mode="ap-wds", encryption="wpa2"})
838 acct_secret.rmempty = true
839 acct_secret.password = true
840
841 wpakey = s:taboption("encryption", Value, "_wpa_key", translate("Key"))
842 wpakey:depends("encryption", "psk")
843 wpakey:depends("encryption", "psk2")
844 wpakey:depends("encryption", "psk+psk2")
845 wpakey:depends("encryption", "psk-mixed")
846 wpakey.datatype = "wpakey"
847 wpakey.rmempty = true
848 wpakey.password = true
849
850 wpakey.cfgvalue = function(self, section, value)
851 local key = m.uci:get("wireless", section, "key")
852 if key == "1" or key == "2" or key == "3" or key == "4" then
853 return nil
854 end
855 return key
856 end
857
858 wpakey.write = function(self, section, value)
859 self.map.uci:set("wireless", section, "key", value)
860 self.map.uci:delete("wireless", section, "key1")
861 end
862
863
864 wepslot = s:taboption("encryption", ListValue, "_wep_key", translate("Used Key Slot"))
865 wepslot:depends("encryption", "wep-open")
866 wepslot:depends("encryption", "wep-shared")
867 wepslot:value("1", translatef("Key #%d", 1))
868 wepslot:value("2", translatef("Key #%d", 2))
869 wepslot:value("3", translatef("Key #%d", 3))
870 wepslot:value("4", translatef("Key #%d", 4))
871
872 wepslot.cfgvalue = function(self, section)
873 local slot = tonumber(m.uci:get("wireless", section, "key"))
874 if not slot or slot < 1 or slot > 4 then
875 return 1
876 end
877 return slot
878 end
879
880 wepslot.write = function(self, section, value)
881 self.map.uci:set("wireless", section, "key", value)
882 end
883
884 local slot
885 for slot=1,4 do
886 wepkey = s:taboption("encryption", Value, "key" .. slot, translatef("Key #%d", slot))
887 wepkey:depends("encryption", "wep-open")
888 wepkey:depends("encryption", "wep-shared")
889 wepkey.datatype = "wepkey"
890 wepkey.rmempty = true
891 wepkey.password = true
892
893 function wepkey.write(self, section, value)
894 if value and (#value == 5 or #value == 13) then
895 value = "s:" .. value
896 end
897 return Value.write(self, section, value)
898 end
899 end
900
901
902 if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
903
904 -- Probe EAP support as a proxy for determining if 802.11r support is present
905 local has_ap_eap = (os.execute("hostapd -veap >/dev/null 2>/dev/null") == 0)
906
907 ieee80211r = s:taboption("encryption", Flag, "ieee80211r",
908 translate("802.11r Fast Transition"),
909 translate("Enables fast roaming among access points that belong " ..
910 "to the same Mobility Domain"))
911 ieee80211r:depends({mode="ap", encryption="wpa"})
912 ieee80211r:depends({mode="ap", encryption="wpa2"})
913 ieee80211r:depends({mode="ap-wds", encryption="wpa"})
914 ieee80211r:depends({mode="ap-wds", encryption="wpa2"})
915 if has_ap_eap then
916 ieee80211r:depends({mode="ap", encryption="psk"})
917 ieee80211r:depends({mode="ap", encryption="psk2"})
918 ieee80211r:depends({mode="ap", encryption="psk-mixed"})
919 end
920 ieee80211r.rmempty = true
921
922 nasid = s:taboption("encryption", Value, "nasid", translate("NAS ID"),
923 translate("Used for two different purposes: RADIUS NAS ID and " ..
924 "802.11r R0KH-ID. Not needed with normal WPA(2)-PSK."))
925 nasid:depends({mode="ap", encryption="wpa"})
926 nasid:depends({mode="ap", encryption="wpa2"})
927 nasid:depends({mode="ap-wds", encryption="wpa"})
928 nasid:depends({mode="ap-wds", encryption="wpa2"})
929 nasid:depends({ieee80211r="1"})
930 nasid.rmempty = true
931
932 mobility_domain = s:taboption("encryption", Value, "mobility_domain",
933 translate("Mobility Domain"),
934 translate("4-character hexadecimal ID"))
935 mobility_domain:depends({ieee80211r="1"})
936 mobility_domain.placeholder = "4f57"
937 mobility_domain.datatype = "and(hexstring,rangelength(4,4))"
938 mobility_domain.rmempty = true
939
940 r0_key_lifetime = s:taboption("encryption", Value, "r0_key_lifetime",
941 translate("R0 Key Lifetime"), translate("minutes"))
942 r0_key_lifetime:depends({ieee80211r="1"})
943 r0_key_lifetime.placeholder = "10000"
944 r0_key_lifetime.datatype = "uinteger"
945 r0_key_lifetime.rmempty = true
946
947 r1_key_holder = s:taboption("encryption", Value, "r1_key_holder",
948 translate("R1 Key Holder"),
949 translate("6-octet identifier as a hex string - no colons"))
950 r1_key_holder:depends({ieee80211r="1"})
951 r1_key_holder.placeholder = "00004f577274"
952 r1_key_holder.datatype = "and(hexstring,rangelength(12,12))"
953 r1_key_holder.rmempty = true
954
955 reassociation_deadline = s:taboption("encryption", Value, "reassociation_deadline",
956 translate("Reassociation Deadline"),
957 translate("time units (TUs / 1.024 ms) [1000-65535]"))
958 reassociation_deadline:depends({ieee80211r="1"})
959 reassociation_deadline.placeholder = "1000"
960 reassociation_deadline.datatype = "range(1000,65535)"
961 reassociation_deadline.rmempty = true
962
963 pmk_r1_push = s:taboption("encryption", Flag, "pmk_r1_push", translate("PMK R1 Push"))
964 pmk_r1_push:depends({ieee80211r="1"})
965 pmk_r1_push.placeholder = "0"
966 pmk_r1_push.rmempty = true
967
968 r0kh = s:taboption("encryption", DynamicList, "r0kh", translate("External R0 Key Holder List"),
969 translate("List of R0KHs in the same Mobility Domain. " ..
970 "<br>Format: MAC-address,NAS-Identifier,128-bit key as hex string. " ..
971 "<br>This list is used to map R0KH-ID (NAS Identifier) to a destination " ..
972 "MAC address when requesting PMK-R1 key from the R0KH that the STA " ..
973 "used during the Initial Mobility Domain Association."))
974
975 r0kh:depends({ieee80211r="1"})
976 r0kh.rmempty = true
977
978 r1kh = s:taboption("encryption", DynamicList, "r1kh", translate("External R1 Key Holder List"),
979 translate ("List of R1KHs in the same Mobility Domain. "..
980 "<br>Format: MAC-address,R1KH-ID as 6 octets with colons,128-bit key as hex string. "..
981 "<br>This list is used to map R1KH-ID to a destination MAC address " ..
982 "when sending PMK-R1 key from the R0KH. This is also the " ..
983 "list of authorized R1KHs in the MD that can request PMK-R1 keys."))
984 r1kh:depends({ieee80211r="1"})
985 r1kh.rmempty = true
986 -- End of 802.11r options
987
988 eaptype = s:taboption("encryption", ListValue, "eap_type", translate("EAP-Method"))
989 eaptype:value("tls", "TLS")
990 eaptype:value("ttls", "TTLS")
991 eaptype:value("peap", "PEAP")
992 eaptype:value("fast", "FAST")
993 eaptype:depends({mode="sta", encryption="wpa"})
994 eaptype:depends({mode="sta", encryption="wpa2"})
995 eaptype:depends({mode="sta-wds", encryption="wpa"})
996 eaptype:depends({mode="sta-wds", encryption="wpa2"})
997
998 cacert = s:taboption("encryption", FileUpload, "ca_cert", translate("Path to CA-Certificate"))
999 cacert:depends({mode="sta", encryption="wpa"})
1000 cacert:depends({mode="sta", encryption="wpa2"})
1001 cacert:depends({mode="sta-wds", encryption="wpa"})
1002 cacert:depends({mode="sta-wds", encryption="wpa2"})
1003 cacert.rmempty = true
1004
1005 clientcert = s:taboption("encryption", FileUpload, "client_cert", translate("Path to Client-Certificate"))
1006 clientcert:depends({mode="sta", eap_type="tls", encryption="wpa"})
1007 clientcert:depends({mode="sta", eap_type="tls", encryption="wpa2"})
1008 clientcert:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
1009 clientcert:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
1010
1011 privkey = s:taboption("encryption", FileUpload, "priv_key", translate("Path to Private Key"))
1012 privkey:depends({mode="sta", eap_type="tls", encryption="wpa2"})
1013 privkey:depends({mode="sta", eap_type="tls", encryption="wpa"})
1014 privkey:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
1015 privkey:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
1016
1017 privkeypwd = s:taboption("encryption", Value, "priv_key_pwd", translate("Password of Private Key"))
1018 privkeypwd:depends({mode="sta", eap_type="tls", encryption="wpa2"})
1019 privkeypwd:depends({mode="sta", eap_type="tls", encryption="wpa"})
1020 privkeypwd:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
1021 privkeypwd:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
1022 privkeypwd.rmempty = true
1023 privkeypwd.password = true
1024
1025 auth = s:taboption("encryption", ListValue, "auth", translate("Authentication"))
1026 auth:value("PAP", "PAP", {eap_type="ttls"})
1027 auth:value("CHAP", "CHAP", {eap_type="ttls"})
1028 auth:value("MSCHAP", "MSCHAP", {eap_type="ttls"})
1029 auth:value("MSCHAPV2", "MSCHAPv2", {eap_type="ttls"})
1030 auth:value("EAP-GTC")
1031 auth:value("EAP-MD5")
1032 auth:value("EAP-MSCHAPV2")
1033 auth:value("EAP-TLS")
1034 auth:depends({mode="sta", eap_type="fast", encryption="wpa2"})
1035 auth:depends({mode="sta", eap_type="fast", encryption="wpa"})
1036 auth:depends({mode="sta", eap_type="peap", encryption="wpa2"})
1037 auth:depends({mode="sta", eap_type="peap", encryption="wpa"})
1038 auth:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
1039 auth:depends({mode="sta", eap_type="ttls", encryption="wpa"})
1040 auth:depends({mode="sta-wds", eap_type="fast", encryption="wpa2"})
1041 auth:depends({mode="sta-wds", eap_type="fast", encryption="wpa"})
1042 auth:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
1043 auth:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
1044 auth:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
1045 auth:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
1046
1047 cacert2 = s:taboption("encryption", FileUpload, "ca_cert2", translate("Path to inner CA-Certificate"))
1048 cacert2:depends({mode="sta", auth="EAP-TLS", encryption="wpa"})
1049 cacert2:depends({mode="sta", auth="EAP-TLS", encryption="wpa2"})
1050 cacert2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa"})
1051 cacert2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa2"})
1052
1053 clientcert2 = s:taboption("encryption", FileUpload, "client_cert2", translate("Path to inner Client-Certificate"))
1054 clientcert2:depends({mode="sta", auth="EAP-TLS", encryption="wpa"})
1055 clientcert2:depends({mode="sta", auth="EAP-TLS", encryption="wpa2"})
1056 clientcert2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa"})
1057 clientcert2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa2"})
1058
1059 privkey2 = s:taboption("encryption", FileUpload, "priv_key2", translate("Path to inner Private Key"))
1060 privkey2:depends({mode="sta", auth="EAP-TLS", encryption="wpa"})
1061 privkey2:depends({mode="sta", auth="EAP-TLS", encryption="wpa2"})
1062 privkey2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa"})
1063 privkey2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa2"})
1064
1065 privkeypwd2 = s:taboption("encryption", Value, "priv_key2_pwd", translate("Password of inner Private Key"))
1066 privkeypwd2:depends({mode="sta", auth="EAP-TLS", encryption="wpa"})
1067 privkeypwd2:depends({mode="sta", auth="EAP-TLS", encryption="wpa2"})
1068 privkeypwd2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa"})
1069 privkeypwd2:depends({mode="sta-wds", auth="EAP-TLS", encryption="wpa2"})
1070 privkeypwd2.rmempty = true
1071 privkeypwd2.password = true
1072
1073 identity = s:taboption("encryption", Value, "identity", translate("Identity"))
1074 identity:depends({mode="sta", eap_type="fast", encryption="wpa2"})
1075 identity:depends({mode="sta", eap_type="fast", encryption="wpa"})
1076 identity:depends({mode="sta", eap_type="peap", encryption="wpa2"})
1077 identity:depends({mode="sta", eap_type="peap", encryption="wpa"})
1078 identity:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
1079 identity:depends({mode="sta", eap_type="ttls", encryption="wpa"})
1080 identity:depends({mode="sta-wds", eap_type="fast", encryption="wpa2"})
1081 identity:depends({mode="sta-wds", eap_type="fast", encryption="wpa"})
1082 identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
1083 identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
1084 identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
1085 identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
1086 identity:depends({mode="sta", eap_type="tls", encryption="wpa2"})
1087 identity:depends({mode="sta", eap_type="tls", encryption="wpa"})
1088 identity:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
1089 identity:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
1090
1091 anonymous_identity = s:taboption("encryption", Value, "anonymous_identity", translate("Anonymous Identity"))
1092 anonymous_identity:depends({mode="sta", eap_type="fast", encryption="wpa2"})
1093 anonymous_identity:depends({mode="sta", eap_type="fast", encryption="wpa"})
1094 anonymous_identity:depends({mode="sta", eap_type="peap", encryption="wpa2"})
1095 anonymous_identity:depends({mode="sta", eap_type="peap", encryption="wpa"})
1096 anonymous_identity:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
1097 anonymous_identity:depends({mode="sta", eap_type="ttls", encryption="wpa"})
1098 anonymous_identity:depends({mode="sta-wds", eap_type="fast", encryption="wpa2"})
1099 anonymous_identity:depends({mode="sta-wds", eap_type="fast", encryption="wpa"})
1100 anonymous_identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
1101 anonymous_identity:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
1102 anonymous_identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
1103 anonymous_identity:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
1104 anonymous_identity:depends({mode="sta", eap_type="tls", encryption="wpa2"})
1105 anonymous_identity:depends({mode="sta", eap_type="tls", encryption="wpa"})
1106 anonymous_identity:depends({mode="sta-wds", eap_type="tls", encryption="wpa2"})
1107 anonymous_identity:depends({mode="sta-wds", eap_type="tls", encryption="wpa"})
1108
1109 password = s:taboption("encryption", Value, "password", translate("Password"))
1110 password:depends({mode="sta", eap_type="fast", encryption="wpa2"})
1111 password:depends({mode="sta", eap_type="fast", encryption="wpa"})
1112 password:depends({mode="sta", eap_type="peap", encryption="wpa2"})
1113 password:depends({mode="sta", eap_type="peap", encryption="wpa"})
1114 password:depends({mode="sta", eap_type="ttls", encryption="wpa2"})
1115 password:depends({mode="sta", eap_type="ttls", encryption="wpa"})
1116 password:depends({mode="sta-wds", eap_type="fast", encryption="wpa2"})
1117 password:depends({mode="sta-wds", eap_type="fast", encryption="wpa"})
1118 password:depends({mode="sta-wds", eap_type="peap", encryption="wpa2"})
1119 password:depends({mode="sta-wds", eap_type="peap", encryption="wpa"})
1120 password:depends({mode="sta-wds", eap_type="ttls", encryption="wpa2"})
1121 password:depends({mode="sta-wds", eap_type="ttls", encryption="wpa"})
1122 password.rmempty = true
1123 password.password = true
1124 end
1125
1126 -- ieee802.11w options
1127 if hwtype == "mac80211" then
1128 local has_ap_eap = (os.execute("hostapd -veap >/dev/null 2>/dev/null") == 0)
1129 if has_ap_eap then
1130 ieee80211w = s:taboption("encryption", ListValue, "ieee80211w",
1131 translate("802.11w Management Frame Protection"),
1132 translate("Requires the 'full' version of wpad/hostapd " ..
1133 "and support from the wifi driver <br>(as of Feb 2017: " ..
1134 "ath9k and ath10k, in LEDE also mwlwifi and mt76)"))
1135 ieee80211w.default = "0"
1136 ieee80211w.rmempty = true
1137 ieee80211w:value("0", translate("Disabled (default)"))
1138 ieee80211w:value("1", translate("Optional"))
1139 ieee80211w:value("2", translate("Required"))
1140 ieee80211w:depends({mode="ap", encryption="wpa2"})
1141 ieee80211w:depends({mode="ap-wds", encryption="wpa2"})
1142 ieee80211w:depends({mode="ap", encryption="psk2"})
1143 ieee80211w:depends({mode="ap", encryption="psk-mixed"})
1144 ieee80211w:depends({mode="ap-wds", encryption="psk2"})
1145 ieee80211w:depends({mode="ap-wds", encryption="psk-mixed"})
1146
1147 max_timeout = s:taboption("encryption", Value, "ieee80211w_max_timeout",
1148 translate("802.11w maximum timeout"),
1149 translate("802.11w Association SA Query maximum timeout"))
1150 max_timeout:depends({ieee80211w="1"})
1151 max_timeout:depends({ieee80211w="2"})
1152 max_timeout.datatype = "uinteger"
1153 max_timeout.placeholder = "1000"
1154 max_timeout.rmempty = true
1155
1156 retry_timeout = s:taboption("encryption", Value, "ieee80211w_retry_timeout",
1157 translate("802.11w retry timeout"),
1158 translate("802.11w Association SA Query retry timeout"))
1159 retry_timeout:depends({ieee80211w="1"})
1160 retry_timeout:depends({ieee80211w="2"})
1161 retry_timeout.datatype = "uinteger"
1162 retry_timeout.placeholder = "201"
1163 retry_timeout.rmempty = true
1164 end
1165 end
1166
1167 if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
1168 local wpasupplicant = fs.access("/usr/sbin/wpa_supplicant")
1169 local hostcli = fs.access("/usr/sbin/hostapd_cli")
1170 if hostcli and wpasupplicant then
1171 wps = s:taboption("encryption", Flag, "wps_pushbutton", translate("Enable WPS pushbutton, requires WPA(2)-PSK"))
1172 wps.enabled = "1"
1173 wps.disabled = "0"
1174 wps.rmempty = false
1175 wps:depends("encryption", "psk")
1176 wps:depends("encryption", "psk2")
1177 wps:depends("encryption", "psk-mixed")
1178 end
1179 end
1180
1181 return m