base: status: For odhpcd leases display MAC formatted with colons
authorDaniel Dickinson <lede@cshore.thecshore.com>
Fri, 9 Dec 2016 16:58:21 +0000 (11:58 -0500)
committerJo-Philipp Wich <jo@mein.io>
Wed, 31 May 2017 22:17:26 +0000 (00:17 +0200)
This should result in the MAC address display being the same
using odhcpd for v4 DHCP as when using DNSMasq for v4 DHCP.

Signed-off-by: Daniel Dickinson <lede@cshore.thecshore.com>
modules/luci-base/luasrc/tools/status.lua

index 4da0cf984b252eef1c344a95be8e1e413bc53c49..b0df9d365a03dcccdbb189722530e3f38ddb3aef 100644 (file)
@@ -73,9 +73,19 @@ local function dhcp_leases_common(family)
                                                hostname = (name ~= "-") and name
                                        }
                                elseif ip and iaid == "ipv4" and family == 4 then
+                                       local mac, mac1, mac2, mac3, mac4, mac5, mac6
+                                       if duid and type(duid) == "string" then
+                                                mac1, mac2, mac3, mac4, mac5, mac6 = duid:match("^(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)(%x%x)$")
+                                       end
+                                       if not (mac1 and mac2 and mac3 and mac4 and mac5 and mac6) then
+                                               mac = "FF:FF:FF:FF:FF:FF"
+                                       else
+                                               mac = mac1..":"..mac2..":"..mac3..":"..mac4..":"..mac5..":"..mac6
+                                       end
                                        rv[#rv+1] = {
                                                expires  = (expire >= 0) and os.difftime(expire, os.time()),
                                                macaddr  = duid,
+                                               macaddr  = mac:lower(),
                                                ipaddr   = ip,
                                                hostname = (name ~= "-") and name
                                        }