-function network.is_virtual(self)
- local p = self:proto()
- return (
- p == "3g" or p == "6in4" or p == "6to4" or p == "ppp" or
- p == "pppoe" or p == "pppoa"
- )
+function protocol.metric(self)
+ return tonumber(_uci_state:get("network", self.sid, "metric")) or 0
+end
+
+function protocol.ipaddr(self)
+ return self:_ip("ipaddr", 4)
+end
+
+function protocol.netmask(self)
+ return self:_ip("netmask", 4)
+end
+
+function protocol.gwaddr(self)
+ return self:_ip("gateway", 4)
+end
+
+function protocol.dnsaddrs(self)
+ return self:_ip("dns", 4, true)
+end
+
+function protocol.ip6addr(self)
+ local ip6 = self:_ip("ip6addr", 6)
+ if not ip6 then
+ local ifc = _interfaces[self:ifname()]
+ if ifc and ifc.ip6addrs then
+ local a
+ for _, a in ipairs(ifc.ip6addrs) do
+ if not a:is6linklocal() then
+ ip6 = a:string()
+ break
+ end
+ end
+ end
+ end
+ return ip6