libs/core: add luci.model.network.wifinet.id()
[project/luci.git] / libs / core / luasrc / model / network.lua
index 10fa03c..56597a2 100644 (file)
@@ -150,13 +150,19 @@ function _wifi_lookup(ifn)
        end
 end
 
+function _iface_virtual(x)
+       return (
+               x:match("^6in4-%w") or x:match("^6to4-%w") or x:match("^3g-%w") or
+               x:match("^ppp-%w") or x:match("^pppoe-%w") or x:match("^pppoa-%w") or
+               x:match("^relay-%w")
+       )
+end
+
 function _iface_ignore(x)
        return (
                x:match("^wmaster%d") or x:match("^wifi%d") or x:match("^hwsim%d") or
-               x:match("^imq%d") or x:match("^mon.wlan%d") or x:match("^6in4-%w") or
-               x:match("^6to4-%w") or x:match("^3g-%w") or x:match("^ppp-%w") or
-               x:match("^pppoe-%w") or x:match("^pppoa-%w") or x:match("^relay-%w") or
-               x == "sit0" or x == "lo"
+               x:match("^imq%d") or x:match("^mon.wlan%d") or
+               x == "sit0" or x == "lo" or _iface_virtual(x)
        )
 end
 
@@ -175,7 +181,7 @@ function init(cursor)
                local name = i.name:match("[^:]+")
                local prnt = name:match("^([^%.]+)%.")
 
-               if not _iface_ignore(name) then
+               if _iface_virtual(name) or not _iface_ignore(name) then
                        ifs[name] = ifs[name] or {
                                idx      = i.ifindex or n,
                                name     = name,
@@ -1115,6 +1121,10 @@ function wifinet.network(self)
        return uci_s:get("wifinet", self.sid, "network")
 end
 
+function wifinet.id(self)
+       return self.netid
+end
+
 function wifinet.name(self)
        return self.sid
 end
@@ -1198,6 +1208,14 @@ function wifinet.noise(self)
        return self.iwinfo.noise or 0
 end
 
+function wifinet.country(self)
+       return self.iwinfo.country or "00"
+end
+
+function wifinet.txpower(self)
+       return self.iwinfo.txpower or 0
+end
+
 function wifinet.signal_level(self, s, n)
        if self:active_bssid() ~= "00:00:00:00:00:00" then
                local signal = s or self:signal()