summaryrefslogtreecommitdiffhomepage
path: root/libs/sys/luasrc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-08-09 02:50:20 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-08-09 02:50:20 +0000
commit398c125336f035a9a5a23b476f597b2e22fb672a (patch)
tree60a690dd4b70a16ff2d94a6b0393164ff1fedaba /libs/sys/luasrc
parentd1fb1f9d69c865956d1a92aba6d69712ea24c741 (diff)
libs/sys: implement luci.sys.wifi.getiwinfo() oop interface
Diffstat (limited to 'libs/sys/luasrc')
-rw-r--r--libs/sys/luasrc/sys.lua30
1 files changed, 23 insertions, 7 deletions
diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua
index d57077026..1708a2735 100644
--- a/libs/sys/luasrc/sys.lua
+++ b/libs/sys/luasrc/sys.lua
@@ -25,18 +25,19 @@ limitations under the License.
]]--
-local io = require "io"
-local os = require "os"
-local table = require "table"
-local nixio = require "nixio"
-local fs = require "nixio.fs"
+local io = require "io"
+local os = require "os"
+local table = require "table"
+local nixio = require "nixio"
+local fs = require "nixio.fs"
+local iwinfo = require "iwinfo"
local luci = {}
luci.util = require "luci.util"
luci.ip = require "luci.ip"
-local tonumber, ipairs, pairs, pcall, type, next =
- tonumber, ipairs, pairs, pcall, type, next
+local tonumber, ipairs, pairs, pcall, type, next, setmetatable =
+ tonumber, ipairs, pairs, pcall, type, next, setmetatable
--- LuCI Linux and POSIX system utilities.
@@ -617,6 +618,21 @@ end
-- @name luci.sys.wifi
wifi = {}
+--- Get wireless information for given interface.
+-- @param ifname String containing the interface name
+-- @return A wrapped iwinfo object instance
+function wifi.getiwinfo(ifname)
+ local t = iwinfo.type(ifname)
+ if t then
+ local x = iwinfo[t]
+ return setmetatable({}, {
+ __index = function(t, k)
+ if x[k] then return x[k](ifname) end
+ end
+ })
+ end
+end
+
--- Get iwconfig output for all wireless devices.
-- @return Table of tables containing the iwconfing output for each wifi device
function wifi.getiwconfig()