]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Do the same sort of checks whether ether_ntohost() is declared that we
authorguy <guy>
Sun, 27 Mar 2005 22:38:09 +0000 (22:38 +0000)
committerguy <guy>
Sun, 27 Mar 2005 22:38:09 +0000 (22:38 +0000)
do in libpcap for ether_hostton().  Include <netinet/ether.h> only if it
declares ether_ntohost().  If nothing declares it, declare it ourselves,
as we do in libpcap.

Don't cast the second argument to ether_ntohost() to a const pointer, as
some systems don't modify it but don't declare that argument as a const
pointer.  (This is similar to what we do on libpvap for
ether_hostton().)

Fix indentation.

addrtoname.c
config.h.in
configure
configure.in

index e6907254078f9bcd97d4e053e95544ca9c3ad688..13d3997dfa69445946f56f910d2112c4e9db20be 100644 (file)
@@ -23,7 +23,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.107 2005-03-08 08:52:38 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108 2005-03-27 22:38:09 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -39,11 +39,15 @@ 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 HAVE_NETINET_ETHER_H
-#include <netinet/ether.h>  /* ether_ntohost on linux */
-#endif /* HAVE_NETINET_ETHER_H */
+#ifdef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
+#include <netinet/ether.h>
+#endif /* NETINET_ETHER_H_DECLARES_ETHER_NTOHOST */
 #endif /* USE_ETHER_NTOHOST */
 
+#if !defined(HAVE_DECL_ETHER_NTOHOST) || !HAVE_DECL_ETHER_NTOHOST
+extern int ether_ntohost(char *, const struct ether_addr *);
+#endif
+
 #include <pcap.h>
 #include <pcap-namedb.h>
 #include <signal.h>
@@ -459,18 +463,25 @@ etheraddr_string(register const u_char *ep)
 #ifdef USE_ETHER_NTOHOST
        if (!nflag) {
                char buf2[128];
-               if (ether_ntohost(buf2, (const struct ether_addr *)ep) == 0) {
+
+               /*
+                * We don't cast it to "const struct ether_addr *"
+                * because some systems don't modify the Ethernet
+                * address but fail to declare the second argument
+                * as a "const" pointer.
+                */
+               if (ether_ntohost(buf2, (struct ether_addr *)ep) == 0) {
                        tp->e_name = strdup(buf2);
                        return (tp->e_name);
                }
        }
 #endif
        cp = buf;
-        *cp++ = hex[*ep >> 4 ];
+       *cp++ = hex[*ep >> 4 ];
        *cp++ = hex[*ep++ & 0xf];
        for (i = 5; (int)--i >= 0;) {
                *cp++ = ':';
-                *cp++ = hex[*ep >> 4 ];
+               *cp++ = hex[*ep >> 4 ];
                *cp++ = hex[*ep++ & 0xf];
        }
        *cp = '\0';
@@ -586,7 +597,7 @@ isonsap_string(const u_char *nsap, register u_int nsap_length)
        register char *cp;
        register struct enamemem *tp;
 
-        if (nsap_length < 1 || nsap_length > ISONSAP_MAX_LENGTH)
+       if (nsap_length < 1 || nsap_length > ISONSAP_MAX_LENGTH)
                error("isonsap_string: illegal length");
 
        tp = lookup_nsap(nsap);
@@ -601,8 +612,8 @@ isonsap_string(const u_char *nsap, register u_int nsap_length)
                *cp++ = hex[*nsap >> 4];
                *cp++ = hex[*nsap++ & 0xf];
                if (((nsap_idx & 1) == 0) &&
-                     (nsap_idx + 1 < nsap_length)) {
-                       *cp++ = '.';
+                    (nsap_idx + 1 < nsap_length)) {
+                       *cp++ = '.';
                }
        }
        *cp = '\0';
@@ -829,9 +840,16 @@ init_etherarray(void)
                        continue;
 
 #ifdef USE_ETHER_NTOHOST
