46f05a3afdca697974198ca10b88b40cdc8c72fe
[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 ch = s:option(Value, "channel", translate("a_w_channel"))
41 for i=1, 14 do
42         ch:value(i, i .. " (2.4 GHz)")
43 end
44 for i=36, 64, 4 do
45         ch:value(i, i .. " (5 GHz)")
46 end
47 for i=100, 140, 4 do
48         ch:value(i, i .. " (5 GHz)")
49 end
50 ch:value(147, 147 .. " (5 GHz)")
51 ch:value(151, 151 .. " (5 GHz)")
52 ch:value(155, 155 .. " (5 GHz)")
53 ch:value(167, 167 .. " (5 GHz)")
54
55 s:option(Value, "txantenna", translate("a_w_txantenna")).optional = true
56
57 s:option(Value, "rxantenna", translate("a_w_rxantenna")).optional = true
58
59 s:option(Value, "distance", translate("distance"),
60         translate("a_w_distance1")).optional = true
61
62 s:option(Value, "diversity", translate("a_w_diversity")):depends("type", "atheros")
63         
64 country = s:option(Value, "country", translate("a_w_countrycode"))
65 country.optional = true
66 country:depends("type", "broadcom")
67
68 maxassoc = s:option(Value, "maxassoc", translate("a_w_connlimit"))
69 maxassoc:depends("type", "broadcom")
70 maxassoc.optional = true
71
72
73
74 s = m:section(TypedSection, "wifi-iface", translate("interfaces"))
75 s.addremove = true
76 s.anonymous = true
77 s:depends("device", arg[1])
78 s.defaults.device = arg[1]
79
80 s:option(Value, "ssid", translate("a_w_netid")).maxlength = 32
81
82 network = s:option(Value, "network", translate("network"), translate("a_w_network1"))
83 network.rmempty = true
84 network:value("")
85 network.combobox_manual = translate("a_w_netmanual")
86 luci.tools.webadmin.cbi_add_networks(network)
87
88 function network.write(self, section, value)    
89         if not m:uci.get("network", value) then 
90                 m:chain("network")
91                 m.uci:set("network", value, "interface")
92                 Value.write(self, section, value)
93         else
94                 if m.uci:get("network", value) == "interface" then
95                         Value.write(self, section, value)
96                 end
97         end
98 end
99
100 mode = s:option(ListValue, "mode", translate("mode"))
101 mode:value("ap", translate("a_w_ap"))
102 mode:value("adhoc", translate("a_w_adhoc"))
103 mode:value("ahdemo", translate("a_w_ahdemo"))
104 mode:value("sta", translate("a_w_client"))
105 mode:value("wds", translate("a_w_wds"))
106 mode:value("monitor", translate("a_w_monitor"))
107
108 s:option(Value, "bssid", "BSSID").optional = true
109
110 s:option(Value, "txpower", translate("a_w_txpwr"), "dbm").rmempty = true
111
112 s:option(Flag, "frameburst", translate("a_w_brcmburst")).optional = true
113 s:option(Flag, "bursting", translate("a_w_athburst")).optional = true
114
115
116 encr = s:option(ListValue, "encryption", translate("encryption"))
117 encr:value("none", "keine")
118 encr:value("wep", "WEP")
119 encr:value("PSK", "WPA-PSK")
120 encr:value("WPA", "WPA-EAP", {mode="ap"}, {mode="sta"})
121 encr:value("PSK2", "WPA2-PSK")
122 encr:value("WPA2", "WPA2-EAP", {mode="ap"}, {mode="sta"})
123 encr:depends("mode", "ap")
124 encr:depends("mode", "sta")
125 encr:depends("mode", "wds")
126
127 server = s:option(Value, "server", translate("a_w_radiussrv"))
128 server:depends({mode="ap", encryption="WPA"})
129 server:depends({mode="ap", encryption="WPA2"})
130 server.rmempty = true
131
132 port = s:option(Value, "port", translate("a_w_radiusport"))
133 port:depends({mode="ap", encryption="WPA"})
134 port:depends({mode="ap", encryption="WPA2"})
135 port.rmempty = true
136
137 key = s:option(Value, "key", translate("key"))
138 key:depends("encryption", "wep")
139 key:depends("encryption", "PSK")
140 key:depends({mode="ap", encryption="WPA"})
141 key:depends("encryption", "PSK2")
142 key:depends({mode="ap", encryption="WPA2"})
143 key.rmempty = true
144
145 nasid = s:option(Value, "nasid", translate("a_w_nasid"))
146 nasid:depends({mode="ap", encryption="WPA"})
147 nasid:depends({mode="ap", encryption="WPA2"})
148 nasid.rmempty = true
149
150 eaptype = s:option(ListValue, "eap_type", translate("a_w_eaptype"))
151 eaptype:value("TLS")
152 eaptype:value("PEAP")
153 eaptype:depends({mode="sta", encryption="WPA"})
154 eaptype:depends({mode="sta", encryption="WPA2"})
155
156 cacert = s:option(Value, "ca_cert", translate("a_w_cacert"))
157 cacert:depends({mode="sta", encryption="WPA"})
158 cacert:depends({mode="sta", encryption="WPA2"})
159
160 privkey = s:option(Value, "priv_key", translate("a_w_tlsprivkey"))
161 privkey:depends({mode="sta", eap_type="TLS", encryption="WPA2"})
162 privkey:depends({mode="sta", eap_type="TLS", encryption="WPA"})
163
164 privkeypwd = s:option(Value, "priv_key_pwd", translate("a_w_tlsprivkeypwd"))
165 privkeypwd:depends({mode="sta", eap_type="TLS", encryption="WPA2"})
166 privkeypwd:depends({mode="sta", eap_type="TLS", encryption="WPA"})
167
168
169 auth = s:option(Value, "auth", translate("a_w_peapauth"))
170 auth:depends({mode="sta", eap_type="PEAP", encryption="WPA2"})
171 auth:depends({mode="sta", eap_type="PEAP", encryption="WPA"})
172
173 identity = s:option(Value, "identity", translate("a_w_peapidentity"))
174 identity:depends({mode="sta", eap_type="PEAP", encryption="WPA2"})
175 identity:depends({mode="sta", eap_type="PEAP", encryption="WPA"})
176
177 password = s:option(Value, "password", translate("a_w_peappassword"))
178 password:depends({mode="sta", eap_type="PEAP", encryption="WPA2"})
179 password:depends({mode="sta", eap_type="PEAP", encryption="WPA"})
180
181
182
183
184 s:option(Flag, "isolate", translate("a_w_apisolation"), translate("a_w_apisolation1")).optional = true
185
186 s:option(Flag, "hidden", translate("a_w_hideessid")).optional = true
187
188
189
190 return m