diff --git a/files/usr/local/bin/node-setup b/files/usr/local/bin/node-setup index 28d0f356..41bc63fb 100755 --- a/files/usr/local/bin/node-setup +++ b/files/usr/local/bin/node-setup @@ -981,6 +981,17 @@ if nixio.fs.access("/etc/config.mesh/olsrd", "r") then if is_supernode then of:write("config Hna4\n\toption netaddr 10.0.0.0\n\toption netmask 255.0.0.0\n\n") end + + if nixio.fs.stat("/etc/config.mesh/xlink") then + uci.cursor("/etc/config.mesh"):foreach("xlink", "interface", + function(section) + if section.netmask ~= "255.255.255.255" then + local addr = decimal_to_ip(nixio.bit.band(ip_to_decimal(section.ipaddr), ip_to_decimal(section.netmask))) + of:write(string.format("config Hna4\n\toption netaddr %s\n\toption netmask %s\n\n", addr, section.netmask)) + end + end + ) + end if nc:get("aredn", "@wan[0]", "olsrd_gw") == "1" then of:write("config LoadPlugin\n\toption library 'olsrd_dyn_gw.so.0.5'\n\toption Interval '60'\n\tlist Ping '8.8.8.8'\n\tlist Ping '8.8.4.4'\n\n") diff --git a/files/www/cgi-bin/advancednetwork b/files/www/cgi-bin/advancednetwork index 955a6b2d..50d3f953 100755 --- a/files/www/cgi-bin/advancednetwork +++ b/files/www/cgi-bin/advancednetwork @@ -191,6 +191,7 @@ function read_xlink_config() peer = nil, weight = 0, port = nil, + netmask = nil, mac = "" } configs[#configs + 1] = config @@ -225,6 +226,10 @@ function read_xlink_config() if m then config.weight = tonumber(m) end + m = line:match("option%s+netmask%s+'([%d%.]+)'") + if m then + config.netmask = m + end end end return configs @@ -320,8 +325,12 @@ function write_xlink_config(configs) f:write("\toption macaddr '" .. config.mac .. "'\n") f:write("\toption proto 'static'\n") f:write("\toption ipaddr '" .. config.ipaddr .. "'\n") - f:write("\toption netmask '255.255.255.255'\n") f:write("\toption weight '" .. config.weight .. "'\n") + if config.netmask and config.netmask ~= "" then + f:write("\toption netmask '" .. config.netmask .. "'\n") + else + f:write("\toption netmask '255.255.255.255'\n") + end if config.peer and config.peer ~= "" then f:write("\toption peer '" .. config.peer .. "'\n") f:write("\nconfig route\n") @@ -512,13 +521,10 @@ html.print([[ width: 100px; padding-left: 10px; } - .xlinks td:nth-child(1), .xlinks td:nth-child(4) { + .xlinks td:nth-child(1), .xlinks td:nth-child(4), .xlinks td:nth-child(5) { width: 40px; } - .xlinks td:nth-child(5) { - width: 55px; - } - .xlinks td:nth-child(6) { + .xlinks td:nth-child(6), .xlinks td:nth-child(7) { width: 20px; } .xlinks td input { @@ -531,7 +537,7 @@ html.print([[ .xlinks td:nth-child(1) input, .xlinks td:nth-child(4) input { text-align: right; } - .xlinks td:nth-child(6) button { + .xlinks td:nth-child(7) button { width: 24px; line-height: 14px; background-color: #f0f0f0; @@ -596,6 +602,7 @@ html.print([[ const row = document.createElement("tr"); row.innerHTML = "]] .. (function() local s = "" end)() + .. (function() local s = "" end)() .. [[" tbody.appendChild(row) validate(); @@ -610,13 +617,32 @@ html.print([[ const rows = document.querySelectorAll("table.xlinks tr"); for (let i = 1; i < rows.length; i++) { const cells = rows[i].querySelectorAll("td input"); + const selects = rows[i].querySelectorAll("select"); xlinks.push({ name: "xlink" + (i - 1), vlan: parseInt(cells[0].value), ipaddr: cells[1].value, peer: cells[2].value, weight: parseInt(cells[3].value), - port: rows[i].querySelector("select").value, + port: selects[0].value, + netmask: { + "": "255.255.255.255", + "30": "255.255.255.252", + "29": "255.255.255.248", + "28": "255.255.255.240", + "27": "255.255.255.224", + "26": "255.255.255.192", + "25": "255.255.255.128", + "24": "255.255.255.0", + "23": "255.255.254.0", + "22": "255.255.252.0", + "21": "255.255.248.0", + "20": "255.255.240.0", + "19": "255.255.224.0", + "18": "255.255.192.0", + "17": "255.255.128.0", + "16": "255.255.0.0" + }[selects[1].value], mac: cells[4].value }); } @@ -744,8 +770,11 @@ end html.print([[]]) html.print([[]]) if #layout.ports > 1 then - html.print([[]]) + html.print([[]]) +else + html.print([[]]) end +html.print([[]]) html.print([[]]) for _, xlink in ipairs(xlinks) do @@ -758,6 +787,14 @@ do html.print("") end html.print("") + html.print("") html.print("") html.print("") end