diff options
author | Joachim Tingvold <joachim@tingvold.com> | 2017-04-08 19:17:52 +0200 |
---|---|---|
committer | Joachim Tingvold <joachim@tingvold.com> | 2017-04-08 19:17:52 +0200 |
commit | 1cadec6c2905ba65189424597dabfb718a780fc6 (patch) | |
tree | f1ad56d369be30886fd58917d78f04ee8fb6fe1b | |
parent | 73e69ae72f2c619c7dd36cf40891dd3683abfd89 (diff) |
Fix proper format of the MAC address in the DHCP-log.
-rwxr-xr-x | bootstrap/make-dhcpd.pl | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/bootstrap/make-dhcpd.pl b/bootstrap/make-dhcpd.pl index 96c5fba..deca55e 100755 --- a/bootstrap/make-dhcpd.pl +++ b/bootstrap/make-dhcpd.pl @@ -205,17 +205,30 @@ option option-150 code 150 = { ip-address }; # define option 60 - used for classifying ZTP clients ("vendor class identifier") option vendor-class-identifier code 60 = text; +# binary-to-ascii remove leading 0 rebuild the complete MAC +set tempmac = concat ( + suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), ":", + suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), ":", + suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,3,1))),2), ":", + suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1))),2), ":", + suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), ":", + suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,6,1))),2) +); + +# extract the only first 8 chars +set hostmac = substring(tempmac, 0, 8); + # only allow FAP "clients" class "fap-vendor-class" { # Vendor-Class Option 60, length 21: "Juniper-ex2200-48t-4g" # Vendor-Class Option 60, length 21: "Juniper-ex3300-48p" match if substring (option vendor-class-identifier, 0, 10) = "Juniper-ex"; - log( info, concat( "FAP: ", binary-to-ascii(16,8,":",hardware), " (", option host-name, ") - ", option agent.circuit-id, " - ", option vendor-class-identifier )); + log( info, concat( "FAP: ", hostmac, " (", option host-name, ") - ", option agent.circuit-id, " - ", option vendor-class-identifier )); } class "fap-mac" { # some Juniper switches won't send vendor-class-identifier match if binary-to-ascii(16,8,":",substring(hardware, 1, 3)) = "44:f4:77"; - log( info, concat( "FAP: ", binary-to-ascii(16,8,":",hardware), " (", option host-name, ") - ", option agent.circuit-id )); + log( info, concat( "FAP: ", hostmac, " (", option host-name, ") - ", option agent.circuit-id )); } group { |