diff options
author | Grant Limberg <grant.limberg@zerotier.com> | 2018-05-25 14:25:44 -0700 |
---|---|---|
committer | Grant Limberg <grant.limberg@zerotier.com> | 2018-05-25 14:25:44 -0700 |
commit | 442595d6fc102fcb0bbf7d725149b67b5963944e (patch) | |
tree | f6c2a48f8c8571d99824c55b0ce8de9af0225990 | |
parent | be469f4dd034050ca95a953903b3170ace275b27 (diff) | |
download | infinitytier-442595d6fc102fcb0bbf7d725149b67b5963944e.tar.gz infinitytier-442595d6fc102fcb0bbf7d725149b67b5963944e.zip |
also store binary representation of mac address in the interface lookup table for later use
-rw-r--r-- | osdep/LinuxNetLink.cpp | 3 | ||||
-rw-r--r-- | osdep/LinuxNetLink.hpp | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/osdep/LinuxNetLink.cpp b/osdep/LinuxNetLink.cpp index 6251cb10..d6fffe78 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 d0e83189..188c8a77 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<int, iface_entry> _interfaces; |