[vlc-commits] contrib: microdns: fix Android ifaddrs detection

Thomas Guillem git at videolan.org
Tue Oct 23 14:54:04 CEST 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Oct 23 14:08:42 2018 +0200| [161c74fecc4a2b9503f56e7e9f790daa770ce82a] | committer: Thomas Guillem

contrib: microdns: fix Android ifaddrs detection

Fixes Android NDK 17+ build

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=161c74fecc4a2b9503f56e7e9f790daa770ce82a
---

 .../0001-build-fix-getifaddrs-detection.patch      | 79 ++++++++++++++++++++++
 .../0002-fix-dummy-mdns_list_interfaces.patch      | 33 +++++++++
 contrib/src/microdns/rules.mak                     |  2 +
 3 files changed, 114 insertions(+)

diff --git a/contrib/src/microdns/0001-build-fix-getifaddrs-detection.patch b/contrib/src/microdns/0001-build-fix-getifaddrs-detection.patch
new file mode 100644
index 0000000000..0b6d93c2c9
--- /dev/null
+++ b/contrib/src/microdns/0001-build-fix-getifaddrs-detection.patch
@@ -0,0 +1,79 @@
+From b9b10be3ea0e7ffe660747f35f11dc6b896883fc Mon Sep 17 00:00:00 2001
+From: Victorien Le Couviour--Tuffet <victorien.lecouviour.tuffet at gmail.com>
+Date: Tue, 11 Sep 2018 17:38:25 +0200
+Subject: [PATCH 1/2] build: fix getifaddrs detection
+
+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.
+---
+ compat/compat.h | 2 +-
+ configure.ac    | 7 ++-----
+ src/mdns.c      | 6 +++---
+ 3 files changed, 6 insertions(+), 9 deletions(-)
+
+diff --git a/compat/compat.h b/compat/compat.h
+index ef4103c..dd78134 100644
+--- a/compat/compat.h
++++ b/compat/compat.h
+@@ -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
+diff --git a/configure.ac b/configure.ac
+index 489e233..f0b3be2 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -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])
+ 
+diff --git a/src/mdns.c b/src/mdns.c
+index 55c5cb4..d3c29b1 100644
+--- a/src/mdns.c
++++ b/src/mdns.c
+@@ -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)
+@@ -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
+ 
+@@ -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,
+-- 
+2.19.1
+
diff --git a/contrib/src/microdns/0002-fix-dummy-mdns_list_interfaces.patch b/contrib/src/microdns/0002-fix-dummy-mdns_list_interfaces.patch
new file mode 100644
index 0000000000..3644df97fb
--- /dev/null
+++ b/contrib/src/microdns/0002-fix-dummy-mdns_list_interfaces.patch
@@ -0,0 +1,33 @@
+From f5a9f81eb7635fb3bb31a305e88cf02f0b9ec7b3 Mon Sep 17 00:00:00 2001
+From: Thomas Guillem <thomas at gllm.fr>
+Date: Tue, 23 Oct 2018 13:56:47 +0200
+Subject: [PATCH 2/2] fix dummy mdns_list_interfaces
+
+In case multicast_if is a valid struct and not a void *. This can happen when
+getifaddr headers are present but not the function.
+---
+ src/mdns.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/src/mdns.c b/src/mdns.c
+index d3c29b1..e499195 100644
+--- a/src/mdns.c
++++ b/src/mdns.c
+@@ -132,10 +132,11 @@ mdns_list_interfaces(multicast_if** pp_intfs, size_t* p_nb_intf, int ai_family)
+ static size_t
+ mdns_list_interfaces(multicast_if** pp_intfs, size_t* p_nb_intf, int ai_family)
+ {
+-        *pp_intfs = malloc(sizeof(**pp_intfs));
+-        if (*pp_intfs == NULL)
++        multicast_if *intfs;
++        *pp_intfs = intfs = malloc(sizeof(*intfs));
++        if (intfs == NULL)
+                 return (MDNS_ERROR);
+-        **pp_intfs = NULL;
++        memset(intfs, 0, sizeof(*intfs));
+         *p_nb_intf = 1;
+         return (0);
+ }
+-- 
+2.19.1
+
diff --git a/contrib/src/microdns/rules.mak b/contrib/src/microdns/rules.mak
index dcc5a7f423..e6a766d844 100644
--- a/contrib/src/microdns/rules.mak
+++ b/contrib/src/microdns/rules.mak
@@ -19,6 +19,8 @@ $(TARBALLS)/microdns-$(LIBMICRODNS_VERSION).tar.gz:
 
 microdns: microdns-$(LIBMICRODNS_VERSION).tar.gz .sum-microdns
 	$(UNPACK)
+	$(APPLY) $(SRC)/microdns/0001-build-fix-getifaddrs-detection.patch
+	$(APPLY) $(SRC)/microdns/0002-fix-dummy-mdns_list_interfaces.patch
 	$(MOVE)
 
 .microdns: microdns



More information about the vlc-commits mailing list