projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
08dfc28
)
libs/core: reuse existing uci context in network model if possible. fix some bugs
author
Jo-Philipp Wich
<jow@openwrt.org>
Sat, 30 Oct 2010 04:48:55 +0000
(
04:48
+0000)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Sat, 30 Oct 2010 04:48:55 +0000
(
04:48
+0000)
libs/core/luasrc/model/network.lua
patch
|
blob
|
history
diff --git
a/libs/core/luasrc/model/network.lua
b/libs/core/luasrc/model/network.lua
index
101bba3
..
ed40dc2
100644
(file)
--- a/
libs/core/luasrc/model/network.lua
+++ b/
libs/core/luasrc/model/network.lua
@@
-93,6
+93,16
@@
function _stror(s1, s2)
end
end
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 _get(c, s, o)
return uci_r:get(c, s, o)
end
@@
-161,7
+171,7
@@
end
function init(cursor)
function init(cursor)
- uci_r = cursor or uci.cursor()
+ uci_r = cursor or uci
_r or uci
.cursor()
uci_s = uci_r:substate()
ifs = { }
uci_s = uci_r:substate()
ifs = { }
@@
-609,7
+619,7
@@
function network.get_interfaces(self)
ifaces = { interface(ifn) }
else
local nfs = { }
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 = ifn:match("[^:]+")
nfs[ifn] = interface(ifn)
end
@@
-651,7
+661,7
@@
function network.contains_interface(self, ifname)
ifn = self:proto() .. "-" .. self.sid
return ifname == ifn
else
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
ifn = ifn:match("[^:]+")
if ifn == ifname then
return true
@@
-686,7
+696,7
@@
function interface.name(self)
end
function interface.mac(self)
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)
end
function interface.ipaddrs(self)