diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-10-22 18:35:49 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-11-15 22:27:33 +0100 |
commit | b9db5aa4670ecc457af481ca41cb591f165b6852 (patch) | |
tree | 172ef3d5b9a0b8b07e675178b4cc092b8810a216 | |
parent | 24a240d233335bee89d44f76cb968e3889e2d9f7 (diff) |
luci-mod-status: routes.js: link-local neighbourslink-local-neigh
Show link-local addresses which don't contain an embedded
MAC/EUI-48 address in the IPv6 Neighbour list on the Routes status page.
Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
-rw-r--r-- | modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js index 5da5d403b..42c6b53d9 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/routes.js @@ -26,6 +26,20 @@ function applyMask(addr, mask, v6) { v6 ? '%x:%x:%x:%x:%x:%x:%x:%x' : '%d.%d.%d.%d', words); } +function eui48ToIPv6LinkLocal(eui48) { + var eui48_arr = eui48.toLowerCase().split(":"); + + if ( eui48.length != (3*6-1) || eui48_arr.length != 6 ) + return null; + + eui48_arr.splice(3, 0, "ff", "fe") + eui48_arr[0] = (parseInt(eui48_arr[0], 16)^2).toString(16) + + var eui64_arr = [eui48_arr[0]+eui48_arr[1], eui48_arr[2]+eui48_arr[3], eui48_arr[4]+eui48_arr[5], eui48_arr[6]+eui48_arr[7]]; + var eui64 = eui64_arr.map(x => x.replace(/^0+/, '')).join(":"); + return "fe80::" + eui64; +} + return view.extend({ load: function() { return Promise.all([ @@ -89,7 +103,7 @@ return view.extend({ flags = m ? m[2].trim().split(/\s+/) : [], state = (m ? m[3] : null) || 'FAILED'; - if (!addr || state == 'FAILED' || addr.match(/^fe[89a-f][0-9a-f]:/)) + if (!addr || state == 'FAILED') continue; for (var j = 0; j < flags.length; j += 2) @@ -98,6 +112,9 @@ return view.extend({ if (!flags.lladdr) continue; + if (v6 && addr.match(/^fe[89a-f][0-9a-f]:/) && eui48ToIPv6LinkLocal(flags.lladdr) == addr) + continue; + var net = this.getNetworkByDevice(networks, flags.dev, addr, v6 ? 128 : 32, v6); res.push([ |