From 92f199ab985f861028ffcbd899f9037e8e575ab6 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 28 Mar 2019 22:40:28 +0000 Subject: More bug fixing for AARCH64. --- osdep/LinuxNetLink.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'osdep') diff --git a/osdep/LinuxNetLink.cpp b/osdep/LinuxNetLink.cpp index 90b3d53a..6645a856 100644 --- a/osdep/LinuxNetLink.cpp +++ b/osdep/LinuxNetLink.cpp @@ -362,7 +362,7 @@ void LinuxNetLink::_routeDeleted(struct nlmsghdr *nlp) void LinuxNetLink::_linkAdded(struct nlmsghdr *nlp) { - char mac_bin[6] = {0}; + unsigned char mac_bin[6] = {0}; unsigned int mtu = 0; char ifname[IFNAMSIZ] = {0}; @@ -370,17 +370,16 @@ void LinuxNetLink::_linkAdded(struct nlmsghdr *nlp) struct rtattr *rtap = (struct rtattr *)IFLA_RTA(ifip); int ifil = RTM_PAYLOAD(nlp); - const char *ptr; - unsigned char *ptr2; + const char *ptr = (const char *)0; for(;RTA_OK(rtap, ifil);rtap=RTA_NEXT(rtap, ifil)) { switch(rtap->rta_type) { case IFLA_ADDRESS: - ptr2 = (unsigned char*)RTA_DATA(rtap); + ptr = (const char *)RTA_DATA(rtap); memcpy(mac_bin, ptr, 6); break; case IFLA_IFNAME: - ptr = (const char*)RTA_DATA(rtap); + ptr = (const char *)RTA_DATA(rtap); memcpy(ifname, ptr, strlen(ptr)); break; case IFLA_MTU: @@ -394,7 +393,7 @@ void LinuxNetLink::_linkAdded(struct nlmsghdr *nlp) struct iface_entry &entry = _interfaces[ifip->ifi_index]; entry.index = ifip->ifi_index; memcpy(entry.ifacename, ifname, sizeof(ifname)); - memcpy(entry.mac, mac, sizeof(mac)); + snprintf(entry.mac,sizeof(entry.mac),"%.02x:%.02x:%.02x:%.02x:%.02x:%.02x",(unsigned int)mac_bin[0],(unsigned int)mac_bin[1],(unsigned int)mac_bin[2],(unsigned int)mac_bin[3],(unsigned int)mac_bin[4],(unsigned int)mac_bin[5]); memcpy(entry.mac_bin, mac_bin, 6); entry.mtu = mtu; } @@ -409,14 +408,10 @@ void LinuxNetLink::_linkDeleted(struct nlmsghdr *nlp) struct rtattr *rtap = (struct rtattr *)IFLA_RTA(ifip); int ifil = RTM_PAYLOAD(nlp); - const char *ptr; - unsigned char *ptr2; + const char *ptr = (const char *)0; for(;RTA_OK(rtap, ifil);rtap=RTA_NEXT(rtap, ifil)) { switch(rtap->rta_type) { - case IFLA_ADDRESS: - ptr2 = (unsigned char*)RTA_DATA(rtap); - break; case IFLA_IFNAME: ptr = (const char*)RTA_DATA(rtap); memcpy(ifname, ptr, strlen(ptr)); -- cgit v1.2.3