]> The Tcpdump Group git mirrors - libpcap/commitdiff
If we have ether_hostton(), check whether we have <netinet/if_ether.h>
authorguy <guy>
Sat, 26 Mar 2005 23:07:50 +0000 (23:07 +0000)
committerguy <guy>
Sat, 26 Mar 2005 23:07:50 +0000 (23:07 +0000)
and if including it declares ether_hostton(), and define
HAVE_DECL_ETHER_HOSTTON appropriately, and use that to determine whether
to define it ourselves, rather than having a set of OSes that don't need
it, as that set can change over time.

Make the default declaration of "ether_hostton()" declare its first
argument as "const char *", as that's what it's *supposed* to be
(although it's not declared as such in some OSes, so we still have to
cast a "const char *" when passed as the first argument).

config.h.in
configure
configure.in
nametoaddr.c

index 6c25423b3d3f434ec7e1e3477e2980e6cc412ecd..89ec69de971b11696b15d4f613fe7df5da1e83de 100644 (file)
 /* define if you have the DAG API */
 #undef HAVE_DAG_API
 
+/* Define to 1 if you have the declaration of `ether_hostton', and to 0 if you
+   don't. */
+#undef HAVE_DECL_ETHER_HOSTTON
+
 /* define if you have a /dev/dlpi */
 #undef HAVE_DEV_DLPI
 
index 117b1b5560b0df63b5570c15ccffaa65c39225ef..8cb3264b83c0b88321da7f59c8d092b43e7dd985 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.110 .
+# From configure.in Revision: 1.111 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.57.
 #
@@ -3597,8 +3597,7 @@ echo "$as_me: error: see the INSTALL for more info" >&2;}
 
 
 
-
-for ac_func in ether_hostton strerror strlcpy
+for ac_func in strerror strlcpy
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -3774,6 +3773,169 @@ if test $needsnprintf = yes; then
        LIBOBJS="$LIBOBJS snprintf.$ac_objext"
 fi
 
+
+for ac_func in ether_hostton
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+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.  */
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (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_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+if test "$ac_cv_func_ether_hostton" = yes; then
+       #
+       # OK, we have ether_hoston().  Do we have <netinet/if_ether.h>?
+       #
+       if test "$ac_cv_header_netinet_if_ether_h" = yes; then
+               #
+               # Yes.  Does it declare ether_hostton()?
+               #
+               echo "$as_me:$LINENO: checking whether ether_hostton is declared" >&5
+echo $ECHO_N "checking whether ether_hostton is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_ether_hostton+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/if_ether.h>
+
+
+int
+main ()
+{
+#ifndef ether_hostton
+  char *p = (char *) ether_hostton;
+#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_hostton=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_have_decl_ether_hostton=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_ether_hostton" >&5
+echo "${ECHO_T}$ac_cv_have_decl_ether_hostton" >&6
+if test $ac_cv_have_decl_ether_hostton = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ETHER_HOSTTON 1
+_ACEOF
+
+
+else
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_ETHER_HOSTTON 0
+_ACEOF
+
+
+fi
+
+
+       fi
+fi
+
 echo "$as_me:$LINENO: checking if --disable-protochain option is specified" >&5
 echo $ECHO_N "checking if --disable-protochain option is specified... $ECHO_C" >&6
 # Check whether --enable-protochain or --disable-protochain was given.
index cec7f6a9009bd8f05754737607678d0a6248610e..711217c8272d31ddbbeb4eb5a17ab9bd17d3555c 100644 (file)
@@ -1,4 +1,4 @@
-dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.110 2004-12-17 23:25:36 guy Exp $ (LBL)
+dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.111 2005-03-26 23:07:51 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.110 $)
+AC_REVISION($Revision: 1.111 $)
 AC_PREREQ(2.50)
 AC_INIT(pcap.c)
 
@@ -32,7 +32,7 @@ AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
 
 AC_LBL_FIXINCLUDES
 
-AC_CHECK_FUNCS(ether_hostton strerror strlcpy)
+AC_CHECK_FUNCS(strerror strlcpy)
 
 needsnprintf=no
 AC_CHECK_FUNCS(vsnprintf snprintf,,
@@ -41,6 +41,24 @@ if test $needsnprintf = yes; then
        AC_LIBOBJ(snprintf)
 fi
 
+AC_CHECK_FUNCS(ether_hostton)
+if test "$ac_cv_func_ether_hostton" = yes; then
+       #
+       # OK, we have ether_hoston().  Do we have <netinet/if_ether.h>?
+       #
+       if test "$ac_cv_header_netinet_if_ether_h" = yes; then
+               #
+               # Yes.  Does it declare ether_hostton()?
+               #
+               AC_CHECK_DECLS(ether_hostton,,,
+                   [
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/if_ether.h>
+                   ])
+       fi
+fi
+
 dnl to pacify those who hate protochain insn
 AC_MSG_CHECKING(if --disable-protochain option is specified)
 AC_ARG_ENABLE(protochain, [  --disable-protochain    disable \"protochain\" insn])
index b6c6a66a2845c7e3db552ac004b2729f85ad5f5d..bffcf7e90b5b70e8ce907141cc79db49eed69d86 100644 (file)
@@ -24,7 +24,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.74 2005-03-17 07:02:32 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.75 2005-03-26 23:07:51 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -405,18 +405,8 @@ pcap_ether_hostton(const char *name)
 }
 #else
 
-/*
- * XXX - perhaps this should, instead, be declared in "lbl/os-XXX.h" files,
- * for those OS versions that don't declare it, rather than being declared
- * here?  That way, for example, we could declare it on FreeBSD 2.x (which
- * doesn't declare it), but not on FreeBSD 3.x (which declares it like
- * this) or FreeBSD 4.x (which declares it with its first argument as
- * "const char *", so no matter how we declare it here, it'll fail to
- * compile on one of 3.x or 4.x).
- */
-#if !defined(sgi) && !defined(__NetBSD__) && !defined(__FreeBSD__) && \
-       !defined(_UNICOSMP)
-extern int ether_hostton(char *, struct ether_addr *);
+#if !defined(HAVE_DECL_ETHER_HOSTTON) || !HAVE_DECL_ETHER_HOSTTON
+extern int ether_hostton(const char *, struct ether_addr *);
 #endif
 
 /* Use the os supplied routines */