-                /* Use yp/nis version of name if available */
-                if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) {
-                        tp->e_name = strdup(name);
+               /*
+                * Use YP/NIS version of name if available.
+                *
+                * We don't cast it to "const struct ether_addr *"
+                * because some systems don't modify the Ethernet
+                * address but fail to declare the second argument
+                * as a "const" pointer.
+                */
+               if (ether_ntohost(name, (struct ether_addr *)el->addr) == 0) {
+                       tp->e_name = strdup(name);
                        continue;
                }
 #endif
index 1e28869ada93b27a3fa8f1d0ca51b4aea51de587..bce43a05ebb6c69e3f289d1c3c4cd0ab4c73297c 100644 (file)
 /* Define to 1 if you have the `bpf_dump' function. */
 #undef HAVE_BPF_DUMP
 
+/* Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
+   don't. */
+#undef HAVE_DECL_ETHER_NTOHOST
+
 /* Define to 1 if you have the `ether_ntohost' function. */
 #undef HAVE_ETHER_NTOHOST
 
 /* define if your compiler has __attribute__ */
 #undef HAVE___ATTRIBUTE__
 
+/* Define to 1 if netinet/ether.h declares `ether_ntohost' */
+#undef NETINET_ETHER_H_DECLARES_ETHER_ntohost
+
+/* Define to 1 if netinet/if_ether.h declares `ether_ntohost' */
+#undef NETINET_IF_ETHER_H_DECLARES_ETHER_ntohost
+
 /* Define to the address where bug reports for this package should be sent. */
 #undef PACKAGE_BUGREPORT
 
index 66654f3f564f54b78d790976727f555a47aab0a0..feed5ba9e1c07adb38c7801947415d71892e685e 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.183 .
+# From configure.in Revision: 1.184 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.57.
 #
@@ -3322,6 +3322,76 @@ fi
 
 done
 
+if test "$ac_cv_header_netinet_if_ether_h" != yes; then
+       #
+       # The simple test didn't work.
+       # Do we need to include <net/if.h> first?
+       # Unset ac_cv_header_netinet_if_ether_h so we don't
+       # treat the previous failure as a cached value and
+       # suppress the next test.
+       #
+       { echo "$as_me:$LINENO: Rechecking with some additional includes" >&5
+echo "$as_me: Rechecking with some additional includes" >&6;}
+       unset ac_cv_header_netinet_if_ether_h
+
+for ac_header in netinet/if_ether.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+struct mbuf;
+struct rtentry;
+#include <net/if.h>
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+fi
+
 echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
 if test "${ac_cv_header_time+set}" = set; then
@@ -6914,6 +6984,18 @@ fi
 done
 
 
+#
+# 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.)
+#
+# Before you is a C compiler.
+#
+
 for ac_func in ether_ntohost
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
@@ -7062,6 +7144,326 @@ _ACEOF
 fi
 done
 
+if test "$ac_cv_func_ether_ntohost" = yes; then
+       #
+       # OK, we have ether_ntohost().  Do we have <netinet/if_ether.h>?
+       #
+       if test "$ac_cv_header_netinet_if_ether_h" = yes; then
+               #
+               # Yes.  Does it declare ether_ntohost()?
+               #
+               echo "$as_me:$LINENO: checking whether ether_ntohost is declared" >&5
+echo $ECHO_N "checking whether ether_ntohost is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_ether_ntohost+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+struct mbuf;
+struct rtentry;
+#include <net/if.h>
+#include <netinet/if_ether.h>
+
+
+int
+main ()
+{
+#ifndef ether_ntohost
+  char *p = (char *) ether_ntohost;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_have_decl_ether_ntohost=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_ether_ntohost=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_ether_ntohost" >&5
+echo "${ECHO_T}$ac_cv_have_decl_ether_ntohost" >&6
+if test $ac_cv_have_decl_ether_ntohost = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ETHER_NTOHOST 1
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define NETINET_IF_ETHER_H_DECLARES_ETHER_ntohost
+_ACEOF
+
+
+else
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ETHER_NTOHOST 0
+_ACEOF
+
+
+fi
+
+
+       fi
+       #
+       # Did that succeed?
+       #
+       if test "$ac_cv_have_decl_ether_ntohost" != yes; then
+               #
+               # No, how about <netinet/ether.h>, as on Linux?
+               #
+
+for ac_header in netinet/ether.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to [email protected]. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to [email protected]. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+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
+                       echo "$as_me:$LINENO: checking whether ether_ntohost is declared" >&5
+echo $ECHO_N "checking whether ether_ntohost is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_ether_ntohost+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <netinet/ether.h>
+
+
+int
+main ()
+{
+#ifndef ether_ntohost
+  char *p = (char *) ether_ntohost;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_have_decl_ether_ntohost=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_ether_ntohost=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_ether_ntohost" >&5
+echo "${ECHO_T}$ac_cv_have_decl_ether_ntohost" >&6
+if test $ac_cv_have_decl_ether_ntohost = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ETHER_NTOHOST 1
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define NETINET_ETHER_H_DECLARES_ETHER_ntohost
+_ACEOF
+
+
+else
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ETHER_NTOHOST 0
+_ACEOF
+
+
+fi
+
+
+               fi
+       fi
+fi
+
 
 
 for ac_func in setlinebuf alarm
index df4a0a1504501f5832f98876f0f92ccc8ff7a0cb..0c0661b79bf5d7f2af1d839b0210ed05e0f3d952 100644 (file)
@@ -1,4 +1,4 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.183 2004-12-27 00:41:30 guy Exp $ (LBL)
+dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.184 2005-03-27 22:38:09 guy Exp $ (LBL)
 dnl
 dnl Copyright (c) 1994, 1995, 1996, 1997
 dnl    The Regents of the University of California.  All rights reserved.
@@ -6,7 +6,7 @@ dnl
 dnl Process this file with autoconf to produce a configure script.
 dnl
 
-AC_REVISION($Revision: 1.183 $)
+AC_REVISION($Revision: 1.184 $)
 AC_PREREQ(2.50)
 AC_INIT(tcpdump.c)
 
@@ -18,6 +18,24 @@ AC_C___ATTRIBUTE__
 AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netdnet/dnetdb.h netinet/ether.h)
 AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
 #include <sys/socket.h>])
+if test "$ac_cv_header_netinet_if_ether_h" != yes; then
+       #
+       # The simple test didn't work.
+       # Do we need to include <net/if.h> first?
+       # Unset ac_cv_header_netinet_if_ether_h so we don't
+       # treat the previous failure as a cached value and
+       # suppress the next test.
+       #
+       AC_MSG_NOTICE([Rechecking with some additional includes])
+       unset ac_cv_header_netinet_if_ether_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>])
+fi
+
 AC_HEADER_TIME
 
 case "$host_os" in
