]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Configure for ether_ntohost() as libpcap does it for ether_hostton().
authorGuy Harris <[email protected]>
Mon, 22 Jan 2018 10:34:31 +0000 (02:34 -0800)
committerGuy Harris <[email protected]>
Mon, 22 Jan 2018 10:34:31 +0000 (02:34 -0800)
Check for the same header files that declare it, and handle the results
of those checks in a similar fashion.

addrtoname.c
cmakeconfig.h.in
config.h.in
configure
configure.ac

index 621021f188547e13c5069943fe39084dfd760cdd..f4d05e97b5a1ccfe0aa6b4a616dc03c6e10fe7da 100644 (file)
 #define HTONS(x)       (x) = htons(x)
 #endif
 
-#ifdef USE_ETHER_NTOHOST
-#ifdef HAVE_NETINET_IF_ETHER_H
-struct mbuf;           /* Squelch compiler warnings on some platforms for */
-struct rtentry;                /* declarations in <net/if.h> */
-#include <net/if.h>    /* for "struct ifnet" in "struct arpcom" on Solaris */
-#include <netinet/if_ether.h>
-#endif /* HAVE_NETINET_IF_ETHER_H */
-#ifdef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
-#include <netinet/ether.h>
-#endif /* NETINET_ETHER_H_DECLARES_ETHER_NTOHOST */
-
-#if !defined(HAVE_DECL_ETHER_NTOHOST) || !HAVE_DECL_ETHER_NTOHOST
-#ifndef HAVE_STRUCT_ETHER_ADDR
-struct ether_addr {
-       unsigned char ether_addr_octet[6];
-};
-#endif
-extern int ether_ntohost(char *, const struct ether_addr *);
-#endif
-
-#endif /* USE_ETHER_NTOHOST */
+#ifndef _WIN32
+  #ifdef USE_ETHER_NTOHOST
+    #if defined(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST)
+      /*
+       * OK, just include <net/ethernet.h>.
+       */
+      #include <net/ethernet.h>
+    #elif defined(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST)
+      /*
+       * OK, just include <netinet/ether.h>
+       */
+      #include <netinet/ether.h>
+    #elif defined(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST)
+      /*
+       * OK, just include <sys/ethernet.h>
+       */
+      #include <sys/ethernet.h>
+    #elif defined(ARPA_INET_H_DECLARES_ETHER_NTOHOST)
+      /*
+       * OK, just include <arpa/inet.h>
+       */
+      #include <arpa/inet.h>
+    #elif defined(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST)
+      /*
+       * OK, include <netinet/if_ether.h>, after all the other stuff we
+       * need to include or define for its benefit.
+       */
+      #define NEED_NETINET_IF_ETHER_H
+    #else
+      /*
+       * We'll have to declare it ourselves.
+       * If <netinet/if_ether.h> defines struct ether_addr, include
+       * it.  Otherwise, define it ourselves.
+       */
+      #ifdef HAVE_STRUCT_ETHER_ADDR
+        #define NEED_NETINET_IF_ETHER_H
+      #else /* HAVE_STRUCT_ETHER_ADDR */
+       struct ether_addr {
+               unsigned char ether_addr_octet[6];
+       };
+      #endif /* HAVE_STRUCT_ETHER_ADDR */
+    #endif /* what declares ether_ntohost() */
+
+    #ifdef NEED_NETINET_IF_ETHER_H
+      #include <net/if.h>      /* Needed on some platforms */
+      #include <netinet/in.h>  /* Needed on some platforms */
+      #include <netinet/if_ether.h>
+    #endif /* NEED_NETINET_IF_ETHER_H */
+
+    #ifndef HAVE_DECL_ETHER_NTOHOST
+      /*
+       * No header declares it, so declare it ourselves.
+       */
+      extern int ether_ntohost(char *, const struct ether_addr *);
+    #endif /* !defined(HAVE_DECL_ETHER_NTOHOST) */
+  #endif /* USER_ETHER_NTOHOST */
+#endif /* _WIN32 */
 
 #include <pcap.h>
 #include <pcap-namedb.h>
