From 442595d6fc102fcb0bbf7d725149b67b5963944e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 25 May 2018 14:25:44 -0700 Subject: [PATCH] also store binary representation of mac address in the interface lookup table for later use --- osdep/LinuxNetLink.cpp | 3 +++ osdep/LinuxNetLink.hpp | 1 + 2 files changed, 4 insertions(+) diff --git a/osdep/LinuxNetLink.cpp b/osdep/LinuxNetLink.cpp index 6251cb102..d6fffe788 100644 --- a/osdep/LinuxNetLink.cpp +++ b/osdep/LinuxNetLink.cpp @@ -311,6 +311,7 @@ void LinuxNetLink::_routeDeleted(struct nlmsghdr *nlp) void LinuxNetLink::_linkAdded(struct nlmsghdr *nlp) { char mac[18] = {0}; + char mac_bin[6] = {0}; unsigned int mtu = 0; char ifname[IFNAMSIZ] = {0}; @@ -327,6 +328,7 @@ void LinuxNetLink::_linkAdded(struct nlmsghdr *nlp) ptr2 = (unsigned char*)RTA_DATA(rtap); snprintf(mac, 20, "%02x:%02x:%02x:%02x:%02x:%02x", ptr2[0], ptr2[1], ptr2[2], ptr2[3], ptr2[4], ptr2[5]); + memcpy(mac_bin, ptr, 6); break; case IFLA_IFNAME: ptr = (const char*)RTA_DATA(rtap); @@ -342,6 +344,7 @@ void LinuxNetLink::_linkAdded(struct nlmsghdr *nlp) entry.index = ifip->ifi_index; memcpy(entry.ifacename, ifname, sizeof(ifname)); memcpy(entry.mac, mac, sizeof(mac)); + memcpy(entry.mac_bin, mac_bin, 6); entry.mtu = mtu; fprintf(stderr, "Link Added: %s mac: %s, mtu: %d\n", ifname, mac, mtu); diff --git a/osdep/LinuxNetLink.hpp b/osdep/LinuxNetLink.hpp index d0e831896..188c8a770 100644 --- a/osdep/LinuxNetLink.hpp +++ b/osdep/LinuxNetLink.hpp @@ -105,6 +105,7 @@ private: int index; char ifacename[IFNAMSIZ]; char mac[18]; + char mac_bin[6]; unsigned int mtu; }; Hashtable _interfaces;