return assoc
end
-
-function switch_status(devs)
- local dev
- local switches = { }
- for dev in devs:gmatch("[^%s,]+") do
- local ports = { }
- local swc = io.popen("swconfig dev %s show"
- % luci.util.shellquote(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
- until not l
- swc:close()
- end
- switches[dev] = ports
- end
- return switches
-end