index 3346ad69b6923136b177646e61f17c9e1e02d0d9..8c5168d14274334fae4501368e50b741b729253d 100644 (file)
@@ -1,5 +1,8 @@
 /* cmakeconfig.h.in */
 
+/* Define to 1 if arpa/inet.h declares `ether_ntohost' */
+#cmakedefine ARPA_INET_H_DECLARES_ETHER_NTOHOST 1
+
 /* define if you want to build the possibly-buggy SMB printer */
 #cmakedefine ENABLE_SMB 1
 
 /* Define to 1 if you have the <netdnet/dn.h> header file. */
 #cmakedefine HAVE_NETDNET_DN_H 1
 
-/* Define to 1 if you have the <netinet/ether.h> header file. */
-#cmakedefine HAVE_NETINET_ETHER_H 1
-
-/* Define to 1 if you have the <netinet/if_ether.h> header file. */
-#cmakedefine HAVE_NETINET_IF_ETHER_H 1
-
 /* Define to 1 if you have the <net/if_pflog.h> header file. */
 #cmakedefine HAVE_NET_IF_PFLOG_H 1
 
 /* Define to 1 if netinet/if_ether.h declares `ether_ntohost' */
 #cmakedefine NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST 1
 
+/* Define to 1 if net/ethernet.h declares `ether_ntohost' */
+#cmakedefine NET_ETHERNET_H_DECLARES_ETHER_NTOHOST 1
+
 /* Define to the address where bug reports for this package should be sent. */
 #cmakedefine PACKAGE_BUGREPORT ""
 
 /* Define to 1 if you have the ANSI C header files. */
 #cmakedefine STDC_HEADERS 1
 
+/* Define to 1 if sys/ethernet.h declares `ether_ntohost' */
+#cmakedefine SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST 1
+
 /* define if you have ether_ntohost() and it works */
 #cmakedefine USE_ETHER_NTOHOST 1
 
index 43260010e04ea82a37af2a19bfc967dbe8d97e49..db43da3436ad17f2e660c98c5654f5243fbf8544 100644 (file)
@@ -1,5 +1,8 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* Define to 1 if arpa/inet.h declares `ether_ntohost' */
+#undef ARPA_INET_H_DECLARES_ETHER_NTOHOST
+
 /* define if you want to build the possibly-buggy SMB printer */
 #undef ENABLE_SMB
 
@@ -24,8 +27,7 @@
 /* Casper support available */
 #undef HAVE_CASPER
 
-/* Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
-   don't. */
+/* Define to 1 if you have the declaration of `ether_ntohost' */
 #undef HAVE_DECL_ETHER_NTOHOST
 
 /* define if you have the dnet_htoa function */
 /* Define to 1 if you have the <netdnet/dn.h> header file. */
 #undef HAVE_NETDNET_DN_H
 
-/* Define to 1 if you have the <netinet/ether.h> header file. */
-#undef HAVE_NETINET_ETHER_H
-
-/* Define to 1 if you have the <netinet/if_ether.h> header file. */
-#undef HAVE_NETINET_IF_ETHER_H
-
 /* Define to 1 if you have the <net/if_pflog.h> header file. */
 #undef HAVE_NET_IF_PFLOG_H
 
 /* Define to 1 if netinet/if_ether.h declares `ether_ntohost' */
 #undef NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST
 
+/* Define to 1 if net/ethernet.h declares `ether_ntohost' */
+#undef NET_ETHERNET_H_DECLARES_ETHER_NTOHOST
+
 /* Define to the address where bug reports for this package should be sent. */
 #undef PACKAGE_BUGREPORT
 
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
+/* Define to 1 if sys/ethernet.h declares `ether_ntohost' */
+#undef SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST
+
 /* define if you have ether_ntohost() and it works */
 #undef USE_ETHER_NTOHOST
 
index 452372d81d96d2f1ffed65ceddf0a0122812ff1a..39325a52025489b45baff28c787f8fc7bf470d92 100755 (executable)
--- a/configure
+++ b/configure
@@ -5713,11 +5713,12 @@ fi
 #
 # You are in a twisty little maze of UN*Xes, all different.
 # Some might not have ether_ntohost().
