Skip to content

Commit fc24f8b

Browse files
jbkempfchouquette
authored andcommitted
Detect ifaddrs.h header and ifaddrs addr
And don't only disable that for Android Signed-off-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
1 parent 0351072 commit fc24f8b

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

compat/compat.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ enum {
3939
# include <errno.h>
4040
# include <net/if.h>
4141
# include <poll.h>
42-
#ifndef __ANDROID__
43-
# include <ifaddrs.h>
44-
#endif
4542

4643
extern struct timeval os_deadline;
4744

configure.ac

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ AC_LINK_IFELSE([
245245

246246
LIBS=${LIBS_SAVE}
247247

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

249253
AC_SUBST([LIBSOCKET])
250254

src/mdns.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ struct mdns_svc {
4949
};
5050

5151
#ifndef _WIN32
52-
# ifndef __ANDROID__
52+
# if HAVE_IFADDRS
53+
#include <ifaddrs.h>
5354
typedef struct sockaddr_storage multicast_if;
5455
# else
5556
typedef void* multicast_if;
@@ -83,7 +84,7 @@ extern void rr_print(const struct rr_entry *);
8384
extern void rr_free(struct rr_entry *);
8485

8586
#ifndef _WIN32
86-
#ifndef __ANDROID__
87+
#if HAVE_IFADDRS
8788

8889
static bool
8990
mdns_is_interface_valuable(struct ifaddrs* ifa)
@@ -142,8 +143,9 @@ mdns_list_interfaces(multicast_if** pp_intfs, int ai_family)
142143
**pp_intfs = NULL;
143144
return 1;
144145
}
145-
#endif // __ANDROID__
146-
#else
146+
#endif // HAVE_IFADDRS
147+
148+
#else // _WIN32
147149

148150
static bool
149151
mdns_is_interface_valuable(IP_ADAPTER_ADDRESSES *intf)
@@ -210,7 +212,6 @@ mdns_list_interfaces(multicast_if** pp_intfs, int ai_family)
210212
}
211213
return (nb_intf);
212214
}
213-
214215
#endif
215216

216217
static int
@@ -321,7 +322,7 @@ mdns_init(struct mdns_ctx **p_ctx, const char *addr, unsigned short port)
321322
return mdns_destroy(ctx), (MDNS_NETERR);
322323
}
323324

324-
#ifndef __ANDROID__
325+
#if HAVE_IFADDRS
325326
if (setsockopt(ctx->conns[i].sock,
326327
ctx->conns[i].family == AF_INET ? IPPROTO_IP : IPPROTO_IPV6,
327328
ctx->conns[i].family == AF_INET ? IP_MULTICAST_IF : IPV6_MULTICAST_IF,

0 commit comments

Comments
 (0)