mirror of https://github.com/aredn/aredn.git
Bridge handling on older devices is more complex
This commit is contained in:
parent
6d321a119f
commit
108a3e839e
|
@ -149,7 +149,7 @@ function hardware.get_iface_name(name)
|
||||||
end
|
end
|
||||||
local intfname = cursor:get("network", name, "ifname")
|
local intfname = cursor:get("network", name, "ifname")
|
||||||
if intfname then
|
if intfname then
|
||||||
return intfname
|
return intfname:match("^(%S+)")
|
||||||
end
|
end
|
||||||
-- Now we guess
|
-- Now we guess
|
||||||
if name == "lan" then
|
if name == "lan" then
|
||||||
|
@ -168,6 +168,30 @@ function hardware.get_iface_name(name)
|
||||||
return hardware.get_board().network[name].ifname:match("^(%S+)")
|
return hardware.get_board().network[name].ifname:match("^(%S+)")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function hardware.get_bridge_iface_names(name)
|
||||||
|
local cursor = uci.cursor()
|
||||||
|
local btype = cursor:get("network", name, "type")
|
||||||
|
local intfnames = cursor:get("network", name, "ifname")
|
||||||
|
if intfnames then
|
||||||
|
return intfnames
|
||||||
|
end
|
||||||
|
-- Now we guess
|
||||||
|
if name == "lan" then
|
||||||
|
return "eth0"
|
||||||
|
end
|
||||||
|
if name == "wan" then
|
||||||
|
return "eth0.1"
|
||||||
|
end
|
||||||
|
if name == "wifi" then
|
||||||
|
return "wlan0"
|
||||||
|
end
|
||||||
|
if name == "dtdlink" then
|
||||||
|
return "eth0.2"
|
||||||
|
end
|
||||||
|
-- Maybe the board knows
|
||||||
|
return hardware.get_board().network[name].ifname
|
||||||
|
end
|
||||||
|
|
||||||
function hardware.get_link_led()
|
function hardware.get_link_led()
|
||||||
local err, result = xpcall(
|
local err, result = xpcall(
|
||||||
function()
|
function()
|
||||||
|
@ -256,7 +280,7 @@ end
|
||||||
function hardware.get_interface_mac(intf)
|
function hardware.get_interface_mac(intf)
|
||||||
local mac = ""
|
local mac = ""
|
||||||
if intf then
|
if intf then
|
||||||
local f = io.popen("ifconfig " .. intf)
|
local f = io.popen("ifconfig " .. intf .. " 2>/dev/null")
|
||||||
for line in f:lines()
|
for line in f:lines()
|
||||||
do
|
do
|
||||||
local m = line:match("HWaddr ([%w:]+)")
|
local m = line:match("HWaddr ([%w:]+)")
|
||||||
|
|
|
@ -452,6 +452,9 @@ end
|
||||||
|
|
||||||
function mac_to_ip(mac, shift)
|
function mac_to_ip(mac, shift)
|
||||||
local a, b, c = mac:match("%w%w:%w%w:%w%w:(%w%w):(%w%w):(%w%w)")
|
local a, b, c = mac:match("%w%w:%w%w:%w%w:(%w%w):(%w%w):(%w%w)")
|
||||||
|
if not a then
|
||||||
|
return "0.0.0"
|
||||||
|
end
|
||||||
return string.format("%d.%d.%d", tonumber(a, 16), tonumber(b, 16), tonumber(c, 16))
|
return string.format("%d.%d.%d", tonumber(a, 16), tonumber(b, 16), tonumber(c, 16))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ local deleteme = {}
|
||||||
local cfg = {
|
local cfg = {
|
||||||
lan_intf = lanintf,
|
lan_intf = lanintf,
|
||||||
wan_intf = "dummy",
|
wan_intf = "dummy",
|
||||||
dtdlink_intf = aredn.hardware.get_iface_name('dtdlink')
|
dtdlink_intf = aredn.hardware.get_bridge_iface_names('dtdlink')
|
||||||
}
|
}
|
||||||
|
|
||||||
if not auto then
|
if not auto then
|
||||||
|
@ -114,7 +114,7 @@ end
|
||||||
if cfg.wifi_enable == "1" then
|
if cfg.wifi_enable == "1" then
|
||||||
cfg.wifi_intf = aredn.hardware.get_board().network.wifi.ifname:match("^(%S+)")
|
cfg.wifi_intf = aredn.hardware.get_board().network.wifi.ifname:match("^(%S+)")
|
||||||
else
|
else
|
||||||
cfg.wifi_intf = cfg.dtdlink_intf:match("([%w]*)") .. ".3975"
|
cfg.wifi_intf = lanintf:match("^([^%.%s]+).*$") .. ".3975"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- delete some config lines if necessary
|
-- delete some config lines if necessary
|
||||||
|
|
Loading…
Reference in New Issue