-# Some might have it, but not declare it in any header file.
-# Some might have it, but declare it in <netinet/if_ether.h>.
-# Some might have it, but declare it in <netinet/ether.h>
-# (And some might have it but document it as something declared in
-# <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
+# Some might have it and declare it in <net/ethernet.h>.
+# Some might have it and declare it in <netinet/ether.h>
+# Some might have it and declare it in <sys/ethernet.h>.
+# Some might have it and declare it in <arpa/inet.h>.
+# Some might have it and declare it in <netinet/if_ether.h>.
+# Some might have it and not declare it in any header file.
 #
 # Before you is a C compiler.
 #
@@ -5781,46 +5782,46 @@ done
 if test "$ac_cv_func_ether_ntohost" = yes -a \
     "$ac_cv_buggy_ether_ntohost" = "no"; then
        #
-       # OK, we have ether_ntohost().  Do we have <netinet/if_ether.h>?
+       # OK, we have ether_ntohost().  Is it declared in <net/ethernet.h>?
        #
-       for ac_header in netinet/if_ether.h
-do :
-  ac_fn_c_check_header_compile "$LINENO" "netinet/if_ether.h" "ac_cv_header_netinet_if_ether_h" "
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-struct mbuf;
-struct rtentry;
-#include <net/if.h>
+       # This test fails if we don't have <net/ethernet.h> or if we do
+       # but it doesn't declare ether_ntohost().
+       #
+       ac_fn_c_check_decl "$LINENO" "ether_ntohost" "ac_cv_have_decl_ether_ntohost" "
+#include <net/ethernet.h>
+
 "
-if test "x$ac_cv_header_netinet_if_ether_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_NETINET_IF_ETHER_H 1
-_ACEOF
+if test "x$ac_cv_have_decl_ether_ntohost" = xyes; then :
 
-fi
 
-done
+$as_echo "#define NET_ETHERNET_H_DECLARES_ETHER_NTOHOST /**/" >>confdefs.h
+
 
-       if test "$ac_cv_header_netinet_if_ether_h" = yes; then
+fi
+
+       #
+       # Did that succeed?
+       #
+       if test "$ac_cv_have_decl_ether_ntohost" != yes; then
                #
-               # Yes.  Does it declare ether_ntohost()?
+               # No, how about <netinet/ether.h>, as on Linux?
+               #
+               # This test fails if we don't have <netinet/ether.h>
+               # or if we do but it doesn't declare ether_ntohost().
+               #
+               # Unset ac_cv_have_decl_ether_ntohost so we don't
+               # treat the previous failure as a cached value and
+               # suppress the next test.
                #
+               unset ac_cv_have_decl_ether_ntohost
                ac_fn_c_check_decl "$LINENO" "ether_ntohost" "ac_cv_have_decl_ether_ntohost" "
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-struct mbuf;
-struct rtentry;
-#include <net/if.h>
-#include <netinet/if_ether.h>
+#include <netinet/ether.h>
 
 "
 if test "x$ac_cv_have_decl_ether_ntohost" = xyes; then :
 
 
-$as_echo "#define NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST /**/" >>confdefs.h
+$as_echo "#define NETINET_ETHER_H_DECLARES_ETHER_NTOHOST /**/" >>confdefs.h
 
 
 fi
        #
        if test "$ac_cv_have_decl_ether_ntohost" != yes; then
                #
-               # No, how about <netinet/ether.h>, as on Linux?
+               # No, how about <sys/ethernet.h>, as on Solaris 10
+               # and later?
                #
-               for ac_header in netinet/ether.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "netinet/ether.h" "ac_cv_header_netinet_ether_h" "$ac_includes_default"
-if test "x$ac_cv_header_netinet_ether_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_NETINET_ETHER_H 1
-_ACEOF
+               # This test fails if we don't have <sys/ethernet.h>
+               # or if we do but it doesn't declare ether_ntohost().
+               #
+               # Unset ac_cv_have_decl_ether_ntohost so we don't
+               # treat the previous failure as a cached value and
+               # suppress the next test.
+               #
+               unset ac_cv_have_decl_ether_ntohost
+               ac_fn_c_check_decl "$LINENO" "ether_ntohost" "ac_cv_have_decl_ether_ntohost" "
+#include <sys/ethernet.h>
 
