Skip to content

Commit

Permalink
build: fix getifaddrs detection
Browse files Browse the repository at this point in the history
Before this was determined by the presence of a struct member, but for
android target, the NDK will provide the struct but not necessarily the
related functions.
  • Loading branch information
Psilokos authored and tguillem committed Oct 23, 2018
1 parent b96302a commit b9b10be
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion compat/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ typedef DWORD multicast_if;

#else

# if HAVE_IFADDRS
# if HAVE_IFADDRS_H
#include <ifaddrs.h>
typedef struct sockaddr_storage multicast_if;
# else
Expand Down
7 changes: 2 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,8 @@ AC_CHECK_TYPES([struct pollfd],,,
#endif
])


AC_CHECK_MEMBER([struct ifaddrs.ifa_addr],[
AC_DEFINE([HAVE_IFADDRS],[1],[Define to 1 if you have ifaddrs.ifa_addr function])],
[],[[#include <ifaddrs.h>]])

AC_CHECK_FUNCS([getifaddrs])
AC_CHECK_HEADERS([ifaddrs.h])

AC_SUBST([LIBSOCKET])

Expand Down
6 changes: 3 additions & 3 deletions src/mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extern void rr_print(const struct rr_entry *);
extern void rr_free(struct rr_entry *);

#ifndef _WIN32
#if HAVE_IFADDRS
#if HAVE_GETIFADDRS

static bool
mdns_is_interface_valuable(struct ifaddrs* ifa)
Expand Down Expand Up @@ -139,7 +139,7 @@ mdns_list_interfaces(multicast_if** pp_intfs, size_t* p_nb_intf, int ai_family)
*p_nb_intf = 1;
return (0);
}
#endif // HAVE_IFADDRS
#endif // HAVE_GETIFADDRS

#else // _WIN32

Expand Down Expand Up @@ -332,7 +332,7 @@ mdns_init(struct mdns_ctx **p_ctx, const char *addr, unsigned short port)
return mdns_destroy(ctx), (MDNS_NETERR);
}

#if defined(HAVE_IFADDRS) || defined(_WIN32)
#if defined(HAVE_GETIFADDRS) || defined(_WIN32)
if (setsockopt(ctx->conns[i].sock,
ctx->conns[i].family == AF_INET ? IPPROTO_IP : IPPROTO_IPV6,
ctx->conns[i].family == AF_INET ? IP_MULTICAST_IF : IPV6_MULTICAST_IF,
Expand Down

0 comments on commit b9b10be

Please sign in to comment.