hwaddr = s:option(DummyValue, "_hwaddr")
function hwaddr.cfgvalue(self, section)
local ix = utl.trim(self.map:get(section, "ifname") or "")
- if #ix > 0 then
- local mac = fs.readfile("/sys/class/net/" .. ix .. "/address")
- or luci.util.exec("ifconfig " .. ix):match(" ([A-F0-9:]+)%s*\n")
+ local mac = fs.readfile("/sys/class/net/" .. ix .. "/address")
+
+ if not mac then
+ mac = luci.util.exec("ifconfig " .. ix)
+ mac = mac and mac:match(" ([A-F0-9:]+)%s*\n")
+ end
- if mac and #mac > 0 then
- return mac:upper()
- end
+ if mac and #mac > 0 then
+ return mac:upper()
end
+
return "?"
end
translate("network_interface_hwaddr"), translate("network_interface_hwaddr_desc"))
function hwaddr.cfgvalue(self, section)
local ix = self.map:get(section, "ifname") or ""
- return fs.readfile("/sys/class/net/" .. ix .. "/address")
- or luci.util.exec("ifconfig " .. ix):match(" ([A-F0-9:]+)%s*\n")
- or "n/a"
+ local mac = fs.readfile("/sys/class/net/" .. ix .. "/address")
+
+ if not mac then
+ mac = luci.util.exec("ifconfig " .. ix)
+ mac = mac and mac:match(" ([A-F0-9:]+)%s*\n")
+ end
+
+ if mac and #mac > 0 then
+ return mac:upper()
+ end
+
+ return "?"
end