Skip to content

Commit

Permalink
socket: Add FreeBSD supprt to get_primary_mac_address
Browse files Browse the repository at this point in the history
  • Loading branch information
CRKatri committed Nov 24, 2021
1 parent 7c37434 commit 106cea5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static int wsa_init = 0;
#ifdef AF_INET6
#include <net/if.h>
#include <ifaddrs.h>
#ifdef __APPLE__
#if defined (__APPLE__) || defined (__FreeBSD__)
#include <net/if_dl.h>
#endif
#ifdef __linux__
Expand Down Expand Up @@ -714,11 +714,15 @@ LIBIMOBILEDEVICE_GLUE_API int get_primary_mac_address(unsigned char mac_addr_buf
if (ifa->ifa_flags & IFF_LOOPBACK) {
continue;
}
#if defined(__APPLE__)
#if defined(__APPLE__) || defined (__FreeBSD__)
if (ifa->ifa_addr->sa_family != AF_LINK) {
continue;
}
#if defined (__APPLE__)
if (!strcmp(ifa->ifa_name, "en0")) {
#elif defined (__FreeBSD__)
{
#endif
memcpy(mac_addr_buf, (unsigned char *)LLADDR((struct sockaddr_dl *)(ifa)->ifa_addr), 6);
result = 0;
break;
Expand Down

0 comments on commit 106cea5

Please sign in to comment.