Minor bugfixes
[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 require("luci.tools.webadmin")
15 arg[1] = arg[1] or ""
16
17 m = Map("wireless", translate("networks"), translate("a_w_networks1"))
18
19 s = m:section(NamedSection, arg[1], "wifi-device", translate("device") .. " " .. arg[1])
20 --s.addremove = true
21
22 en = s:option(Flag, "disabled", translate("enable"))
23 en.enabled = "0"
24 en.disabled = "1"
25
26 function en.cfgvalue(self, section)
27 return Flag.cfgvalue(self, section) or "0"
28 end
29
30 t = s:option(DummyValue, "type", translate("type"))
31
32 mode = s:option(ListValue, "mode", translate("mode"))
33 mode:value("", "standard")
34 mode:value("11b", "802.11b")
35 mode:value("11g", "802.11g")
36 mode:value("11a", "802.11a")
37 mode:value("11bg", "802.11b+g")
38 mode.rmempty = true
39
40 s:option(Value, "channel", translate("a_w_channel"))
41
42 s:option(Value, "txantenna", translate("a_w_txantenna")).optional = true
43
44 s:option(Value, "rxantenna", translate("a_w_rxantenna")).optional = true
45
46 s:option(Value, "distance", translate("distance"),
47 translate("a_w_distance1")).optional = true
48
49 s:option(Value, "diversity", translate("a_w_diversity")):depends("type", "atheros")
50
51 country = s:option(Value, "country", translate("a_w_countrycode"))
52 country.optional = true
53 country:depends("type", "broadcom")
54
55 maxassoc = s:option(Value, "maxassoc", translate("a_w_connlimit"))
56 maxassoc:depends("type", "broadcom")
57 maxassoc.optional = true
58
59
60
61 s = m:section(TypedSection, "wifi-iface", translate("interfaces"))
62 s.addremove = true
63 s.anonymous = true
64 s:depends("device", arg[1])
65 s.defaults.device = arg[1]
66
67 s:option(Value, "ssid", translate("a_w_netid")).maxlength = 32
68
69 network = s:option(Value, "network", translate("network"), translate("a_w_network1"))
70 network.rmempty = true
71 network:value("")
72 network.combobox_manual = translate("a_w_netmanual")
73 luci.tools.webadmin.cbi_add_networks(network)
74
75 function network.write(self, section, value)
76 if not luci.model.uci.get("network", value) then
77 m:chain("network")
78 luci.model.uci.set("network", value, "interface")
79 Value.write(self, section, value)
80 else
81 if luci.model.uci.get("network", value) == "interface" then
82 Value.write(self, section, value)
83 end
84 end
85 end
86
87 mode = s:option(ListValue, "mode", translate("mode"))
88 mode:value("ap", translate("a_w_ap"))
89 mode:value("adhoc", translate("a_w_adhoc"))
90 mode:value("ahdemo", translate("a_w_ahdemo"))
91 mode:value("sta", translate("a_w_client"))
92 mode:value("wds", translate("a_w_wds"))
93 mode:value("monitor", translate("a_w_monitor"))
94
95 s:option(Value, "bssid", "BSSID").optional = true
96
97 s:option(Value, "txpower", translate("a_w_txpwr"), "dbm").rmempty = true
98
99 s:option(Flag, "frameburst", translate("a_w_brcmburst")).optional = true
100 s:option(Flag, "bursting", translate("a_w_athburst")).optional = true
101
102
103 encr = s:option(ListValue, "encryption", translate("encryption"))
104 encr:value("none", "keine")
105 encr:value("wep", "WEP")
106 encr:value("PSK", "WPA-PSK")
107 encr:value("WPA", "WPA-EAP", {mode="ap"}, {mode="sta"})
108 encr:value("PSK2", "WPA2-PSK")
109 encr:value("WPA2", "WPA2-EAP", {mode="ap"}, {mode="sta"})
110 encr:depends("mode", "ap")
111 encr:depends("mode", "sta")
112 encr:depends("mode", "wds")
113
114 server = s:option(Value, "server", translate("a_w_radiussrv"))
115 server:depends({mode="ap", encryption="WPA"})
116 server:depends({mode="ap", encryption="WPA2"})
117 server.rmempty = true
118
119 port = s:option(Value, "port", translate("a_w_radiusport"))
120 port:depends({mode="ap", encryption="WPA"})
121 port:depends({mode="ap", encryption="WPA2"})
122 port.rmempty = true
123
124 key = s:option(Value, "key", translate("key"))
125 key:depends("encryption", "wep")
126 key:depends("encryption", "PSK")
127 key:depends({mode="ap", encryption="WPA"})
128 key:depends("encryption", "PSK2")
129 key:depends({mode="ap", encryption="WPA2"})
130 key.rmempty = true
131
132 nasid = s:option(Value, "nasid", translate("a_w_nasid"))
133 nasid:depends({mode="ap", encryption="WPA"})
134 nasid:depends({mode="ap", encryption="WPA2"})
135 nasid.rmempty = true
136
137 eaptype = s:option(ListValue, "eap_type", translate("a_w_eaptype"))
138 eaptype:value("TLS")
139 eaptype:value("PEAP")
140 eaptype:depends({mode="sta", encryption="WPA"})
141 eaptype:depends({mode="sta", encryption="WPA2"})
142
143 cacert = s:option(Value, "ca_cert", translate("a_w_cacert"))
144 cacert:depends({mode="sta", encryption="WPA"})
145 cacert:depends({mode="sta", encryption="WPA2"})
146
147 privkey = s:option(Value, "priv_key", translate("a_w_tlsprivkey"))
148 privkey:depends({mode="sta", eap_type="TLS", encryption="WPA2"})
149 privkey:depends({mode="sta", eap_type="TLS", encryption="WPA"})
150
151 privkeypwd = s:option(Value, "priv_key_pwd", translate("a_w_tlsprivkeypwd"))
152 privkeypwd:depends({mode="sta", eap_type="TLS", encryption="WPA2"})
153 privkeypwd:depends({mode="sta", eap_type="TLS", encryption="WPA"})
154
155
156 auth = s:option(Value, "auth", translate("a_w_peapauth"))
157 auth:depends({mode="sta", eap_type="PEAP", encryption="WPA2"})
158 auth:depends({mode="sta", eap_type="PEAP", encryption="WPA"})
159
160 identity = s:option(Value, "identity", translate("a_w_peapidentity"))
161 identity:depends({mode="sta", eap_type="PEAP", encryption="WPA2"})
162 identity:depends({mode="sta", eap_type="PEAP", encryption="WPA"})
163
164 password = s:option(Value, "password", translate("a_w_peappassword"))
165 password:depends({mode="sta", eap_type="PEAP", encryption="WPA2"})
166 password:depends({mode="sta", eap_type="PEAP", encryption="WPA"})
167
168
169
170
171 s:option(Flag, "isolate", translate("a_w_apisolation"), translate("a_w_apisolation1")).optional = true
172
173 s:option(Flag, "hidden", translate("a_w_hideessid")).optional = true
174
175
176
177 return m