-hwaddr = s:option(DummyValue, "_hwaddr")
-function hwaddr.cfgvalue(self, section)
- local ix = self.map:stateget(section, "ifname") or ""
- return luci.fs.readfile("/sys/class/net/" .. ix .. "/address") or "n/a"
-end
-
-
-ipaddr = s:option(DummyValue, "ipaddr")
-
-function ipaddr.cfgvalue(self, section)
- local ip = self.map:stateget(section, "ipaddr")
- local nm = self.map:stateget(section, "netmask")
-
- local parsed = ip and luci.ip.IPv4(ip, nm)
- return parsed and parsed:string() or ""
-end
-
-txrx = s:option(DummyValue, "_rx", "TX / RX")
-
-function txrx.cfgvalue(self, section)
- local ix = self.map:stateget(section, "ifname")
-
- local rx = netstat and netstat[ix] and netstat[ix][1]
- rx = rx and luci.tools.webadmin.byte_format(tonumber(rx)) or "-"
-
- local tx = netstat and netstat[ix] and netstat[ix][9]
- tx = tx and luci.tools.webadmin.byte_format(tonumber(tx)) or "-"
-
- return string.format("%s / %s", tx, rx)
-end
-
-errors = s:option(DummyValue, "_err", "Errors", "TX / RX")
-
-function errors.cfgvalue(self, section)
- local ix = self.map:stateget(section, "ifname")
-
- local rx = netstat and netstat[ix] and netstat[ix][3]
- local tx = netstat and netstat[ix] and netstat[ix][11]
-
- rx = rx and tostring(rx) or "-"
- tx = tx and tostring(tx) or "-"
-
- return string.format("%s / %s", tx, rx)
-end