modules/admin-full: add extended mac80211 wireless options for 11n, patch by Dennis...
[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                 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
348                 hidden:depends({mode="ap"})
349                 hidden:depends({mode="ap-wds"})                         
350         end
351
352
353
354         -------------------- Madwifi Interface ----------------------
355
356         if hwtype == "atheros" then
357                 mode:value("ahdemo", translate("Pseudo Ad-Hoc (ahdemo)"))
358                 mode:value("monitor", translate("Monitor"))
359                 mode:value("ap-wds", "%s (%s)" % {translate("Access Point"), translate("WDS")})
360                 mode:value("sta-wds", "%s (%s)" % {translate("Client"), translate("WDS")})
361                 mode:value("wds", translate("Static WDS"))
362
363                 function mode.write(self, section, value)
364                         if value == "ap-wds" then
365                                 ListValue.write(self, section, "ap")
366                                 m.uci:set("wireless", section, "wds", 1)
367                         elseif value == "sta-wds" then
368                                 ListValue.write(self, section, "sta")
369                                 m.uci:set("wireless", section, "wds", 1)
370                         else
371                                 ListValue.write(self, section, value)
372                                 m.uci:delete("wireless", section, "wds")
373                         end
374                 end
375
376                 function mode.cfgvalue(self, section)
377                         local mode = ListValue.cfgvalue(self, section)
378                         local wds  = m.uci:get("wireless", section, "wds") == "1"
379
380                         if mode == "ap" and wds then
381                                 return "ap-wds"
382                         elseif mode == "sta" and wds then
383                                 return "sta-wds"
384                         else
385                                 return mode
386                         end
387                 end
388
389                 bssid:depends({mode="adhoc"})
390                 bssid:depends({mode="ahdemo"})
391                 bssid:depends({mode="wds"})
392
393                 wdssep = s:taboption("advanced", Flag, "wdssep", translate("Separate WDS"))
394                 wdssep:depends({mode="ap-wds"})
395
396                 s:taboption("advanced", Flag, "doth", "802.11h")
397                 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
398                 hidden:depends({mode="ap"})
399                 hidden:depends({mode="adhoc"})
400                 hidden:depends({mode="ap-wds"})
401                 hidden:depends({mode="sta-wds"})
402                 isolate = s:taboption("advanced", Flag, "isolate", translate("Separate Clients"),
403                  translate("Prevents client-to-client communication"))
404                 isolate:depends({mode="ap"})
405                 s:taboption("advanced", Flag, "bgscan", translate("Background Scan"))
406
407                 mp = s:taboption("macfilter", ListValue, "macpolicy", translate("MAC-Address Filter"))
408                 mp:value("", translate("disable"))
409                 mp:value("deny", translate("Allow listed only"))
410                 mp:value("allow", translate("Allow all except listed"))
411                 ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List"))
412                 ml:depends({macpolicy="allow"})
413                 ml:depends({macpolicy="deny"})
414
415                 s:taboption("advanced", Value, "rate", translate("Transmission Rate"))
416                 s:taboption("advanced", Value, "mcast_rate", translate("Multicast Rate"))
417                 s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
418                 s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
419                 s:taboption("advanced", Value, "minrate", translate("Minimum Rate"))
420                 s:taboption("advanced", Value, "maxrate", translate("Maximum Rate"))
421                 s:taboption("advanced", Flag, "compression", translate("Compression"))
422
423                 s:taboption("advanced", Flag, "bursting", translate("Frame Bursting"))
424                 s:taboption("advanced", Flag, "turbo", translate("Turbo Mode"))
425                 s:taboption("advanced", Flag, "ff", translate("Fast Frames"))
426
427                 s:taboption("advanced", Flag, "wmm", translate("WMM Mode"))
428                 s:taboption("advanced", Flag, "xr", translate("XR Support"))
429                 s:taboption("advanced", Flag, "ar", translate("AR Support"))
430
431                 local swm = s:taboption("advanced", Flag, "sw_merge", translate("Disable HW-Beacon timer"))
432                 swm:depends({mode="adhoc"})
433
434                 local nos = s:taboption("advanced", Flag, "nosbeacon", translate("Disable HW-Beacon timer"))
435                 nos:depends({mode="sta"})
436                 nos:depends({mode="sta-wds"})
437
438                 local probereq = s:taboption("advanced", Flag, "probereq", translate("Do not send probe responses"))
439                 probereq.enabled  = "0"
440                 probereq.disabled = "1"
441         end
442
443
444         -------------------- Broadcom Interface ----------------------
445
446         if hwtype == "broadcom" then
447                 mode:value("wds", translate("WDS"))
448                 mode:value("monitor", translate("Monitor"))
449
450                 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
451                 hidden:depends({mode="ap"})
452                 hidden:depends({mode="adhoc"})
453                 hidden:depends({mode="wds"})
454
455                 isolate = s:taboption("advanced", Flag, "isolate", translate("Separate Clients"),
456                  translate("Prevents client-to-client communication"))
457                 isolate:depends({mode="ap"})
458
459                 s:taboption("advanced", Flag, "doth", "802.11h")
460                 s:taboption("advanced", Flag, "wmm", translate("WMM Mode"))
461
462                 bssid:depends({mode="wds"})
463                 bssid:depends({mode="adhoc"})
464         end
465
466
467         ----------------------- HostAP Interface ---------------------
468
469         if hwtype == "prism2" then
470                 mode:value("wds", translate("WDS"))
471                 mode:value("monitor", translate("Monitor"))
472
473                 hidden = s:taboption("general", Flag, "hidden", translate("Hide <abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
474                 hidden:depends({mode="ap"})
475                 hidden:depends({mode="adhoc"})
476                 hidden:depends({mode="wds"})
477
478                 bssid:depends({mode="sta"})
479
480                 mp = s:taboption("macfilter", ListValue, "macpolicy", translate("MAC-Address Filter"))
481                 mp:value("", translate("disable"))
482                 mp:value("deny", translate("Allow listed only"))
483                 mp:value("allow", translate("Allow all except listed"))
484                 ml = s:taboption("macfilter", DynamicList, "maclist", translate("MAC-List"))
485                 ml:depends({macpolicy="allow"})
486                 ml:depends({macpolicy="deny"})
487
488                 s:taboption("advanced", Value, "rate", translate("Transmission Rate"))
489                 s:taboption("advanced", Value, "frag", translate("Fragmentation Threshold"))
490                 s:taboption("advanced", Value, "rts", translate("RTS/CTS Threshold"))
491         end
492
493
494         ------------------- WiFI-Encryption -------------------
495
496         encr = s:taboption("encryption", ListValue, "encryption", translate("Encryption"))
497         encr.override_values = true
498         encr.override_depends = true
499         encr:depends({mode="ap"})
500         encr:depends({mode="sta"})
501         encr:depends({mode="adhoc"})
502         encr:depends({mode="ahdemo"})
503         encr:depends({mode="ap-wds"})
504         encr:depends({mode="sta-wds"})
505         encr:depends({mode="mesh"})
506
507         encr:value("none", "No Encryption")
508         encr:value("wep", "WEP", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
509
510         if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
511                 local supplicant = fs.access("/usr/sbin/wpa_supplicant")
512                 local hostapd = fs.access("/usr/sbin/hostapd")
513
514                 if hostapd and supplicant then
515                         encr:value("psk", "WPA-PSK")
516                         encr:value("psk2", "WPA2-PSK")
517                         encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode")
518                         encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"})
519                         encr:value("wpa2", "WPA2-EAP", {mode="ap"}, {mode="sta"})
520                 elseif hostapd and not supplicant then
521                         encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="ap-wds"}, {mode="adhoc"}, {mode="ahdemo"})
522                         encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="ap-wds"}, {mode="adhoc"}, {mode="ahdemo"})
523                         encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="ap"}, {mode="ap-wds"}, {mode="adhoc"}, {mode="ahdemo"})
524                         encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="ap-wds"})
525                         encr:value("wpa2", "WPA2-EAP", {mode="ap"}, {mode="ap-wds"})
526                         encr.description = translate(
527                                 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
528                                 "and ad-hoc mode) to be installed."
529                         )
530                 elseif not hostapd and supplicant then
531                         encr:value("psk", "WPA-PSK", {mode="sta"}, {mode="sta-wds"})
532                         encr:value("psk2", "WPA2-PSK", {mode="sta"}, {mode="sta-wds"})
533                         encr:value("psk-mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="sta"}, {mode="sta-wds"})
534                         encr:value("wpa", "WPA-EAP", {mode="sta"}, {mode="sta-wds"})
535                         encr:value("wpa2", "WPA2-EAP", {mode="sta"}, {mode="sta-wds"})
536                         encr.description = translate(
537                                 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
538                                 "and ad-hoc mode) to be installed."
539                         )
540                 else
541                         encr.description = translate(
542                                 "WPA-Encryption requires wpa_supplicant (for client mode) or hostapd (for AP " ..
543                                 "and ad-hoc mode) to be installed."
544                         )
545                 end
546         elseif hwtype == "broadcom" then
547                 encr:value("psk", "WPA-PSK")
548                 encr:value("psk2", "WPA2-PSK")
549                 encr:value("psk+psk2", "WPA-PSK/WPA2-PSK Mixed Mode")
550         end
551
552         encr:depends("mode", "ap")
553         encr:depends("mode", "sta")
554         encr:depends("mode", "ap-wds")
555         encr:depends("mode", "sta-wds")
556         encr:depends("mode", "wds")
557
558         server = s:taboption("encryption", Value, "server", translate("Radius-Server"))
559         server:depends({mode="ap", encryption="wpa"})
560         server:depends({mode="ap", encryption="wpa2"})
561         server:depends({mode="ap-wds", encryption="wpa"})
562         server:depends({mode="ap-wds", encryption="wpa2"})
563         server.rmempty = true
564
565         port = s:taboption("encryption", Value, "port", translate("Radius-Port"))
566         port:depends({mode="ap", encryption="wpa"})
567         port:depends({mode="ap", encryption="wpa2"})
568         port:depends({mode="ap-wds", encryption="wpa"})
569         port:depends({mode="ap-wds", encryption="wpa2"})
570         port.rmempty = true
571
572         key = s:taboption("encryption", Value, "key", translate("Key"))
573         key:depends("encryption", "wep")
574         key:depends("encryption", "psk")
575         key:depends("encryption", "psk2")
576         key:depends("encryption", "psk+psk2")
577         key:depends("encryption", "psk-mixed")
578         key:depends({mode="ap", encryption="wpa"})
579         key:depends({mode="ap", encryption="wpa2"})
580         key:depends({mode="ap-wds", encryption="wpa"})
581         key:depends({mode="ap-wds", encryption="wpa2"})
582         key.rmempty = true
583         key.password = true
584
585         if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
586                 nasid = s:taboption("encryption", Value, "nasid", translate("NAS ID"))
587                 nasid:depends({mode="ap", encryption="wpa"})
588                 nasid:depends({mode="ap", encryption="wpa2"})
589                 nasid:depends({mode="ap-wds", encryption="wpa"})
590                 nasid:depends({mode="ap-wds", encryption="wpa2"})
591                 nasid.rmempty = true
592
593                 eaptype = s:taboption("encryption", ListValue, "eap_type", translate("EAP-Method"))
594                 eaptype:value("TLS")
595                 eaptype:value("TTLS")
596                 eaptype:value("PEAP")
597                 eaptype:depends({mode="sta", encryption="wpa"})
598                 eaptype:depends({mode="sta", encryption="wpa2"})
599
600                 cacert = s:taboption("encryption", FileUpload, "ca_cert", translate("Path to CA-Certificate"))
601                 cacert:depends({mode="sta", encryption="wpa"})
602                 cacert:depends({mode="sta", encryption="wpa2"})
603
604                 privkey = s:taboption("encryption", FileUpload, "priv_key", translate("Path to Private Key"))
605                 privkey:depends({mode="sta", eap_type="TLS", encryption="wpa2"})
606                 privkey:depends({mode="sta", eap_type="TLS", encryption="wpa"})
607
608                 privkeypwd = s:taboption("encryption", Value, "priv_key_pwd", translate("Password of Private Key"))
609                 privkeypwd:depends({mode="sta", eap_type="TLS", encryption="wpa2"})
610                 privkeypwd:depends({mode="sta", eap_type="TLS", encryption="wpa"})
611
612
613                 auth = s:taboption("encryption", Value, "auth", translate("Authentication"))
614                 auth:value("PAP")
615                 auth:value("CHAP")
616                 auth:value("MSCHAP")
617                 auth:value("MSCHAPV2")
618                 auth:depends({mode="sta", eap_type="PEAP", encryption="wpa2"})
619                 auth:depends({mode="sta", eap_type="PEAP", encryption="wpa"})
620                 auth:depends({mode="sta", eap_type="TTLS", encryption="wpa2"})
621                 auth:depends({mode="sta", eap_type="TTLS", encryption="wpa"})
622
623
624                 identity = s:taboption("encryption", Value, "identity", translate("Identity"))
625                 identity:depends({mode="sta", eap_type="PEAP", encryption="wpa2"})
626                 identity:depends({mode="sta", eap_type="PEAP", encryption="wpa"})
627                 identity:depends({mode="sta", eap_type="TTLS", encryption="wpa2"})
628                 identity:depends({mode="sta", eap_type="TTLS", encryption="wpa"})
629
630                 password = s:taboption("encryption", Value, "password", translate("Password"))
631                 password:depends({mode="sta", eap_type="PEAP", encryption="wpa2"})
632                 password:depends({mode="sta", eap_type="PEAP", encryption="wpa"})
633                 password:depends({mode="sta", eap_type="TTLS", encryption="wpa2"})
634                 password:depends({mode="sta", eap_type="TTLS", encryption="wpa"})
635         end
636 end
637
638 return m