diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2012-11-01 20:03:36 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2012-11-01 20:03:36 +0000 |
commit | 36f88887c19d2b0098ae1965b6725845705efc51 (patch) | |
tree | 4b73eab4ac1485ce96417803167e47a696b39c7a /modules/admin-core/luasrc/tools | |
parent | 59af400346d15250af5873db66e420592a5b9ff9 (diff) |
modules/admin-core, modules/admin-full: fix switch port status for devices with multiple switches
Diffstat (limited to 'modules/admin-core/luasrc/tools')
-rw-r--r-- | modules/admin-core/luasrc/tools/status.lua | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/modules/admin-core/luasrc/tools/status.lua b/modules/admin-core/luasrc/tools/status.lua index e5c517f23..3ececa8f1 100644 --- a/modules/admin-core/luasrc/tools/status.lua +++ b/modules/admin-core/luasrc/tools/status.lua @@ -153,35 +153,40 @@ function wifi_network(id) return { } end -function switch_status(dev) - local ports = { } - local swc = io.popen("swconfig dev %q show" % dev, "r") - if swc then - local l - repeat - l = swc:read("*l") - if l then - local port, up = l:match("port:(%d+) link:(%w+)") - if port then - local speed = l:match(" speed:(%d+)") - local duplex = l:match(" (%w+)-duplex") - local txflow = l:match(" (txflow)") - local rxflow = l:match(" (rxflow)") - local auto = l:match(" (auto)") - - ports[#ports+1] = { - port = tonumber(port) or 0, - speed = tonumber(speed) or 0, - link = (up == "up"), - duplex = (duplex == "full"), - rxflow = (not not rxflow), - txflow = (not not txflow), - auto = (not not auto) - } +function switch_status(devs) + local dev + local switches = { } + for dev in devs:gmatch("[^%s,]+") do + local ports = { } + local swc = io.popen("swconfig dev %q show" % dev, "r") + if swc then + local l + repeat + l = swc:read("*l") + if l then + local port, up = l:match("port:(%d+) link:(%w+)") + if port then + local speed = l:match(" speed:(%d+)") + local duplex = l:match(" (%w+)-duplex") + local txflow = l:match(" (txflow)") + local rxflow = l:match(" (rxflow)") + local auto = l:match(" (auto)") + + ports[#ports+1] = { + port = tonumber(port) or 0, + speed = tonumber(speed) or 0, + link = (up == "up"), + duplex = (duplex == "full"), + rxflow = (not not rxflow), + txflow = (not not txflow), + auto = (not not auto) + } + end end - end - until not l - swc:close() + until not l + swc:close() + end + switches[dev] = ports end - return ports + return switches end |