From e4f39eaeeaad5841653bbd6a36c40a27a6565682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Tue, 12 Jul 2016 10:51:12 +0200 Subject: [PATCH] Fix build when lacking getifaddrs lacking --- configure.ac | 4 ++-- src/netbios_ns.c | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 351cdad..56ea1d7 100644 --- a/configure.ac +++ b/configure.ac @@ -105,9 +105,9 @@ AC_CHECK_DECLS([CLOCK_MONOTONIC],,,[ AC_REPLACE_FUNCS([strlcpy]) AC_REPLACE_FUNCS([strndup]) AC_REPLACE_FUNCS([clock_gettime]) -AC_CHECK_FUNCS([pipe _pipe]) +AC_CHECK_FUNCS([pipe _pipe getifaddrs]) -AC_CHECK_HEADERS([bsd/string.h langinfo.h alloca.h sys/queue.h arpa/inet.h sys/socket.h]) +AC_CHECK_HEADERS([bsd/string.h langinfo.h alloca.h sys/queue.h arpa/inet.h sys/socket.h ifaddrs.h]) ## Configure random device path AC_ARG_WITH([urandom], diff --git a/src/netbios_ns.c b/src/netbios_ns.c index 4fb74b2..e0d3796 100644 --- a/src/netbios_ns.c +++ b/src/netbios_ns.c @@ -59,7 +59,9 @@ #ifndef _WIN32 # include -# include +# ifdef HAVE_IFADDRS_H +# include +# endif # include #endif @@ -262,6 +264,8 @@ static ssize_t netbios_ns_send_packet(netbios_ns* ns, netbios_query* q, uint32_t #ifndef _WIN32 +#ifdef HAVE_GETIFADDRS + static void netbios_ns_broadcast_packet(netbios_ns* ns, netbios_query* q) { struct ifaddrs *addrs; @@ -284,6 +288,15 @@ static void netbios_ns_broadcast_packet(netbios_ns* ns, netbios_query* q) #else +static void netbios_ns_broadcast_packet(netbios_ns* ns, netbios_query* q) +{ + netbios_ns_send_packet(ns, q, INADDR_BROADCAST); +} + +#endif + +#else + static void netbios_ns_broadcast_packet(netbios_ns* ns, netbios_query* q) { INTERFACE_INFO infolist[16];