chiark / gitweb /
pathmtu/pathmtu.c: Disable `raw' strategy if we don't have getifaddrs(3).
authorMark Wooding <mdw@distorted.org.uk>
Sun, 17 Jun 2018 18:00:22 +0000 (19:00 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 5 Sep 2019 12:07:22 +0000 (13:07 +0100)
This isn't available on Android earlier than N.

configure.ac
pathmtu/pathmtu.c

index 887f81d31ee46cc512658bf0449727ff598f9234..e2e763ee8ed6cadc49ce9b85431acf2393f22d73 100644 (file)
@@ -63,6 +63,8 @@ case "$host_os" in
     ;;
 esac
 
+AC_CHECK_FUNCS([getifaddrs])
+
 AC_ARG_WITH([adns],
   AS_HELP_STRING([--with-adns],
                 [use ADNS library for background name resolution]),
index ad1f672c2ea0ad7e06a3b78c3b1e791317453c3b..9c5c829424da339ec9e72384b539d7fdac92d1e6 100644 (file)
 #include <netinet/icmp6.h>
 #include <netinet/udp.h>
 
-#include <net/if.h>
-#include <ifaddrs.h>
-#include <sys/ioctl.h>
+#ifdef HAVE_GETIFADDRS
+#  include <net/if.h>
+#  include <ifaddrs.h>
+#  include <sys/ioctl.h>
+#endif
 
 #include <mLib/alloc.h>
 #include <mLib/bits.h>
@@ -386,6 +388,8 @@ fail_0:
 
 /*----- Doing it the hard way ---------------------------------------------*/
 
+#ifdef HAVE_GETIFADDRS
+
 #if defined(linux) || defined(__OpenBSD__)
 #  define IPHDR_SANE
 #endif
@@ -794,6 +798,8 @@ static const struct probe_ops raw_ops = {
 #undef OPS_CHAIN
 #define OPS_CHAIN &raw_ops
 
+#endif
+
 /*----- Doing the job on Linux --------------------------------------------*/
 
 #if defined(linux)
@@ -963,12 +969,14 @@ int main(int argc, char *argv[])
 
 #define f_bogus 1u
 
+#ifdef HAVE_GETIFADDRS
   if ((rawicmp = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0 ||
       (rawudp = socket(PF_INET, SOCK_RAW, IPPROTO_UDP)) < 0)
     rawerr = errno;
   if ((rawicmp6 = socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0 ||
       (rawudp6 = socket(PF_INET6, SOCK_RAW, IPPROTO_RAW)) < 0)
     rawerr6 = errno;
+#endif
   if (setuid(getuid()))
     abort();