treewide: unify mac address handling
[project/luci.git] / modules / luci-base / luasrc / model / network.lua
index 3521c6d..056fc67 100644 (file)
@@ -330,7 +330,7 @@ function init(cursor)
                        if i.family == "packet" then
                                _interfaces[name].flags   = i.flags
                                _interfaces[name].stats   = i.data
-                               _interfaces[name].macaddr = i.addr
+                               _interfaces[name].macaddr = ipc.checkmac(i.addr)
                        elseif i.family == "inet" then
                                _interfaces[name].ipaddrs[#_interfaces[name].ipaddrs+1] = ipc.IPv4(i.addr, i.netmask)
                        elseif i.family == "inet6" then
@@ -1001,7 +1001,10 @@ function protocol.ip6addrs(self)
 
        if type(addrs) == "table" then
                for n, addr in ipairs(addrs) do
-                       if type(addr["local-address"]) == "table" then
+                       if type(addr["local-address"]) == "table" and
+                          type(addr["local-address"].mask) == "number" and
+                          type(addr["local-address"].address) == "string"
+                       then
                                rv[#rv+1] = "%s/%d" %{
                                        addr["local-address"].address,
                                        addr["local-address"].mask
@@ -1230,8 +1233,7 @@ function interface.name(self)
 end
 
 function interface.mac(self)
-       local mac = self:_ubus("macaddr")
-       return mac and mac:upper()
+       return ipc.checkmac(self:_ubus("macaddr"))
 end
 
 function interface.ipaddrs(self)