-fi
+"
+if test "x$ac_cv_have_decl_ether_ntohost" = xyes; then :
 
-done
 
-               if test "$ac_cv_header_netinet_ether_h" = yes; then
-                       #
-                       # We have it - does it declare ether_ntohost()?
-                       # Unset ac_cv_have_decl_ether_ntohost so we don't
-                       # treat the previous failure as a cached value and
-                       # suppress the next test.
-                       #
-                       unset ac_cv_have_decl_ether_ntohost
-                       ac_fn_c_check_decl "$LINENO" "ether_ntohost" "ac_cv_have_decl_ether_ntohost" "
-#include <netinet/ether.h>
+$as_echo "#define SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST /**/" >>confdefs.h
+
+
+fi
+
+       fi
+       #
+       # Did that succeed?
+       #
+       if test "$ac_cv_have_decl_ether_ntohost" != yes; then
+               #
+               # No, how about <arpa/inet.h>, as in AIX?
+               #
+               # This test fails if we don't have <arpa/inet.h>
+               # (if we have ether_ntohost(), we should have
+               # networking, and if we have networking, we should
+               # have <arapa/inet.h>) or if we do but it doesn't
+               # declare ether_ntohost().
+               #
+               # Unset ac_cv_have_decl_ether_ntohost so we don't
+               # treat the previous failure as a cached value and
+               # suppress the next test.
+               #
+               unset ac_cv_have_decl_ether_ntohost
+               ac_fn_c_check_decl "$LINENO" "ether_ntohost" "ac_cv_have_decl_ether_ntohost" "
+#include <arpa/inet.h>
 
 "
 if test "x$ac_cv_have_decl_ether_ntohost" = xyes; then :
 
 
-$as_echo "#define NETINET_ETHER_H_DECLARES_ETHER_NTOHOST /**/" >>confdefs.h
+$as_echo "#define ARPA_INET_H_DECLARES_ETHER_NTOHOST /**/" >>confdefs.h
 
 
 fi
 
-               fi
        fi
        #
-       # Is ether_ntohost() declared?
+       # Did that succeed?
        #
        if test "$ac_cv_have_decl_ether_ntohost" != yes; then
                #
-               # No, we'll have to declare it ourselves.
-               # Do we have "struct ether_addr"?
+               # No, how about <netinet/if_ether.h>?
+               # On some platforms, it requires <net/if.h> and
+               # <netinet/in.h>, and we always include it with
+               # both of them, so test it with both of them.
                #
-               ac_fn_c_check_type "$LINENO" "struct ether_addr" "ac_cv_type_struct_ether_addr" "
+               # This test fails if we don't have <netinet/if_ether.h>
+               # and the headers we include before it, or if we do but
+               # <netinet/if_ether.h> doesn't declare ether_hostton().
+               #
+               # Unset ac_cv_have_decl_ether_ntohost so we don't
+               # treat the previous failure as a cached value and
+               # suppress the next test.
+               #
+               unset ac_cv_have_decl_ether_ntohost
+               ac_fn_c_check_decl "$LINENO" "ether_ntohost" "ac_cv_have_decl_ether_ntohost" "
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-struct mbuf;
-struct rtentry;
 #include <net/if.h>
+#include <netinet/in.h>
 #include <netinet/if_ether.h>
 
 "
-if test "x$ac_cv_type_struct_ether_addr" = xyes; then :
+if test "x$ac_cv_have_decl_ether_ntohost" = xyes; then :
 
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_ETHER_ADDR 1
-_ACEOF
+
+$as_echo "#define NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST /**/" >>confdefs.h
 
 
 fi
 
+       fi
+       #
+       # After all that, is ether_ntohost() declared?
+       #
+       if test "$ac_cv_have_decl_ether_ntohost" = yes; then
+               #
+               # Yes.
+               #
 
-$as_echo "#define HAVE_DECL_ETHER_NTOHOST 0" >>confdefs.h
+$as_echo "#define HAVE_DECL_ETHER_NTOHOST 1" >>confdefs.h
 
        else
