From 1ee8d0ac233fb510260dbf3a647fbd02f1a92825 Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Thu, 11 Apr 2024 10:08:22 +0200 Subject: socket: Haiku compilation fixes - link against libnetwork - get_primary_mac_address similar to FreeBSD --- configure.ac | 2 ++ src/socket.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 4a3aca3..eae80e8 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,8 @@ AC_TYPE_UINT8_T # Checks for library functions. AC_CHECK_FUNCS([asprintf strcasecmp strdup strerror strndup stpcpy vasprintf getifaddrs poll]) +# Checks for additional library requirements +AC_SEARCH_LIBS(socket, network) AC_CHECK_HEADER(endian.h, [ac_cv_have_endian_h="yes"], [ac_cv_have_endian_h="no"]) if test "x$ac_cv_have_endian_h" = "xno"; then diff --git a/src/socket.c b/src/socket.c index 5276b1e..d4dedd1 100644 --- a/src/socket.c +++ b/src/socket.c @@ -55,7 +55,7 @@ static int wsa_init = 0; #ifdef AF_INET6 #include #include -#if defined (__APPLE__) || defined (__FreeBSD__) +#if defined (__APPLE__) || defined (__FreeBSD__) || defined (__HAIKU__) #include #endif #ifdef __linux__ @@ -894,13 +894,13 @@ int get_primary_mac_address(unsigned char mac_addr_buf[6]) if (ifa->ifa_flags & IFF_LOOPBACK) { continue; } -#if defined(__APPLE__) || defined (__FreeBSD__) +#if defined(__APPLE__) || defined (__FreeBSD__) || defined (__HAIKU__) if (ifa->ifa_addr->sa_family != AF_LINK) { continue; } #if defined (__APPLE__) if (!strcmp(ifa->ifa_name, "en0")) { -#elif defined (__FreeBSD__) +#elif defined (__FreeBSD__) || defined (__HAIKU__) { #endif memcpy(mac_addr_buf, (unsigned char *)LLADDR((struct sockaddr_dl *)(ifa)->ifa_addr), 6); @@ -973,10 +973,12 @@ static int32_t _sockaddr_in6_scope_id(struct sockaddr_in6* addr) continue; } +#ifndef __HAIKU__ /* skip if not running */ if ((ifa->ifa_flags & IFF_RUNNING) == 0) { continue; } +#endif struct sockaddr_in6* addr_in = (struct sockaddr_in6*)ifa->ifa_addr; -- cgit v1.1-32-gdbae