diff --git a/files/usr/lib/lua/aredn/hardware.lua b/files/usr/lib/lua/aredn/hardware.lua index 0a7e92ef..0d59c899 100644 --- a/files/usr/lib/lua/aredn/hardware.lua +++ b/files/usr/lib/lua/aredn/hardware.lua @@ -149,7 +149,7 @@ function hardware.get_iface_name(name) end local intfname = cursor:get("network", name, "ifname") if intfname then - return intfname + return intfname:match("^(%S+)") end -- Now we guess if name == "lan" then @@ -168,6 +168,30 @@ function hardware.get_iface_name(name) return hardware.get_board().network[name].ifname:match("^(%S+)") 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() local err, result = xpcall( function() @@ -256,7 +280,7 @@ end function hardware.get_interface_mac(intf) local mac = "" if intf then - local f = io.popen("ifconfig " .. intf) + local f = io.popen("ifconfig " .. intf .. " 2>/dev/null") for line in f:lines() do local m = line:match("HWaddr ([%w:]+)") diff --git a/files/usr/lib/lua/aredn/utils.lua b/files/usr/lib/lua/aredn/utils.lua index ca6cb268..3359c51d 100755 --- a/files/usr/lib/lua/aredn/utils.lua +++ b/files/usr/lib/lua/aredn/utils.lua @@ -452,6 +452,9 @@ end function mac_to_ip(mac, shift) 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)) end diff --git a/files/usr/local/bin/node-setup b/files/usr/local/bin/node-setup index 8de732e8..099f5545 100755 --- a/files/usr/local/bin/node-setup +++ b/files/usr/local/bin/node-setup @@ -91,7 +91,7 @@ local deleteme = {} local cfg = { lan_intf = lanintf, wan_intf = "dummy", - dtdlink_intf = aredn.hardware.get_iface_name('dtdlink') + dtdlink_intf = aredn.hardware.get_bridge_iface_names('dtdlink') } if not auto then @@ -114,7 +114,7 @@ end if cfg.wifi_enable == "1" then cfg.wifi_intf = aredn.hardware.get_board().network.wifi.ifname:match("^(%S+)") else - cfg.wifi_intf = cfg.dtdlink_intf:match("([%w]*)") .. ".3975" + cfg.wifi_intf = lanintf:match("^([^%.%s]+).*$") .. ".3975" end -- delete some config lines if necessary