diff options
author | WaluigiWare64 <68647953+WaluigiWare64@users.noreply.github.com> | 2020-12-01 14:01:57 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-01 23:01:57 +0100 |
commit | 07423492c434f2d0e54790e87562da25cd382bd9 (patch) | |
tree | 9679a36bbcf5392f729ee6ea3ea36872008427e7 /src/frontend/qt_sdl | |
parent | 298b958e2a105ba29f07ee110cd9f856da1f66d7 (diff) |
Use AF_LINK and net/if_dl.h on all non-Linux systems (#835)
Diffstat (limited to 'src/frontend/qt_sdl')
-rw-r--r-- | src/frontend/qt_sdl/LAN_PCap.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/frontend/qt_sdl/LAN_PCap.cpp b/src/frontend/qt_sdl/LAN_PCap.cpp index 8138699..3381e80 100644 --- a/src/frontend/qt_sdl/LAN_PCap.cpp +++ b/src/frontend/qt_sdl/LAN_PCap.cpp @@ -33,10 +33,10 @@ #include <sys/types.h> #include <ifaddrs.h> #include <netinet/in.h> - #ifdef __APPLE__ - #include <net/if_dl.h> + #ifdef __linux__ + #include <linux/if_packet.h> #else - #include <linux/if_packet.h> + #include <net/if_dl.h> #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; } |