diff options
Diffstat (limited to 'modules/luci-base/luasrc/model/network.lua')
-rw-r--r-- | modules/luci-base/luasrc/model/network.lua | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/modules/luci-base/luasrc/model/network.lua b/modules/luci-base/luasrc/model/network.lua index 6119abd73..39ec8391e 100644 --- a/modules/luci-base/luasrc/model/network.lua +++ b/modules/luci-base/luasrc/model/network.lua @@ -1,7 +1,7 @@ --[[ 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. @@ -24,7 +24,6 @@ local tonumber, tostring, math = tonumber, tostring, math local require = require -local bus = require "ubus" local nxo = require "nixio" local nfs = require "nixio.fs" local ipc = require "luci.ip" @@ -47,7 +46,7 @@ protocol = utl.class() 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) @@ -138,7 +137,7 @@ function _wifi_state(key, val, field) 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 @@ -230,7 +229,6 @@ function init(cursor) _switch = { } _tunnel = { } - _ubus = bus.connect() _ubusnetcache = { } _ubusdevcache = { } _ubuswificache = { } @@ -637,10 +635,10 @@ end 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 @@ -655,10 +653,10 @@ end 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 @@ -722,8 +720,8 @@ end 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] @@ -1070,8 +1068,8 @@ end 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] |