summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2016-01-25 17:54:38 +0100
committerJo-Philipp Wich <jow@openwrt.org>2016-01-25 17:54:44 +0100
commit02a93bca500acac3d051ac6a541e70905f1934e9 (patch)
tree91eccc76b3fe67fab1c883f49fd08258f5de675a /modules
parent4f47a18bb1a98ed263559e1cb40b5b5efc43f14b (diff)
luci-mod-admin-full: map DHCPv6 DUIDs to MACs
Map DUIDs to their corresponding MAC addresses in order to correlate them with IPv4 information. This is useful to e.g. identify IPv6 hosts which do not send a name. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm28
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm26
2 files changed, 50 insertions, 4 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm b/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm
index ab8e732573..f7787dd1ea 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_network/lease_status.htm
@@ -1,4 +1,18 @@
<script type="text/javascript">//<![CDATA[
+ function duid2mac(duid) {
+ // DUID-LLT / Ethernet
+ if (duid.length === 28 && duid.substr(0, 8) === '00010001')
+ return duid.substr(16).replace(/(..)(?=..)/g, '$1:').toUpperCase();
+
+ // DUID-LL / Ethernet
+ if (duid.length === 24 && duid.substr(0, 8) === '00030001')
+ return duid.substr(8).replace(/(..)(?=..)/g, '$1:').toUpperCase();
+
+ return null;
+ }
+
+ var hosts = <%=luci.http.write_json(luci.sys.net.host_hints())%>;
+
XHR.poll(5, '<%=url('admin/network/dhcplease_status')%>', null,
function(x, st)
{
@@ -67,7 +81,17 @@
var tr = tb6.insertRow(-1);
tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
- tr.insertCell(-1).innerHTML = st[1][i].hostname ? st[1][i].hostname : '?';
+ var host = hosts[duid2mac(st[1][i].duid)];
+ if (host)
+ tr.insertCell(-1).innerHTML = String.format(
+ '<div style="max-width:200px;overflow:hidden;text-overflow:ellipsis">%s</div>',
+ ((host.name && (host.ipv4 || host.ipv6))
+ ? '%h (%s)'.format(host.name, host.ipv4 || host.ipv6)
+ : '%h'.format(host.name || host.ipv4 || host.ipv6)).nobr()
+ );
+ else
+ tr.insertCell(-1).innerHTML = st[1][i].hostname ? st[1][i].hostname : '?';
+
tr.insertCell(-1).innerHTML = st[1][i].ip6addr;
tr.insertCell(-1).innerHTML = st[1][i].duid;
tr.insertCell(-1).innerHTML = timestr;
@@ -106,7 +130,7 @@
<legend><%:Active DHCPv6 Leases%></legend>
<table class="cbi-section-table" id="lease6_status_table">
<tr class="cbi-section-table-titles">
- <th class="cbi-section-table-cell"><%:Hostname%></th>
+ <th class="cbi-section-table-cell"><%:Host%></th>
<th class="cbi-section-table-cell"><%:IPv6-Address%></th>
<th class="cbi-section-table-cell"><%:DUID%></th>
<th class="cbi-section-table-cell"><%:Leasetime remaining%></th>
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
index a37982e1dc..8bfc61b99b 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
@@ -144,6 +144,18 @@
return s;
}
+ function duid2mac(duid) {
+ // DUID-LLT / Ethernet
+ if (duid.length === 28 && duid.substr(0, 8) === '00010001')
+ return duid.substr(16).replace(/(..)(?=..)/g, '$1:').toUpperCase();
+
+ // DUID-LL / Ethernet
+ if (duid.length === 24 && duid.substr(0, 8) === '00030001')
+ return duid.substr(8).replace(/(..)(?=..)/g, '$1:').toUpperCase();
+
+ return null;
+ }
+
var npoll = 1;
var hosts = <%=luci.http.write_json(luci.sys.net.host_hints())%>;
@@ -339,7 +351,17 @@
var tr = ls6.rows[0].parentNode.insertRow(-1);
tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
- tr.insertCell(-1).innerHTML = info.leases6[i].hostname ? info.leases6[i].hostname : '?';
+ var host = hosts[duid2mac(info.leases6[i].duid)];
+ if (host)
+ tr.insertCell(-1).innerHTML = String.format(
+ '<div style="max-width:200px;overflow:hidden;text-overflow:ellipsis">%s</div>',
+ ((host.name && (host.ipv4 || host.ipv6))
+ ? '%h (%s)'.format(host.name, host.ipv4 || host.ipv6)
+ : '%h'.format(host.name || host.ipv4 || host.ipv6)).nobr()
+ );
+ else
+ tr.insertCell(-1).innerHTML = info.leases6[i].hostname ? info.leases6[i].hostname : '?';
+
tr.insertCell(-1).innerHTML = info.leases6[i].ip6addr;
tr.insertCell(-1).innerHTML = info.leases6[i].duid;
tr.insertCell(-1).innerHTML = timestr;
@@ -671,7 +693,7 @@
<table class="cbi-section-table" id="lease6_status_table">
<tr class="cbi-section-table-titles">
- <th class="cbi-section-table-cell"><%:Hostname%></th>
+ <th class="cbi-section-table-cell"><%:Host%></th>
<th class="cbi-section-table-cell"><%:IPv6-Address%></th>
<th class="cbi-section-table-cell"><%:DUID%></th>
<th class="cbi-section-table-cell"><%:Leasetime remaining%></th>