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