summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-12-01 21:15:59 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-12-01 21:15:59 +0000
commit9d83aafb789a5c4ffdefcc3e336354485e80fc38 (patch)
tree142c06d46449004ef20b23f8e823681cc8ccefd8 /libs
parentde3ea4e95687812e6aeb2f109f5c9fbac0bd4a08 (diff)
libs/core: fix nil access, implement luci.model.network.network.uptime()
Diffstat (limited to 'libs')
-rw-r--r--libs/core/luasrc/model/network.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/libs/core/luasrc/model/network.lua b/libs/core/luasrc/model/network.lua
index cc4200cb4..30e75b9e4 100644
--- a/libs/core/luasrc/model/network.lua
+++ b/libs/core/luasrc/model/network.lua
@@ -481,6 +481,7 @@ function network.ifname(self)
elseif self:is_virtual() then
return p .. "-" .. self.sid
else
+ local num = { }
local dev = self:_get("ifname") or
uci_r:get("network", self.sid, "ifname")
@@ -525,6 +526,15 @@ function network.name(self)
return self.sid
end
+function network.uptime(self)
+ local cnt = tonumber(uci_s:get("network", self.sid, "connect_time"))
+ if cnt ~= nil then
+ return nxo.sysinfo().uptime - cnt
+ else
+ return 0
+ end
+end
+
function network.is_bridge(self)
return (self:type() == "bridge")
end