From 07423492c434f2d0e54790e87562da25cd382bd9 Mon Sep 17 00:00:00 2001 From: WaluigiWare64 <68647953+WaluigiWare64@users.noreply.github.com> Date: Tue, 1 Dec 2020 14:01:57 -0800 Subject: [PATCH] Use AF_LINK and net/if_dl.h on all non-Linux systems (#835) --- src/frontend/qt_sdl/LAN_PCap.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/frontend/qt_sdl/LAN_PCap.cpp b/src/frontend/qt_sdl/LAN_PCap.cpp index 8138699e..3381e809 100644 --- a/src/frontend/qt_sdl/LAN_PCap.cpp +++ b/src/frontend/qt_sdl/LAN_PCap.cpp @@ -33,10 +33,10 @@ #include #include #include - #ifdef __APPLE__ - #include + #ifdef __linux__ + #include #else - #include + #include #endif #endif @@ -283,16 +283,7 @@ bool Init(bool open_adapter) struct sockaddr_in* sa = (sockaddr_in*)curaddr->ifa_addr; memcpy(adata->IP_v4, &sa->sin_addr, 4); } - #ifdef __APPLE__ - else if (af == AF_LINK) - { - struct sockaddr_dl* sa = (sockaddr_dl*)curaddr->ifa_addr; - if (sa->sdl_alen != 6) - printf("weird MAC length %d for %s\n", sa->sdl_alen, curaddr->ifa_name); - else - memcpy(adata->MAC, LLADDR(sa), 6); - } - #else + #ifdef __linux__ else if (af == AF_PACKET) { struct sockaddr_ll* sa = (sockaddr_ll*)curaddr->ifa_addr; @@ -301,6 +292,15 @@ bool Init(bool open_adapter) else memcpy(adata->MAC, sa->sll_addr, 6); } + #else + else if (af == AF_LINK) + { + struct sockaddr_dl* sa = (sockaddr_dl*)curaddr->ifa_addr; + if (sa->sdl_alen != 6) + printf("weird MAC length %d for %s\n", sa->sdl_alen, curaddr->ifa_name); + else + memcpy(adata->MAC, LLADDR(sa), 6); + } #endif curaddr = curaddr->ifa_next; }