root/luci/trunk/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua @ 4587

Revision 4587, 14.1 KB (checked in by jow, 4 years ago)

modules/admin-full: fix madwifi turbo modes

  • Property svn:keywords set to Id
Line 
1--[[
2LuCI - Lua Configuration Interface
3
4Copyright 2008 Steven Barth <steven@midlink.org>
5
6Licensed under the Apache License, Version 2.0 (the "License");
7you may not use this file except in compliance with the License.
8You may obtain a copy of the License at
9
10    http://www.apache.org/licenses/LICENSE-2.0
11
12$Id$
13]]--
14require("luci.tools.webadmin")
15arg[1] = arg[1] or ""
16
17m = Map("wireless", translate("networks"), translate("a_w_networks1"))
18
19s = m:section(NamedSection, arg[1], "wifi-device", translate("device") .. " " .. arg[1])
20s.addremove = false
21
22back = s:option(DummyValue, "_overview", translate("overview"))
23back.value = ""
24back.titleref = luci.dispatcher.build_url("admin", "network", "wireless")
25
26
27en = s:option(Flag, "disabled", translate("enable"))
28en.enabled = "0"
29en.disabled = "1"
30en.rmempty = false
31
32function en.cfgvalue(self, section)
33    return Flag.cfgvalue(self, section) or "0"
34end
35
36s:option(DummyValue, "type", translate("type"))
37local hwtype = m:get(arg[1], "type")
38-- NanoFoo
39local nsantenna = m:get(arg[1], "antenna")
40
41ch = s:option(Value, "channel", translate("a_w_channel"))
42ch:value("auto", translate("wifi_auto"))
43for c, f in luci.util.kspairs(luci.sys.wifi.channels()) do
44    ch:value(c, "%i (%.3f GHz)" %{ c, f })
45end
46
47
48------------------- MAC80211 Device ------------------
49
50if hwtype == "mac80211" then
51    s:option(Value, "txpower", translate("a_w_txpwr"), "dBm").rmempty = true
52end
53
54
55------------------- Madwifi Device ------------------
56
57if hwtype == "atheros" then
58    s:option(Value, "txpower", translate("a_w_txpwr"), "dBm").rmempty = true
59
60    mode = s:option(ListValue, "mode", translate("mode"))
61    mode:value("", translate("wifi_auto"))
62    mode:value("11b", "802.11b")
63    mode:value("11g", "802.11g")
64    mode:value("11a", "802.11a")
65    mode:value("11bg", "802.11b+g")
66    mode:value("11gst", "802.11g + Turbo")
67    mode:value("11ast", "802.11a + Turbo")
68    mode:value("fh", translate("wifi_fh"))
69
70    s:option(Flag, "diversity", translate("wifi_diversity")).rmempty = false
71
72    if not nsantenna then
73        s:option(Value, "txantenna", translate("wifi_txantenna")).optional = true
74        s:option(Value, "rxantenna", translate("wifi_rxantenna")).optional = true
75    else -- NanoFoo
76        local ant = s:option(ListValue, "antenna", translate("wifi_txantenna"))
77        ant:value("auto")
78        ant:value("vertical")
79        ant:value("horizontal")
80        ant:value("external")
81    end
82    s:option(Value, "distance", translate("wifi_distance"),
83        translate("wifi_distance_desc")).optional = true
84    s:option(Value, "regdomain", translate("wifi_regdomain")).optional = true
85    s:option(Value, "country", translate("wifi_country")).optional = true
86    s:option(Flag, "outdoor", translate("wifi_outdoor")).optional = true
87
88    --s:option(Flag, "nosbeacon", translate("wifi_nosbeacon")).optional = true
89end
90
91
92
93------------------- Broadcom Device ------------------
94
95if hwtype == "broadcom" then
96    s:option(Value, "txpower", translate("a_w_txpwr"), "dBm").rmempty = true
97
98    mp = s:option(ListValue, "macfilter", translate("wifi_macpolicy"))
99    mp.optional = true
100    mp:value("")
101    mp:value("allow", translate("wifi_whitelist"))
102    mp:value("deny", translate("wifi_blacklist"))
103    ml = s:option(DynamicList, "maclist", translate("wifi_maclist"))
104    ml:depends({macfilter="allow"})
105    ml:depends({macfilter="deny"})
106
107    s:option(Value, "txantenna", translate("wifi_txantenna")).optional = true
108    s:option(Value, "rxantenna", translate("wifi_rxantenna")).optional = true
109
110    s:option(Flag, "frameburst", translate("wifi_bursting")).optional = true
111
112    s:option(Value, "distance", translate("wifi_distance")).optional = true
113    --s:option(Value, "slottime", translate("wifi_slottime")).optional = true
114
115    s:option(Value, "country", translate("wifi_country")).optional = true
116    s:option(Value, "maxassoc", translate("wifi_maxassoc")).optional = true
117end
118
119
120--------------------- HostAP Device ---------------------
121
122if hwtype == "prism2" then
123    s:option(Value, "txpower", translate("a_w_txpwr"), "att units").rmempty = true
124
125    s:option(Value, "txantenna", translate("wifi_txantenna")).optional = true
126    s:option(Value, "rxantenna", translate("wifi_rxantenna")).optional = true
127end
128
129
130----------------------- Interface -----------------------
131
132s = m:section(TypedSection, "wifi-iface", translate("interfaces"))
133s.addremove = true
134s.anonymous = true
135s:depends("device", arg[1])
136s.defaults.device = arg[1]
137
138s:option(Value, "ssid", translate("wifi_essid"))
139
140network = s:option(Value, "network", translate("network"), translate("a_w_network1"))
141network.rmempty = true
142network:value("")
143network.combobox_manual = translate("a_w_netmanual")
144luci.tools.webadmin.cbi_add_networks(network)
145
146function network.write(self, section, value)
147    if not m.uci:get("network", value) then
148        -- avoid "value not defined in enum" because network is not known yet
149        s.override_scheme = true
150
151        m:chain("network")
152        m.uci:set("network", value, "interface")
153        Value.write(self, section, value)
154    else
155        if m.uci:get("network", value) == "interface" then
156            Value.write(self, section, value)
157        end
158    end
159end
160
161
162mode = s:option(ListValue, "mode", translate("mode"))
163mode.override_values = true
164mode:value("ap", translate("a_w_ap"))
165mode:value("adhoc", translate("a_w_adhoc"))
166mode:value("sta", translate("a_w_client"))
167
168bssid = s:option(Value, "bssid", translate("wifi_bssid"))
169
170
171-------------------- MAC80211 Interface ----------------------
172
173if hwtype == "mac80211" then
174    if luci.fs.mtime("/usr/sbin/iw") then
175        mode:value("mesh", "802.11s")
176    end
177
178    mode:value("ahdemo", translate("a_w_ahdemo"))
179    mode:value("monitor", translate("a_w_monitor"))
180    bssid:depends({mode="adhoc"})
181
182    s:option(Value, "frag", translate("wifi_frag")).optional = true
183    s:option(Value, "rts", translate("wifi_rts")).optional = true
184end
185
186
187
188-------------------- Madwifi Interface ----------------------
189
190if hwtype == "atheros" then
191    mode:value("ahdemo", translate("a_w_ahdemo"))
192    mode:value("monitor", translate("a_w_monitor"))
193
194    bssid:depends({mode="adhoc"})
195    bssid:depends({mode="ahdemo"})
196
197    wds = s:option(Flag, "wds", translate("a_w_wds"))
198    wds:depends({mode="ap"})
199    wds:depends({mode="sta"})
200    wds.rmempty = true
201    wdssep = s:option(Flag, "wdssep", translate("wifi_wdssep"))
202    wdssep:depends({mode="ap", wds="1"})
203    wdssep.optional = true
204
205    s:option(Flag, "doth", "802.11h").optional = true
206    hidden = s:option(Flag, "hidden", translate("wifi_hidden"))
207    hidden:depends({mode="ap"})
208    hidden:depends({mode="adhoc"})
209    hidden:depends({mode="wds"})
210    hidden.optional = true
211    isolate = s:option(Flag, "isolate", translate("wifi_isolate"),
212     translate("wifi_isolate_desc"))
213    isolate:depends({mode="ap"})
214    isolate.optional = true
215    s:option(Flag, "bgscan", translate("wifi_bgscan")).optional = true
216
217    mp = s:option(ListValue, "macpolicy", translate("wifi_macpolicy"))
218    mp.optional = true
219    mp:value("")
220    mp:value("deny", translate("wifi_whitelist"))
221    mp:value("allow", translate("wifi_blacklist"))
222    ml = s:option(DynamicList, "maclist", translate("wifi_maclist"))
223    ml:depends({macpolicy="allow"})
224    ml:depends({macpolicy="deny"})
225
226    s:option(Value, "rate", translate("wifi_rate")).optional = true
227    s:option(Value, "mcast_rate", translate("wifi_mcast_rate")).optional = true
228    s:option(Value, "frag", translate("wifi_frag")).optional = true
229    s:option(Value, "rts", translate("wifi_rts")).optional = true
230    s:option(Value, "minrate", translate("wifi_minrate")).optional = true
231    s:option(Value, "maxrate", translate("wifi_maxrate")).optional = true
232    s:option(Flag, "compression", translate("wifi_compression")).optional = true
233
234    s:option(Flag, "bursting", translate("wifi_bursting")).optional = true
235    s:option(Flag, "turbo", translate("wifi_turbo")).optional = true
236    s:option(Flag, "ff", translate("wifi_ff")).optional = true
237
238    s:option(Flag, "wmm", translate("wifi_wmm")).optional = true
239    s:option(Flag, "xr", translate("wifi_xr")).optional = true
240    s:option(Flag, "ar", translate("wifi_ar")).optional = true
241
242    local swm = s:option(Flag, "sw_merge", translate("wifi_nosbeacon"))
243    swm:depends({mode="adhoc"})
244    swm.optional = true
245
246    local nos = s:option(Flag, "nosbeacon", translate("wifi_nosbeacon"))
247    nos:depends({mode="sta"})
248    nos.optional = true
249
250    local probereq = s:option(Flag, "probereq", translate("wifi_noprobereq"))
251    probereq.optional = true
252    probereq.enabled  = "0"
253    probereq.disabled = "1"
254end
255
256
257-------------------- Broadcom Interface ----------------------
258
259if hwtype == "broadcom" then
260    mode:value("wds", translate("a_w_wds"))
261    mode:value("monitor", translate("a_w_monitor"))
262
263    hidden = s:option(Flag, "hidden", translate("wifi_hidden"))
264    hidden:depends({mode="ap"})
265    hidden:depends({mode="adhoc"})
266    hidden:depends({mode="wds"})
267    hidden.optional = true
268
269    isolate = s:option(Flag, "isolate", translate("wifi_isolate"),
270     translate("wifi_isolate_desc"))
271    isolate:depends({mode="ap"})
272    isolate.optional = true
273
274    bssid:depends({mode="wds"})
275    bssid:depends({mode="adhoc"})
276end
277
278
279----------------------- HostAP Interface ---------------------
280
281if hwtype == "prism2" then
282    mode:value("wds", translate("a_w_wds"))
283    mode:value("monitor", translate("a_w_monitor"))
284
285    hidden = s:option(Flag, "hidden", translate("wifi_hidden"))
286    hidden:depends({mode="ap"})
287    hidden:depends({mode="adhoc"})
288    hidden:depends({mode="wds"})
289    hidden.optional = true
290
291    bssid:depends({mode="sta"})
292
293    mp = s:option(ListValue, "macpolicy", translate("wifi_macpolicy"))
294    mp.optional = true
295    mp:value("")
296    mp:value("deny", translate("wifi_whitelist"))
297    mp:value("allow", translate("wifi_blacklist"))
298    ml = s:option(DynamicList, "maclist", translate("wifi_maclist"))
299    ml:depends({macpolicy="allow"})
300    ml:depends({macpolicy="deny"})
301
302    s:option(Value, "rate", translate("wifi_rate")).optional = true
303    s:option(Value, "frag", translate("wifi_frag")).optional = true
304    s:option(Value, "rts", translate("wifi_rts")).optional = true
305end
306
307
308------------------- WiFI-Encryption -------------------
309
310encr = s:option(ListValue, "encryption", translate("encryption"))
311encr.override_values = true
312encr:depends({mode="ap"})
313encr:depends({mode="sta"})
314encr:depends({mode="adhoc"})
315encr:depends({mode="ahdemo"})
316encr:depends({mode="wds"})
317encr:depends({mode="mesh"})
318
319encr:value("none", "No Encryption")
320encr:value("wep", "WEP")
321
322if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
323    local supplicant = luci.fs.mtime("/usr/sbin/wpa_supplicant")
324    local hostapd = luci.fs.mtime("/usr/sbin/hostapd")
325
326    if hostapd and supplicant then
327        encr:value("psk", "WPA-PSK")
328        encr:value("psk2", "WPA2-PSK")
329        encr:value("mixed", "WPA-PSK/WPA2-PSK Mixed Mode")
330        encr:value("wpa", "WPA-EAP", {mode="ap"}, {mode="sta"})
331        encr:value("wpa2", "WPA2-EAP", {mode="ap"}, {mode="sta"})
332    elseif hostapd and not supplicant then
333        encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="adhoc"}, {mode="ahdemo"})
334        encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="adhoc"}, {mode="ahdemo"})
335        encr:value("mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="ap"}, {mode="adhoc"}, {mode="ahdemo"})
336        encr:value("wpa", "WPA-EAP", {mode="ap"})
337        encr:value("wpa2", "WPA2-EAP", {mode="ap"})
338        encr.description = translate("wifi_wpareq")
339    elseif not hostapd and supplicant then
340        encr:value("psk", "WPA-PSK", {mode="sta"})
341        encr:value("psk2", "WPA2-PSK", {mode="sta"})
342        encr:value("mixed", "WPA-PSK/WPA2-PSK Mixed Mode", {mode="sta"})
343        encr:value("wpa", "WPA-EAP", {mode="sta"})
344        encr:value("wpa2", "WPA2-EAP", {mode="sta"})
345        encr.description = translate("wifi_wpareq")
346    else
347        encr.description = translate("wifi_wpareq")
348    end
349elseif hwtype == "broadcom" then
350    encr:value("psk", "WPA-PSK")
351    encr:value("psk2", "WPA2-PSK")
352    encr:value("psk+psk2", "WPA-PSK/WPA2-PSK Mixed Mode")
353end
354
355encr:depends("mode", "ap")
356encr:depends("mode", "sta")
357encr:depends("mode", "wds")
358
359server = s:option(Value, "server", translate("a_w_radiussrv"))
360server:depends({mode="ap", encryption="wpa"})
361server:depends({mode="ap", encryption="wpa2"})
362server.rmempty = true
363
364port = s:option(Value, "port", translate("a_w_radiusport"))
365port:depends({mode="ap", encryption="wpa"})
366port:depends({mode="ap", encryption="wpa2"})
367port.rmempty = true
368
369key = s:option(Value, "key", translate("key"))
370key:depends("encryption", "wep")
371key:depends("encryption", "psk")
372key:depends({mode="ap", encryption="wpa"})
373key:depends("encryption", "psk2")
374key:depends({mode="ap", encryption="wpa2"})
375key.rmempty = true
376
377if hwtype == "atheros" or hwtype == "mac80211" or hwtype == "prism2" then
378    nasid = s:option(Value, "nasid", translate("a_w_nasid"))
379    nasid:depends({mode="ap", encryption="wpa"})
380    nasid:depends({mode="ap", encryption="wpa2"})
381    nasid.rmempty = true
382
383    eaptype = s:option(ListValue, "eap_type", translate("a_w_eaptype"))
384    eaptype:value("TLS")
385    eaptype:value("TTLS")
386    eaptype:value("PEAP")
387    eaptype:depends({mode="sta", encryption="wpa"})
388    eaptype:depends({mode="sta", encryption="wpa2"})
389
390    cacert = s:option(FileUpload, "ca_cert", translate("a_w_cacert"))
391    cacert:depends({mode="sta", encryption="wpa"})
392    cacert:depends({mode="sta", encryption="wpa2"})
393
394    privkey = s:option(FileUpload, "priv_key", translate("a_w_tlsprivkey"))
395    privkey:depends({mode="sta", eap_type="TLS", encryption="wpa2"})
396    privkey:depends({mode="sta", eap_type="TLS", encryption="wpa"})
397
398    privkeypwd = s:option(Value, "priv_key_pwd", translate("a_w_tlsprivkeypwd"))
399    privkeypwd:depends({mode="sta", eap_type="TLS", encryption="wpa2"})
400    privkeypwd:depends({mode="sta", eap_type="TLS", encryption="wpa"})
401
402
403    auth = s:option(Value, "auth", translate("a_w_peapauth"))
404    auth:value("PAP")
405    auth:value("CHAP")
406    auth:value("MSCHAP")
407    auth:value("MSCHAPV2")
408    auth:depends({mode="sta", eap_type="PEAP", encryption="wpa2"})
409    auth:depends({mode="sta", eap_type="PEAP", encryption="wpa"})
410    auth:depends({mode="sta", eap_type="TTLS", encryption="wpa2"})
411    auth:depends({mode="sta", eap_type="TTLS", encryption="wpa"})
412
413
414    identity = s:option(Value, "identity", translate("a_w_peapidentity"))
415    identity:depends({mode="sta", eap_type="PEAP", encryption="wpa2"})
416    identity:depends({mode="sta", eap_type="PEAP", encryption="wpa"})
417    identity:depends({mode="sta", eap_type="TTLS", encryption="wpa2"})
418    identity:depends({mode="sta", eap_type="TTLS", encryption="wpa"})
419
420    password = s:option(Value, "password", translate("a_w_peappassword"))
421    password:depends({mode="sta", eap_type="PEAP", encryption="wpa2"})
422    password:depends({mode="sta", eap_type="PEAP", encryption="wpa"})
423    password:depends({mode="sta", eap_type="TTLS", encryption="wpa2"})
424    password:depends({mode="sta", eap_type="TTLS", encryption="wpa"})
425end
426
427
428return m
Note: See TracBrowser for help on using the browser.