--[[
LuCI - Network model
-Copyright 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
+Copyright 2009-2015 Jo-Philipp Wich <jow@openwrt.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
local require = require
-local bus = require "ubus"
local nxo = require "nixio"
local nfs = require "nixio.fs"
local ipc = require "luci.ip"
local _protocols = { }
local _interfaces, _bridge, _switch, _tunnel
-local _ubus, _ubusnetcache, _ubusdevcache, _ubuswificache
+local _ubusnetcache, _ubusdevcache, _ubuswificache
local _uci_real, _uci_state
function _filter(c, s, o, r)
local radio, radiostate, ifc, ifcstate
if not next(_ubuswificache) then
- _ubuswificache = _ubus:call("network.wireless", "status", {}) or {}
+ _ubuswificache = utl.ubus("network.wireless", "status", {}) or {}
-- workaround extended section format
for radio, radiostate in pairs(_ubuswificache) do
_switch = { }
_tunnel = { }
- _ubus = bus.connect()
_ubusnetcache = { }
_ubusdevcache = { }
_ubuswificache = { }
function get_status_by_route(self, addr, mask)
local _, object
- for _, object in ipairs(_ubus:objects()) do
+ for _, object in ipairs(utl.ubus()) do
local net = object:match("^network%.interface%.(.+)")
if net then
- local s = _ubus:call(object, "status", {})
+ local s = utl.ubus(object, "status", {})
if s and s.route then
local rt
for _, rt in ipairs(s.route) do
function get_status_by_address(self, addr)
local _, object
- for _, object in ipairs(_ubus:objects()) do
+ for _, object in ipairs(utl.ubus()) do
local net = object:match("^network%.interface%.(.+)")
if net then
- local s = _ubus:call(object, "status", {})
+ local s = utl.ubus(object, "status", {})
if s and s['ipv4-address'] then
local a
for _, a in ipairs(s['ipv4-address']) do
function protocol._ubus(self, field)
if not _ubusnetcache[self.sid] then
- _ubusnetcache[self.sid] = _ubus:call("network.interface.%s" % self.sid,
- "status", { })
+ _ubusnetcache[self.sid] = utl.ubus("network.interface.%s" % self.sid,
+ "status", { })
end
if _ubusnetcache[self.sid] and field then
return _ubusnetcache[self.sid][field]
function interface._ubus(self, field)
if not _ubusdevcache[self.ifname] then
- _ubusdevcache[self.ifname] = _ubus:call("network.device", "status",
- { name = self.ifname })
+ _ubusdevcache[self.ifname] = utl.ubus("network.device", "status",
+ { name = self.ifname })
end
if _ubusdevcache[self.ifname] and field then
return _ubusdevcache[self.ifname][field]