local dsp = require "luci.dispatcher"
local uci = require "luci.model.uci"
local lng = require "luci.i18n"
+local jsc = require "luci.jsonc"
module "luci.model.network"
IFACE_PATTERNS_VIRTUAL = { }
-IFACE_PATTERNS_IGNORE = { "^wmaster%d", "^wifi%d", "^hwsim%d", "^imq%d", "^ifb%d", "^mon%.wlan%d", "^sit%d", "^gre%d", "^lo$" }
+IFACE_PATTERNS_IGNORE = { "^wmaster%d", "^wifi%d", "^hwsim%d", "^imq%d", "^ifb%d", "^mon%.wlan%d", "^sit%d", "^gre%d", "^gretap%d", "^ip6gre%d", "^ip6tnl%d", "^tunl%d", "^lo$" }
IFACE_PATTERNS_WIRELESS = { "^wlan%d", "^wl%d", "^ath%d", "^%w+%.network%d" }
return true
end
end
- return _iface_virtual(x)
+ return false
end
_tunnel[name] = true
end
- if _tunnel[name] or not _iface_ignore(name) then
+ if _tunnel[name] or not (_iface_ignore(name) or _iface_virtual(name)) then
_interfaces[name] = _interfaces[name] or {
idx = i.ifindex or n,
name = name,
end
end
+local function swdev_from_board_json()
+ local boardinfo = jsc.parse(nfs.readfile("/etc/board.json") or "")
+ if type(boardinfo) == "table" and type(boardinfo.network) == "table" then
+ local net, val
+ for net, val in pairs(boardinfo.network) do
+ if type(val) == "table" and type(val.ifname) == "string" and
+ val.create_vlan == true
+ then
+ return val.ifname
+ end
+ end
+ end
+ return nil
+end
+
function get_interfaces(self)
local iface
local ifaces = { }
_uci:foreach("network", "interface",
function(s)
for iface in utl.imatch(s.ifname) do
- if not _iface_ignore(iface) and not _wifi_iface(iface) then
+ if not _iface_ignore(iface) and not _iface_virtual(iface) and not _wifi_iface(iface) then
seen[iface] = true
nfs[iface] = interface(iface)
end
end)
for iface in utl.kspairs(_interfaces) do
- if not (seen[iface] or _iface_ignore(iface) or _wifi_iface(iface)) then
+ if not (seen[iface] or _iface_ignore(iface) or _iface_virtual(iface) or _wifi_iface(iface)) then
nfs[iface] = interface(iface)
end
end
end
end
if not base or not base:match("^eth%d") then
- base = "eth0"
+ base = swdev_from_board_json() or "eth0"
end
else
base = s.device
end
function get_wannet(self)
- local net = self:get_status_by_route("0.0.0.0", 0)
- return net and network(net)
+ local net, stat = self:get_status_by_route("0.0.0.0", 0)
+ return net and network(net, stat.proto)
end
function get_wandev(self)
end
function get_wan6net(self)
- local net = self:get_status_by_route("::", 0)
- return net and network(net)
+ local net, stat = self:get_status_by_route("::", 0)
+ return net and network(net, stat.proto)
end
function get_wan6dev(self)
function interface.shortname(self)
if self.wif then
- return "%s %q" %{
- self.wif:active_mode(),
- self.wif:active_ssid() or self.wif:active_bssid()
- }
+ return self.wif:shortname()
else
return self.ifname
end
return "%s: %s %q" %{
lng.translate("Wireless Network"),
self.wif:active_mode(),
- self.wif:active_ssid() or self.wif:active_bssid()
+ self.wif:active_ssid() or self.wif:active_bssid() or self.wif:id()
}
else
return "%s: %q" %{ self:get_type_i18n(), self:name() }
function wifinet.shortname(self)
return "%s %q" %{
lng.translate(self:active_mode()),
- self:active_ssid() or self:active_bssid()
+ self:active_ssid() or self:active_bssid() or self:id()
}
end
return "%s: %s %q (%s)" %{
lng.translate("Wireless Network"),
lng.translate(self:active_mode()),
- self:active_ssid() or self:active_bssid(),
+ self:active_ssid() or self:active_bssid() or self:id(),
self:ifname()
}
end