+               #
+               # No, we'll have to declare it ourselves.
+               # Do we have "struct ether_addr" if we include
+               # <netinet/if_ether.h>?
+               #
+               ac_fn_c_check_type "$LINENO" "struct ether_addr" "ac_cv_type_struct_ether_addr" "
+                       #include <sys/types.h>
+                       #include <sys/socket.h>
+                       #include <net/if.h>
+                       #include <netinet/in.h>
+                       #include <netinet/if_ether.h>
 
-$as_echo "#define HAVE_DECL_ETHER_NTOHOST 1" >>confdefs.h
+"
+if test "x$ac_cv_type_struct_ether_addr" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_ETHER_ADDR 1
+_ACEOF
+
+
+fi
 
        fi
 fi
index d47b2fdcf7713f4ab76f3742b122f6ab7917f4da..bc74568a8194a4f908e592bf81d7f970673d1f0a 100644 (file)
@@ -434,11 +434,12 @@ AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
 #
 # You are in a twisty little maze of UN*Xes, all different.
 # Some might not have ether_ntohost().
-# Some might have it, but not declare it in any header file.
-# Some might have it, but declare it in <netinet/if_ether.h>.
-# Some might have it, but declare it in <netinet/ether.h>
-# (And some might have it but document it as something declared in
-# <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
+# Some might have it and declare it in <net/ethernet.h>.
+# Some might have it and declare it in <netinet/ether.h>
+# Some might have it and declare it in <sys/ethernet.h>.
+# Some might have it and declare it in <arpa/inet.h>.
+# Some might have it and declare it in <netinet/if_ether.h>.
+# Some might have it and not declare it in any header file.
 #
 # Before you is a C compiler.
 #
