module/admin-full: add missing mode+wds -> ap/sta-wds reverse mapping for mac80211...
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_network / wifi.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14
15 local wa = require "luci.tools.webadmin"
16 local nw = require "luci.model.network"
17 local ww = require "luci.model.wireless"
18 local fs = require "nixio.fs"
19
20 arg[1] = arg[1] or ""
21 arg[2] = arg[2] or ""
22
23 m = Map("wireless", "",
24         translate("The <em>Device Configuration</em> section covers physical settings of the radio " ..
25                 "hardware such as channel, transmit power or antenna selection which is shared among all " ..
26                 "defined wireless networks (if the radio hardware is multi-SSID capable). Per network settings " ..
27                 "like encryption or operation mode are grouped in the <em>Interface Configuration</em>."))
28
29 m:chain("network")
30
31 m.breadcrumb = {
32         { luci.dispatcher.build_url("admin/network/wireless"), translate("Wireless Networks") }
33 }
34
35 local ifsection
36
37 function m.on_commit(map)
38         nw.init(map.uci)
39         ww.init(map.uci)
40
41         local wnet = ww:get_network(arg[2])
42         if ifsection and wnet then
43                 ifsection.section = wnet.sid
44         end
45 end
46
47 nw.init(m.uci)
48 ww.init(m.uci)
49
50 local wnet = ww:get_network(arg[2])
51
52 -- redirect to overview page if network does not exist anymore (e.g. after a revert)
53 if not wnet then
54         luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
55         return
56 end
57
58 m.title = ww:get_i18n(wnet)
59
60
61 local iw = nil
62 local tx_powers = nil
63
64 m.uci:foreach("wireless", "wifi-iface",
65         function(s)
66                 if s.device == arg[1] and not iw then
67                         iw = luci.sys.wifi.getiwinfo(s.ifname or s.device)
68                         tx_powers = iw.txpwrlist or { }
69                 end
70         end)
71
72 s = m:section(NamedSection, arg[1], "wifi-device", translate("Device Configuration"))
73 s.addremove = false
74
75 s:tab("general", translate("General Setup"))
76 s:tab("macfilter", translate("MAC-Filter"))
77 s:tab("advanced", translate("Advanced Settings"))
78
79 --[[
80 back = s:option(DummyValue, "_overview", translate("Overview"))
81 back.value = ""
82 back.titleref = luci.dispatcher.build_url("admin", "network", "wireless")
83 ]]
84
85 en = s:taboption("general", Flag, "disabled", translate("enable"))
86 en.enabled = "0"
87 en.disabled = "1"
88 en.rmempty = false
89
90 function en.cfgvalue(self, section)
91         return Flag.cfgvalue(self, section) or "0"
92 end
93
94 s:taboption("general", DummyValue, "type", translate("Type"))
95
96 local hwtype = m:get(arg[1], "type")
97 -- NanoFoo
98 local nsantenna = m:get(arg[1], "antenna")
99
100 ch = s:taboption("general", Value, "channel", translate("Channel"))
101 ch:value("auto", translate("auto"))
102 for _, f in ipairs(luci.sys.wifi.channels()) do
103         ch:value(f.channel, "%i (%.3f GHz)" %{ f.channel, f.mhz / 1000 })
104 end
105
106
107 ------------------- MAC80211 Device ------------------
108
109 if hwtype == "mac80211" then
110         tp = s:taboption("general",
111                 (tx_powers and #tx_powers > 0) and ListValue or Value,
112                 "txpower", translate("Transmit Power"), "dBm")
113
114         tp.rmempty = true
115         for _, p in ipairs(iw and iw.txpwrlist or {}) do
116                 tp:value(p.dbm, "%i dBm (%i mW)" %{ p.dbm, p.mw })
117         end
118         
119         mode = s:taboption("advanced", ListValue, "hwmode", translate("Mode"))
120         mode:value("", translate("auto"))
121         mode:value("11b", "802.11b")
122         mode:value("11g", "802.11g")
123         mode:value("11a", "802.11a")
124         mode:value("11ng", "802.11g+n")
125         mode:value("11na", "802.11a+n")
126
127         htmode = s:taboption("advanced", ListValue, "htmode", translate("HT mode"))
128         htmode:depends("hwmode", "11na")
129         htmode:depends("hwmode", "11ng")
130         htmode:value("HT20", "20MHz")
131         htmode:value("HT40-", translate("40MHz 2nd channel below"))
132         htmode:value("HT40+", translate("40MHz 2nd channel above"))
133         
134         htcapab = s:taboption("advanced", DynamicList, "ht_capab", translate("HT capabilities"))
135         htcapab:depends("hwmode", "11na")
136         htcapab:depends("hwmode", "11ng")
137         
138         s:taboption("advanced", Value, "country", translate("Country Code"), translate("Use ISO/IEC 3166 alpha2 country codes."))
139         s:taboption("advanced", Value, "distance", translate("Distance Optimization"),
140                 translate("Distance to farthest network member in meters."))    
141 end
142
143
144 ------------------- Madwifi Device ------------------
145
146 if hwtype == "atheros" then
147         tp = s:taboption("general",
148                 (#tx_powers > 0) and ListValue or Value,
149                 "txpower", translate("Transmit Power"), "dBm")
150
151         tp.rmempty = true
152         for _, p in ipairs(iw.txpwrlist) do
153                 tp:value(p.dbm, "%i dBm (%i mW)" %{ p.dbm, p.mw })
154         end
155
156         mode = s:taboption("advanced", ListValue, "hwmode", translate("Mode"))
157         mode:value("", translate("auto"))
158         mode:value("11b", "802.11b")
159         mode:value("11g", "802.11g")
160         mode:value("11a", "802.11a")
161         mode:value("11bg", "802.11b+g")
162         mode:value("11gst", "802.11g + Turbo")
163         mode:value("11ast", "802.11a + Turbo")
164         mode:value("fh", translate("Frequency Hopping"))
165
166         s:taboption("advanced", Flag, "diversity", translate("Diversity")).rmempty = false
167
168         if not nsantenna then
169                 ant1 = s:taboption("advanced", ListValue, "txantenna", translate("Transmitter Antenna"))
170                 ant1.widget = "radio"
171                 ant1.orientation = "horizontal"
172                 ant1:depends("diversity", "")
173                 ant1:value("0", translate("auto"))
174                 ant1:value("1", translate("Antenna 1"))
175                 ant1:value("2", translate("Antenna 2"))
176
177                 ant2 = s:taboption("advanced", ListValue, "rxantenna", translate("Receiver Antenna"))
178                 ant2.widget = "radio"
179                 ant2.orientation = "horizontal"
180                 ant2:depends("diversity", "")
181                 ant2:value("0", translate("auto"))
182                 ant2:value("1", translate("Antenna 1"))
183                 ant2:value("2", translate("Antenna 2"))
184
185         else -- NanoFoo
186                 local ant = s:taboption("advanced", ListValue, "antenna", translate("Transmitter Antenna"))
187                 ant:value("auto")
188                 ant:value("vertical")
189                 ant:value("horizontal")
190                 ant:value("external")
191         end
192
193         s:taboption("advanced", Value, "distance", translate("Distance Optimization"),
194                 translate("Distance to farthest network member in meters."))
195         s:taboption("advanced", Value, "regdomain", translate("Regulatory Domain"))
196         s:taboption("advanced", Value, "country", translate("Country Code"))
197         s:taboption("advanced", Flag, "outdoor", translate("Outdoor Channels"))
198
199         --s:option(Flag, "nosbeacon", translate("Disable HW-Beacon timer"))
200 end
201
202
203
204 ------------------- Broadcom Device ------------------
205
206 if hwtype == "broadcom" then
207         tp = s:taboption("general",
208                 (#tx_powers > 0) and ListValue or Value,
209                 "txpower", translate("Transmit Power"), "dBm")
210
211         tp.rmempty = true
212         for _, p in ipairs(iw.txpwrlist) do
213                 tp:value(p.dbm, "%i dBm (%i mW)" %{ p.dbm, p.mw })
214         end     
215
216         mp = s:taboption("macfilter", ListValue, "macfilter", translate("MAC-Address Filter"))
217         mp:value("", translate("disable"))
218         mp:value("allow", translate("Allow listed only"))
219         mp:value("deny", translate("Allow all except listed"))
220         ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List"))
221         ml:depends({macfilter="allow"})
222         ml:depends({macfilter="deny"})
223
224         ant1 = s:taboption("advanced", ListValue, "txantenna", translate("Transmitter Antenna"))
225         ant1.widget = "radio"
226         ant1:depends("diversity", "")
227         ant1:value("3", translate("auto"))
228         ant1:value("0", translate("Antenna 1"))
229         ant1:value("1", translate("Antenna 2"))
230
231         ant2 = s:taboption("advanced", ListValue, "rxantenna", translate("Receiver Antenna"))
232         ant2.widget = "radio"
233         ant2:depends("diversity", "")
234         ant2:value("3", translate("auto"))
235         ant2:value("0", translate("Antenna 1"))
236         ant2:value("1", translate("Antenna 2"))
237
238         s:taboption("advanced", Flag, "frameburst", translate("Frame Bursting"))
239
240         s:taboption("advanced", Value, "distance", translate("Distance Optimization"))
241         --s:option(Value, "slottime", translate("Slot time"))
242
243         s:taboption("advanced", Value, "country", translate("Country Code"))
244         s:taboption("advanced", Value, "maxassoc", translate("Connection Limit"))
245 end
246
247
248 --------------------- HostAP Device ---------------------
249
250 if hwtype == "prism2" then
251         s:taboption("advanced", Value, "txpower", translate("Transmit Power"), "att units").rmempty = true
252
253         s:taboption("advanced", Flag, "diversity", translate("Diversity")).rmempty = false
254
255         s:taboption("advanced", Value, "txantenna", translate("Transmitter Antenna"))
256         s:taboption("advanced", Value, "rxantenna", translate("Receiver Antenna"))
257 end
258
259
260 ----------------------- Interface -----------------------
261
262 local wnet = ww:get_network(arg[2])
263
264 if wnet then
265         s = m:section(NamedSection, wnet.sid, "wifi-iface", translate("Interface Configuration"))
266         ifsection = s
267         s.addremove = false
268         s.anonymous = true
269         s.defaults.device = arg[1]
270
271         s:tab("general", translate("General Setup"))
272         s:tab("encryption", translate("Wireless Security"))
273         s:tab("macfilter", translate("MAC-Filter"))
274         s:tab("advanced", translate("Advanced Settings"))
275
276         s:taboption("general", Value, "ssid", translate("<abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
277
278         mode = s:taboption("general", ListValue, "mode", translate("Mode"))
279         mode.override_values = true
280         mode:value("ap", translate("Access Point"))
281         mode:value("sta", translate("Client"))
282         mode:value("adhoc", translate("Ad-Hoc"))
283
284         bssid = s:taboption("general", Value, "bssid", translate("<abbr title=\"Basic Service Set Identifier\">BSSID</abbr>"))
285
286         network = s:taboption("general", Value, "network", translate("Network"),
287                 translate("Choose the network you want to attach to this wireless interface. " ..
288                         "Select <em>unspecified</em> to not attach any network or fill out the " ..
289                         "<em>create</em> field to define a new network."))
290
291         network.rmempty = true
292         network.template = "cbi/network_netlist"
293         network.widget = "radio"
294
295         function network.write(self, section, value)
296                 local i = nw:get_interface(section)
297                 if i then
298                         if value == '-' then
299                                 value = m:formvalue(self:cbid(section) .. ".newnet")
300                                 if value and #value > 0 then
301                                         local n = nw:add_network(value, {type="bridge", proto="none"})
302                                         if n then n:add_interface(i) end
303                                 else
304                                         local n = i:get_network()
305                                         if n then n:del_interface(i) end
306                                 end
307                         else
308                                 local n = nw:get_network(value)
309                                 if n then
310                                         n:type("bridge")
311                                         n:add_interface(i)
312                                 end
313                         end
314                 end
315         end
316
317         -------------------- MAC80211 Interface ----------------------
318
319         if hwtype == "mac80211" then
320                 if fs.access("/usr/sbin/iw") then
321                         mode:value("mesh", "802.11s")
322                 end
323
324                 mode:value("ahdemo", translate("Pseudo Ad-Hoc (ahdemo)"))
325                 mode:value("monitor", translate("Monitor"))
326                 bssid:depends({mode="adhoc"})
327
328                 s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
329                 s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
330                 
331                 mode:value("ap-wds", "%s (%s)" % {translate("Access Point"), translate("WDS")})
332                 mode:value("sta-wds", "%s (%s)" % {translate("Client"), translate("WDS")})              
333                 
334                 function mode.write(self, section, value)
335                         if value == "ap-wds" then
336                                 ListValue.write(self, section, "ap")
337                                 m.uci:set("wireless", section, "wds", 1)
338                         elseif value == "sta-wds" then
339                                 ListValue.write(self, section, "sta")
340                                 m.uci:set("wireless", section, "wds", 1)
341                         else
342                                 ListValue.write(self, section, value)
343                                 m.uci:delete("wireless", section, "wds")
344                         end
345                 end
346
347                 function mode.cfgvalue(self, section)
348                         local mode = ListValue.cfgvalue(self, section)
349                         local wds  = m.uci:get("wireless", section, "wds") == "1"
350
351                         if mode == "ap" and wds then
352                                 return "ap-wds"
353                         elseif mode == "sta" and wds then
354                                 return "sta-wds"
355                         else
356                                 return mode
357                         end
358                 end
359                 
360                 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
361                 hidden:depends({mode="ap"})
362                 hidden:depends({mode="ap-wds"})                         
363         end
364
365
366
367         -------------------- Madwifi Interface ----------------------
368
369         if hwtype == "atheros" then
370                 mode:value("ahdemo", translate("Pseudo Ad-Hoc (ahdemo)"))
371                 mode:value("monitor", translate("Monitor"))
372                 mode:value("ap-wds", "%s (%s)" % {translate("Access Point"), translate("WDS")})
373                 mode:value("sta-wds", "%s (%s)" % {translate("Client"), translate("WDS")})
374                 mode:value("wds", translate("Static WDS"))
375
376                 function mode.write(self, section, value)
377                         if value == "ap-wds" then
378                                 ListValue.write(self, section, "ap")
379                                 m.uci:set("wireless", section, "wds", 1)
380                         elseif value == "sta-wds" then
381                                 ListValue.write(self, section, "sta")
382                                 m.uci:set("wireless", section, "wds", 1)
383                         else
384                                 ListValue.write(self, section, value)
385                                 m.uci:delete("wireless", section, "wds")
386                         end
387                 end
388
389                 function mode.cfgvalue(self, section)
390                         local mode = ListValue.cfgvalue(self, section)
391                         local wds  = m.uci:get("wireless", section, "wds") == "1"
392
393                         if mode == "ap" and wds then
394                                 return "ap-wds"
395                         elseif mode == "sta" and wds then
396                                 return "sta-wds"
397                         else
398                                 return mode
399                         end
400                 end
401
402                 bssid:depends({mode="adhoc"})
403                 bssid:depends({mode="ahdemo"})
404                 bssid:depends({mode="wds"})
405
406                 wdssep = s:taboption("advanced", Flag, "wdssep", translate("Separate WDS"))
407                 wdssep:depends({mode="ap-wds"})
408
409                 s:taboption("advanced", Flag, "doth", "802.11h")
410                 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
411                 hidden:depends({mode="ap"})
412                 hidden:depends({mode="adhoc"})
413                 hidden:depends({mode="ap-wds"})
414                 hidden:depends({mode="sta-wds"})
415                 isolate = s:taboption("advanced", Flag, "isolate", translate("Separate Clients"),
416                  translate("Prevents client-to-client communication"))
417                 isolate:depends({mode="ap"})
418                 s:taboption("advanced", Flag, "bgscan", translate("Background Scan"))
419
420                 mp = s:taboption("macfilter", ListValue, "macpolicy", translate("MAC-Address Filter"))
421                 mp:value("", translate("disable"))
422                 mp:value("deny", translate("Allow listed only"))
423                 mp:value("allow", translate("Allow all except listed"))
424                 ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List"))
425                 ml:depends({macpolicy="allow"})
426                 ml:depends({macpolicy="deny"})
427
428                 s:taboption("advanced", Value, "rate", translate("Transmission Rate"))
429                 s:taboption("advanced", Value, "mcast_rate", translate("Multicast Rate"))
430                 s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
431                 s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
432                 s:taboption("advanced", Value, "minrate", translate("Minimum Rate"))
433                 s:taboption("advanced", Value, "maxrate", translate("Maximum Rate"))
434                 s:taboption("advanced", Flag, "compression", translate("Compression"))
435
436                 s:taboption("advanced", Flag, "bursting", translate("Frame Bursting"))
437                 s:taboption("advanced", Flag, "turbo", translate("Turbo Mode"))
438                 s:taboption("advanced", Flag, "ff", translate("Fast Frames"))
439
440                 s:taboption("advanced", Flag, "wmm", translate("WMM Mode"))
441                 s:taboption("advanced", Flag, "xr", translate("XR Support"))
442                 s:taboption("advanced", Flag, "ar", translate("AR Support"))
443
444                 local swm = s:taboption("advanced", Flag, "sw_merge", translate("Disable HW-Beacon timer"))
445                 swm:depends({mode="adhoc"})
446
447                 local nos = s:taboption("advanced", Flag, "nosbeacon", translate("Disable HW-Beacon timer"))
448                 nos:depends({mode="sta"})
449                 nos:depends({mode="sta-wds"})
450
451                 local probereq = s:taboption("advanced", Flag, "probereq", translate("Do not send probe responses"))
452                 probereq.enabled  = "0"
453                 probereq.disabled = "1"
454         end
455
456
457         -------------------- Broadcom Interface ----------------------
458
459         if hwtype == "broadcom" then
460                 mode:value("wds", translate("WDS"))
461                 mode:value("monitor", translate("Monitor"))
462
463                 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
464                 hidden:depends({mode="ap"})
465                 hidden:depends({mode="adhoc"})
466                 hidden:depends({mode="wds"})
467
468                 isolate = s:taboption("advanced", Flag, "isolate", translate("Separate Clients"),
469                  translate("Prevents client-to-client communication"))
470                 isolate:depends({mode="ap"})
471
472                 s:taboption("advanced", Flag, "doth", "802.11h")
473                 s:taboption("advanced", Flag, "wmm", translate("WMM Mode"))
474
475                 bssid:depends({mode="wds"})
476                 bssid:depends({mode="adhoc"})
477         end
478
479
480         ----------------------- HostAP Interface ---------------------
481
482         if hwtype == "prism2" then
483                 mode:value("wds", translate("WDS"))
484                 mode:value("monitor", translate("Monitor"))
485
486                 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
487                 hidden:depends({mode="ap"})
488                 hidden:depends({mode="adhoc"})
489                 hidden:depends({mode="wds"})
490
491                 bssid:depends({mode="sta"})
492
493                 mp = s:taboption("macfilter", ListValue, "macpolicy", translate("MAC-Address Filter"))
494                 mp:value("", translate("disable"))
495                 mp:value("deny", translate("Allow listed only"))
496                 mp:value("allow", translate("Allow all except listed"))
497                 ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List"))
498                 ml:depends({macpolicy="allow"})
499                 ml:depends({macpolicy="deny"})
500
501                 s:taboption("advanced", Value, "rate", translate("Transmission Rate"))
502                 s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
503                 s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
504         end
505
506
507         ------------------- WiFI-Encryption -------------------
508
509         encr = s:taboption("encryption", ListValue, "encryption", translate("Encryption"))
510         encr.override_values = true
511         encr.override_depends = true
512         encr:depends({mode="ap"})
513         encr:depends({mode="sta"})
514         encr:depends({mode="adhoc"})
515         encr:depends({mode="ahdemo"})
516         encr:depends({mode="ap-wds"})
517         encr:depends({mode="sta-wds"})
518         encr:depends({mode="mesh"})
519
520         encr:value("none", "No Encryption")
521         encr:value("wep", "WEP", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
522
523         if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
524                 local supplicant = fs.access("/usr/sbin/wpa_supplicant")
525                 local hostapd = fs.access("/usr/sbin/hostapd")
526
527                 if hostapd and supplicant then
528                         encr:value("psk", "WPA-PSK")
529                         encr:value("psk2", "WPA2-PSK")
530                         encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode")
531                         encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
532                         encr:value("wpa2", "WPA2-EAP", {mode="ap"}, {mode="sta"})
533                 elseif hostapd and not supplicant then
534                         encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="ap-wds"}, {mode="adhoc"}, {mode="ahdemo"})
535                         encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="ap-wds"}, {mode="adhoc"}, {mode="ahdemo"})
536                         encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="ap"}, {mode="ap-wds"}, {mode="adhoc"}, {mode="ahdemo"})
537                         encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="ap-wds"})
538                         encr:value("wpa2", "WPA2-EAP", {mode="ap"}, {mode="ap-wds"})
539                         encr.description = translate(
540                                 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
541                                 "and ad-hoc mode) to be installed."
542                         )
543                 elseif not hostapd and supplicant then
544                         encr:value("psk", "WPA-PSK", {mode="sta"}, {mode="sta-wds"})
545                         encr:value("psk2", "WPA2-PSK", {mode="sta"}, {mode="sta-wds"})
546                         encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="sta"}, {mode="sta-wds"})
547                         encr:value("wpa", "WPA-EAP", {mode="sta"}, {mode="sta-wds"})
548                         encr:value("wpa2", "WPA2-EAP", {mode="sta"}, {mode="sta-wds"})
549                         encr.description = translate(
550                                 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
551                                 "and ad-hoc mode) to be installed."
552                         )
553                 else
554                         encr.description = translate(
555                                 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
556                                 "and ad-hoc mode) to be installed."
557                         )
558                 end
559         elseif hwtype == "broadcom" then
560                 encr:value("psk", "WPA-PSK")
561                 encr:value("psk2", "WPA2-PSK")
562                 encr:value("psk+psk2", "WPA-PSK/WPA2-PSK Mixed Mode")
563         end
564
565         encr:depends("mode", "ap")
566         encr:depends("mode", "sta")
567         encr:depends("mode", "ap-wds")
568         encr:depends("mode", "sta-wds")
569         encr:depends("mode", "wds")
570
571         server = s:taboption("encryption", Value, "server", translate("Radius-Server"))
572         server:depends({mode="ap", encryption="wpa"})
573         server:depends({mode="ap", encryption="wpa2"})
574         server:depends({mode="ap-wds", encryption="wpa"})
575         server:depends({mode="ap-wds", encryption="wpa2"})
576         server.rmempty = true
577
578         port = s:taboption("encryption", Value, "port", translate("Radius-Port"))
579         port:depends({mode="ap", encryption="wpa"})
580         port:depends({mode="ap", encryption="wpa2"})
581         port:depends({mode="ap-wds", encryption="wpa"})
582         port:depends({mode="ap-wds", encryption="wpa2"})
583         port.rmempty = true
584
585         key = s:taboption("encryption", Value, "key", translate("Key"))
586         key:depends("encryption", "wep")
587         key:depends("encryption", "psk")
588         key:depends("encryption", "psk2")
589         key:depends("encryption", "psk+psk2")
590         key:depends("encryption", "psk-mixed")
591         key:depends({mode="ap", encryption="wpa"})
592         key:depends({mode="ap", encryption="wpa2"})
593         key:depends({mode="ap-wds", encryption="wpa"})
594         key:depends({mode="ap-wds", encryption="wpa2"})
595         key.rmempty = true
596         key.password = true
597
598         if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
599                 nasid = s:taboption("encryption", Value, "nasid", translate("NAS ID"))
600                 nasid:depends({mode="ap", encryption="wpa"})
601                 nasid:depends({mode="ap", encryption="wpa2"})
602                 nasid:depends({mode="ap-wds", encryption="wpa"})
603                 nasid:depends({mode="ap-wds", encryption="wpa2"})
604                 nasid.rmempty = true
605
606                 eaptype = s:taboption("encryption", ListValue, "eap_type", translate("EAP-Method"))
607                 eaptype:value("TLS")
608                 eaptype:value("TTLS")
609                 eaptype:value("PEAP")
610                 eaptype:depends({mode="sta", encryption="wpa"})
611                 eaptype:depends({mode="sta", encryption="wpa2"})
612
613                 cacert = s:taboption("encryption", FileUpload, "ca_cert", translate("Path to CA-Certificate"))
614                 cacert:depends({mode="sta", encryption="wpa"})
615                 cacert:depends({mode="sta", encryption="wpa2"})
616
617                 privkey = s:taboption("encryption", FileUpload, "priv_key", translate("Path to Private Key"))
618                 privkey:depends({mode="sta", eap_type="TLS", encryption="wpa2"})
619                 privkey:depends({mode="sta", eap_type="TLS", encryption="wpa"})
620
621                 privkeypwd = s:taboption("encryption", Value, "priv_key_pwd", translate("Password of Private Key"))
622                 privkeypwd:depends({mode="sta", eap_type="TLS", encryption="wpa2"})
623                 privkeypwd:depends({mode="sta", eap_type="TLS", encryption="wpa"})
624
625
626                 auth = s:taboption("encryption", Value, "auth", translate("Authentication"))
627                 auth:value("PAP")
628                 auth:value("CHAP")
629                 auth:value("MSCHAP")
630                 auth:value("MSCHAPV2")
631                 auth:depends({mode="sta", eap_type="PEAP", encryption="wpa2"})
632                 auth:depends({mode="sta", eap_type="PEAP", encryption="wpa"})
633                 auth:depends({mode="sta", eap_type="TTLS", encryption="wpa2"})
634                 auth:depends({mode="sta", eap_type="TTLS", encryption="wpa"})
635
636
637                 identity = s:taboption("encryption", Value, "identity", translate("Identity"))
638                 identity:depends({mode="sta", eap_type="PEAP", encryption="wpa2"})
639                 identity:depends({mode="sta", eap_type="PEAP", encryption="wpa"})
640                 identity:depends({mode="sta", eap_type="TTLS", encryption="wpa2"})
641                 identity:depends({mode="sta", eap_type="TTLS", encryption="wpa"})
642
643                 password = s:taboption("encryption", Value, "password", translate("Password"))
644                 password:depends({mode="sta", eap_type="PEAP", encryption="wpa2"})
645                 password:depends({mode="sta", eap_type="PEAP", encryption="wpa"})
646                 password:depends({mode="sta", eap_type="TTLS", encryption="wpa2"})
647                 password:depends({mode="sta", eap_type="TTLS", encryption="wpa"})
648         end
649 end
650
651 return m