Kaynağa Gözat

Fix build when lacking getifaddrs lacking

Hugo Beauzée-Luyssen 9 yıl önce
ebeveyn
işleme
e4f39eaeea
2 değiştirilmiş dosya ile 16 ekleme ve 3 silme
  1. 2 2
      configure.ac
  2. 14 1
      src/netbios_ns.c

+ 2 - 2
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], 

+ 14 - 1
src/netbios_ns.c

@@ -59,7 +59,9 @@
 
 #ifndef _WIN32
 # include <sys/types.h>
-# include <ifaddrs.h>
+# ifdef HAVE_IFADDRS_H
+#  include <ifaddrs.h>
+# endif
 # include <net/if.h>
 #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;
@@ -286,6 +290,15 @@ static void netbios_ns_broadcast_packet(netbios_ns* ns, netbios_query* q)
 
 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];
     DWORD dwBytesReturned = 0;
     if (WSAIoctl(ns->socket, SIO_GET_INTERFACE_LIST, NULL, 0, (void*)infolist, sizeof(infolist), &dwBytesReturned, NULL, NULL) != 0)