end
end
+function _strlist(x)
+ if x == nil then
+ x = ""
+ elseif type(x) == "table" then
+ x = table.concat(x, " ")
+ end
+
+ return x:gmatch("%S+")
+end
+
function _get(c, s, o)
return uci_r:get(c, s, o)
end
function init(cursor)
- uci_r = cursor or uci.cursor()
+ uci_r = cursor or uci_r or uci.cursor()
uci_s = uci_r:substate()
ifs = { }
ifaces = { interface(ifn) }
else
local nfs = { }
- for ifn in self:_get("ifname"):gmatch("%S+") do
+ for ifn in _strlist(self:get("ifname")) do
ifn = ifn:match("[^:]+")
nfs[ifn] = interface(ifn)
end
ifn = self:proto() .. "-" .. self.sid
return ifname == ifn
else
- for ifn in self:_get("ifname"):gmatch("%S+") do
+ for ifn in _strlist(self:get("ifname")) do
ifn = ifn:match("[^:]+")
if ifn == ifname then
return true
end
function interface.mac(self)
- return self.dev and self.dev or "00:00:00:00:00:00"
+ return self.dev and self.dev.macaddr or "00:00:00:00:00:00"
end
function interface.ipaddrs(self)