diff options
author | Ansuel Smith <ansuelsmth@gmail.com> | 2019-06-02 22:33:02 +0200 |
---|---|---|
committer | Ansuel Smith <ansuelsmth@gmail.com> | 2019-06-03 12:48:48 +0200 |
commit | 525d62ff333f23552ecdd2d177d64e41544869f9 (patch) | |
tree | 2dcb4cebf7333df2a59adc199f47ca94b0c5e97d /modules/luci-base/luasrc/tools | |
parent | 4bbc033a968478d54a6c4bc2d8529abbfffdec6f (diff) |
luci-base: adds duid_to_mac to sys.lua
Move duid_to_mac function from status.lua to sys.lua.
Implement translation from DUID-LL without header to MAC
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Diffstat (limited to 'modules/luci-base/luasrc/tools')
-rw-r--r-- | modules/luci-base/luasrc/tools/status.lua | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/modules/luci-base/luasrc/tools/status.lua b/modules/luci-base/luasrc/tools/status.lua index 635995310f..496b7b9fd0 100644 --- a/modules/luci-base/luasrc/tools/status.lua +++ b/modules/luci-base/luasrc/tools/status.lua @@ -6,21 +6,6 @@ module("luci.tools.status", package.seeall) local uci = require "luci.model.uci".cursor() local ipc = require "luci.ip" -local function duid_to_mac(duid) - local b1, b2, b3, b4, b5, b6 - - -- DUID-LLT / Ethernet - if type(duid) == "string" and #duid == 28 then - b1, b2, b3, b4, b5, b6 = duid:match("^00010001(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)%x%x%x%x%x%x%x%x$") - - -- DUID-LL / Ethernet - elseif type(duid) == "string" and #duid == 20 then - b1, b2, b3, b4, b5, b6 = duid:match("^00030001(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)$") - end - - return b1 and ipc.checkmac(table.concat({ b1, b2, b3, b4, b5, b6 }, ":")) -end - local function dhcp_leases_common(family) local rv = { } local nfs = require "nixio.fs" @@ -93,7 +78,7 @@ local function dhcp_leases_common(family) elseif ip and iaid == "ipv4" and family == 4 then rv[#rv+1] = { expires = (expire >= 0) and os.difftime(expire, os.time()), - macaddr = ipc.checkmac(duid:gsub("^(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)$", "%1:%2:%3:%4:%5:%6")) or "00:00:00:00:00:00", + macaddr = sys.net.duid_to_mac(duid) or "00:00:00:00:00:00", ipaddr = ip, hostname = (name ~= "-") and name } |