mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-30 16:13:55 +00:00
also store binary representation of mac address in the interface lookup table for later use
This commit is contained in:
parent
be469f4dd0
commit
442595d6fc
@ -311,6 +311,7 @@ void LinuxNetLink::_routeDeleted(struct nlmsghdr *nlp)
|
|||||||
void LinuxNetLink::_linkAdded(struct nlmsghdr *nlp)
|
void LinuxNetLink::_linkAdded(struct nlmsghdr *nlp)
|
||||||
{
|
{
|
||||||
char mac[18] = {0};
|
char mac[18] = {0};
|
||||||
|
char mac_bin[6] = {0};
|
||||||
unsigned int mtu = 0;
|
unsigned int mtu = 0;
|
||||||
char ifname[IFNAMSIZ] = {0};
|
char ifname[IFNAMSIZ] = {0};
|
||||||
|
|
||||||
@ -327,6 +328,7 @@ void LinuxNetLink::_linkAdded(struct nlmsghdr *nlp)
|
|||||||
ptr2 = (unsigned char*)RTA_DATA(rtap);
|
ptr2 = (unsigned char*)RTA_DATA(rtap);
|
||||||
snprintf(mac, 20, "%02x:%02x:%02x:%02x:%02x:%02x",
|
snprintf(mac, 20, "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||||
ptr2[0], ptr2[1], ptr2[2], ptr2[3], ptr2[4], ptr2[5]);
|
ptr2[0], ptr2[1], ptr2[2], ptr2[3], ptr2[4], ptr2[5]);
|
||||||
|
memcpy(mac_bin, ptr, 6);
|
||||||
break;
|
break;
|
||||||
case IFLA_IFNAME:
|
case IFLA_IFNAME:
|
||||||
ptr = (const char*)RTA_DATA(rtap);
|
ptr = (const char*)RTA_DATA(rtap);
|
||||||
@ -342,6 +344,7 @@ void LinuxNetLink::_linkAdded(struct nlmsghdr *nlp)
|
|||||||
entry.index = ifip->ifi_index;
|
entry.index = ifip->ifi_index;
|
||||||
memcpy(entry.ifacename, ifname, sizeof(ifname));
|
memcpy(entry.ifacename, ifname, sizeof(ifname));
|
||||||
memcpy(entry.mac, mac, sizeof(mac));
|
memcpy(entry.mac, mac, sizeof(mac));
|
||||||
|
memcpy(entry.mac_bin, mac_bin, 6);
|
||||||
entry.mtu = mtu;
|
entry.mtu = mtu;
|
||||||
|
|
||||||
fprintf(stderr, "Link Added: %s mac: %s, mtu: %d\n", ifname, mac, mtu);
|
fprintf(stderr, "Link Added: %s mac: %s, mtu: %d\n", ifname, mac, mtu);
|
||||||
|
@ -105,6 +105,7 @@ private:
|
|||||||
int index;
|
int index;
|
||||||
char ifacename[IFNAMSIZ];
|
char ifacename[IFNAMSIZ];
|
||||||
char mac[18];
|
char mac[18];
|
||||||
|
char mac_bin[6];
|
||||||
unsigned int mtu;
|
unsigned int mtu;
|
||||||
};
|
};
|
||||||
Hashtable<int, iface_entry> _interfaces;
|
Hashtable<int, iface_entry> _interfaces;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user