Skip to content

Commit

Permalink
socket: Haiku compilation fixes
Browse files Browse the repository at this point in the history
- link against libnetwork
- get_primary_mac_address similar to FreeBSD
  • Loading branch information
korli authored and nikias committed May 4, 2024
1 parent e61817a commit 1ee8d0a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 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>
#if defined (__APPLE__) || defined (__FreeBSD__)
#if defined (__APPLE__) || defined (__FreeBSD__) || defined (__HAIKU__)
#include <net/if_dl.h>
#endif
#ifdef __linux__
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 1ee8d0a

Please sign in to comment.