AP configuration
[project/luci.git] / modules / niu / luasrc / model / cbi / niu / wireless / apdevice.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2009 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 iwinfo = require "iwinfo"
16 local cursor = require "luci.model.uci".inst
17 cursor:unload("wireless")
18
19 m = Map("wireless", "Configure Private Access Point")
20 s = m:section(NamedSection, "ap", "interface", "Wireless Radio Device",
21 "Select the wireless radio device that should be used to run the access"..
22 " point. Note that wireless radios will not show up here if you already use"..
23 " them for connecting to the Internet and are not capable of being used as"..
24 " an access point in parallel.")
25 s.anonymous = true
26 s.addremove = false
27
28 l = s:option(ListValue, "device", "Device providing Access Point")
29
30 local used = {}
31 cursor:foreach("wireless", "wifi-iface", function(s)
32         if s[".name"] ~= "ap" and s._niu == 1 then
33                 used[s.device] = 1
34         end
35 end)
36
37 for k in pairs(used) do
38         local t = iwinfo.type(k)
39         if t and iwinfo[t] then
40                 used[k] = (iwinfo[t].mbssid_support() < 1)
41         end
42 end
43
44 cursor:foreach("wireless", "wifi-device", function(s)
45         if not used[s[".name"]] then
46                 l:value(s[".name"], "Radio %s" % s[".name"])
47         end
48 end)
49 l:value("none", "Disable Private Access Point")
50
51 return m