@@ -470,33 +471,41 @@ AC_CHECK_FUNCS(ether_ntohost, [
 if test "$ac_cv_func_ether_ntohost" = yes -a \
     "$ac_cv_buggy_ether_ntohost" = "no"; then
        #
-       # OK, we have ether_ntohost().  Do we have <netinet/if_ether.h>?
+       # OK, we have ether_ntohost().  Is it declared in <net/ethernet.h>?
        #
-       AC_CHECK_HEADERS(netinet/if_ether.h, , , [
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-struct mbuf;
-struct rtentry;
-#include <net/if.h>])
-       if test "$ac_cv_header_netinet_if_ether_h" = yes; then
+       # This test fails if we don't have <net/ethernet.h> or if we do
+       # but it doesn't declare ether_ntohost().
+       #
+       AC_CHECK_DECL(ether_ntohost,
+           [
+               AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
+                   [Define to 1 if net/ethernet.h declares `ether_ntohost'])
+           ],,
+           [
+#include <net/ethernet.h>
+           ])
+       #
+       # Did that succeed?
+       #
+       if test "$ac_cv_have_decl_ether_ntohost" != yes; then
                #
-               # Yes.  Does it declare ether_ntohost()?
+               # No, how about <netinet/ether.h>, as on Linux?
                #
+               # This test fails if we don't have <netinet/ether.h>
+               # or if we do but it doesn't declare ether_ntohost().
+               #
+               # Unset ac_cv_have_decl_ether_ntohost so we don't
+               # treat the previous failure as a cached value and
+               # suppress the next test.
+               #
+               unset ac_cv_have_decl_ether_ntohost
                AC_CHECK_DECL(ether_ntohost,
                    [
-                       AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
-                           [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
+                       AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
+                           [Define to 1 if netinet/ether.h declares `ether_ntohost'])
                    ],,
                    [
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-struct mbuf;
-struct rtentry;
-#include <net/if.h>
-#include <netinet/if_ether.h>
+#include <netinet/ether.h>
                    ])
        fi
        #
@@ -504,53 +513,108 @@ struct rtentry;
        #
        if test "$ac_cv_have_decl_ether_ntohost" != yes; then
                #
-               # No, how about <netinet/ether.h>, as on Linux?
+               # No, how about <sys/ethernet.h>, as on Solaris 10
+               # and later?
                #
-               AC_CHECK_HEADERS(netinet/ether.h)
-               if test "$ac_cv_header_netinet_ether_h" = yes; then
-                       #
-                       # We have it - does it declare ether_ntohost()?
-                       # Unset ac_cv_have_decl_ether_ntohost so we don't
-                       # treat the previous failure as a cached value and
-                       # suppress the next test.
-                       #
-                       unset ac_cv_have_decl_ether_ntohost
-                       AC_CHECK_DECL(ether_ntohost,
-                           [
-                               AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
-                                   [Define to 1 if netinet/ether.h declares `ether_ntohost'])
-                           ],,
-                           [
-#include <netinet/ether.h>
-                           ])
-               fi
+               # This test fails if we don't have <sys/ethernet.h>
+               # or if we do but it doesn't declare ether_ntohost().
+               #
+               # Unset ac_cv_have_decl_ether_ntohost so we don't
+               # treat the previous failure as a cached value and
+               # suppress the next test.
+               #
+               unset ac_cv_have_decl_ether_ntohost
+               AC_CHECK_DECL(ether_ntohost,
+                   [
+                       AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
+                           [Define to 1 if sys/ethernet.h declares `ether_ntohost'])
+                   ],,
+                   [
+#include <sys/ethernet.h>
+                   ])
        fi
        #
-       # Is ether_ntohost() declared?
+       # Did that succeed?
        #
        if test "$ac_cv_have_decl_ether_ntohost" != yes; then
                #
-               # No, we'll have to declare it ourselves.
-               # Do we have "struct ether_addr"?
+               # No, how about <arpa/inet.h>, as in AIX?
                #
-               AC_CHECK_TYPES(struct ether_addr,,,
+               # This test fails if we don't have <arpa/inet.h>
+               # (if we have ether_ntohost(), we should have
+               # networking, and if we have networking, we should
+               # have <arapa/inet.h>) or if we do but it doesn't
+               # declare ether_ntohost().
+               #
+               # Unset ac_cv_have_decl_ether_ntohost so we don't
+               # treat the previous failure as a cached value and
+               # suppress the next test.
+               #
+               unset ac_cv_have_decl_ether_ntohost
+               AC_CHECK_DECL(ether_ntohost,
+                   [
+                       AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_NTOHOST,,
+                           [Define to 1 if arpa/inet.h declares `ether_ntohost'])
+                   ],,
+                   [
+#include <arpa/inet.h>
+                   ])
+       fi
+       #
+       # Did that succeed?
+       #
+       if test "$ac_cv_have_decl_ether_ntohost" != yes; then
+               #
+               # No, how about <netinet/if_ether.h>?
+               # On some platforms, it requires <net/if.h> and
+               # <netinet/in.h>, and we always include it with
+               # both of them, so test it with both of them.
+               #
+               # This test fails if we don't have <netinet/if_ether.h>
+               # and the headers we include before it, or if we do but
+               # <netinet/if_ether.h> doesn't declare ether_hostton().
+               #
+               # Unset ac_cv_have_decl_ether_ntohost so we don't
+               # treat the previous failure as a cached value and
+               # suppress the next test.
+               #
+               unset ac_cv_have_decl_ether_ntohost
+               AC_CHECK_DECL(ether_ntohost,
+                   [
+                       AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
+                           [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
+                   ],,
                    [
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-struct mbuf;
-struct rtentry;
 #include <net/if.h>
+#include <netinet/in.h>
 #include <netinet/if_ether.h>
                    ])
-               AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 0,
-                   [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
-don't.])
-       else
+       fi
+       #
+       # After all that, is ether_ntohost() declared?
+       #
+       if test "$ac_cv_have_decl_ether_ntohost" = yes; then
+               #
+               # Yes.
+               #
                AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
-                   [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
-don't.])
+                   [Define to 1 if you have the declaration of `ether_ntohost'])
+       else
+               #
+               # No, we'll have to declare it ourselves.
+               # Do we have "struct ether_addr" if we include
+               # <netinet/if_ether.h>?
+               #
+               AC_CHECK_TYPES(struct ether_addr,,,
+                   [
+                       #include <sys/types.h>
+                       #include <sys/socket.h>
+                       #include <net/if.h>
+                       #include <netinet/in.h>
+                       #include <netinet/if_ether.h>
+                   ])
        fi
 fi