@@ -494,6 +512,18 @@ AC_STRUCT_RES_STATE(ac_cv_res_state)
 
 AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep)
 AC_CHECK_FUNCS(strftime)
+
+#
+# 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.)
+#
+# Before you is a C compiler.
+#
 AC_CHECK_FUNCS(ether_ntohost, [
     AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
        AC_TRY_RUN([
@@ -518,6 +548,57 @@ AC_CHECK_FUNCS(ether_ntohost, [
        AC_DEFINE(USE_ETHER_NTOHOST)
     fi
 ])
+if test "$ac_cv_func_ether_ntohost" = yes; then
+       #
+       # OK, we have ether_ntohost().  Do we have <netinet/if_ether.h>?
+       #
+       if test "$ac_cv_header_netinet_if_ether_h" = yes; then
+               #
+               # Yes.  Does it declare ether_ntohost()?
+               #
+               AC_CHECK_DECLS(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>
+struct mbuf;
+struct rtentry;
+#include <net/if.h>
+#include <netinet/if_ether.h>
+                   ])
+       fi
+       #
+       # Did that succeed?
+       #
+       if test "$ac_cv_have_decl_ether_ntohost" != yes; then
+               #
+               # No, how about <netinet/ether.h>, as on Linux?
+               #
+               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_DECLS(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
+       fi
+fi
+
 AC_CHECK_FUNCS(setlinebuf alarm)
 
 needsnprintf=no