summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-12-30 14:16:15 -0800
committerGuy Harris <guy@alum.mit.edu>2017-12-30 14:16:15 -0800
commitebf3f194266cb41da20aaef7506daab4f9dbb6d8 (patch)
tree04409655e8e0ebe0008b6c836cf793055ee97c44
parenta1b2cce62e20f891d6d35e41ab8fedb156096bfd (diff)
downloadtcpdump-ebf3f194266cb41da20aaef7506daab4f9dbb6d8.tar.gz
Clean up handling of libdnet headers.
If we don't have dnet_htoa(), we don't need any of the headers. Check for them only if we have dnet_htoa(). Use AC_CHECK_DECL to see if netdnet/dnetdb.h declares dnet_htoa(). Check for netdnet/dn.h and, if we have it, check whether it declares struct dn_naddr; if so, include it, rather than defining the structure ourselves. Don't define union etheraddr ourselves; we only need to define an etheraddr typedef. That avoids colliding with a libdnet header definition of union etheraddr. (When we use etheraddr, we care about what's on the wire, and we don't rely on system headers to tell us what's on the wire.)
-rw-r--r--config.h.in10
-rwxr-xr-xconfigure191
-rw-r--r--configure.ac52
-rw-r--r--print-decnet.c43
4 files changed, 187 insertions, 109 deletions
diff --git a/config.h.in b/config.h.in
index 41e3bc72..e5ae27c3 100644
--- a/config.h.in
+++ b/config.h.in
@@ -73,8 +73,8 @@
/* Define to 1 if you have the <netdnet/dnetdb.h> header file. */
#undef HAVE_NETDNET_DNETDB_H
-/* define if you have a dnet_htoa declaration in <netdnet/dnetdb.h> */
-#undef HAVE_NETDNET_DNETDB_H_DNET_HTOA
+/* 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
@@ -223,6 +223,9 @@
/* Define to 1 if you have the `strsep' function. */
#undef HAVE_STRSEP
+/* Define to 1 if the system has the type `struct dn_naddr'. */
+#undef HAVE_STRUCT_DN_NADDR
+
/* Define to 1 if the system has the type `struct ether_addr'. */
#undef HAVE_STRUCT_ETHER_ADDR
@@ -253,6 +256,9 @@
/* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__
+/* Define to 1 if netenet/dnetdb.h declares `dnet_htoa' */
+#undef NETDNET_DNETDB_H_DECLARES_DNET_HTOA
+
/* Define to 1 if netinet/ether.h declares `ether_ntohost' */
#undef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
diff --git a/configure b/configure
index 3b1568ec..5fc8dbcc 100755
--- a/configure
+++ b/configure
@@ -3992,7 +3992,7 @@ fi
done
-for ac_header in fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h
+for ac_header in fcntl.h rpc/rpc.h rpc/rpcent.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -4918,33 +4918,135 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
fi
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_htoa declaration in netdnet/dnetdb.h" >&5
-$as_echo_n "checking for dnet_htoa declaration in netdnet/dnetdb.h... " >&6; }
-if ${td_cv_decl_netdnet_dnetdb_h_dnet_htoa+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dnet_htoa" >&5
+$as_echo_n "checking for library containing dnet_htoa... " >&6; }
+if ${ac_cv_search_dnet_htoa+:} false; then :
$as_echo_n "(cached) " >&6
else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include <netdnet/dnetdb.h>
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dnet_htoa ();
+int
+main ()
+{
+return dnet_htoa ();
+ ;
+ return 0;
+}
_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "dnet_htoa" >/dev/null 2>&1; then :
- td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes
+for ac_lib in '' dnet; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_dnet_htoa=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_dnet_htoa+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_dnet_htoa+:} false; then :
+
else
- td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no
+ ac_cv_search_dnet_htoa=no
fi
-rm -f conftest*
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dnet_htoa" >&5
+$as_echo "$ac_cv_search_dnet_htoa" >&6; }
+ac_res=$ac_cv_search_dnet_htoa
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+
+$as_echo "#define HAVE_DNET_HTOA 1" >>confdefs.h
+
+ #
+ # OK, we have dnet_htoa(). Do we have netdnet/dnetdb.h?
+ #
+ for ac_header in netdnet/dnetdb.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "netdnet/dnetdb.h" "ac_cv_header_netdnet_dnetdb_h" "$ac_includes_default"
+if test "x$ac_cv_header_netdnet_dnetdb_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_NETDNET_DNETDB_H 1
+_ACEOF
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $td_cv_decl_netdnet_dnetdb_h_dnet_htoa" >&5
-$as_echo "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" >&6; }
-if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
-$as_echo "#define HAVE_NETDNET_DNETDB_H_DNET_HTOA 1" >>confdefs.h
+done
+
+ if test "$ac_cv_header_netdnet_dnetdb_h" = "yes"; then
+ #
+ # Yes. Does it declare dnet_htoa()?
+ #
+ ac_fn_c_check_decl "$LINENO" "dnet_htoa" "ac_cv_have_decl_dnet_htoa" "
+$ac_includes_default
+#include <netdnet/dnetdb.h>
+
+"
+if test "x$ac_cv_have_decl_dnet_htoa" = xyes; then :
+
+ # Yes.
+
+$as_echo "#define NETDNET_DNETDB_H_DECLARES_DNET_HTOA /**/" >>confdefs.h
+
fi
+ fi
+
+ #
+ # Do we have netdnet/dn.h?
+ #
+ for ac_header in netdnet/dn.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "netdnet/dn.h" "ac_cv_header_netdnet_dn_h" "$ac_includes_default"
+if test "x$ac_cv_header_netdnet_dn_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_NETDNET_DN_H 1
+_ACEOF
+
+fi
+
+done
+
+ if test "$ac_cv_header_netdnet_dn_h" = "yes"; then
+ #
+ # Yes. Does it declare struct dn_naddr?
+ #
+ ac_fn_c_check_type "$LINENO" "struct dn_naddr" "ac_cv_type_struct_dn_naddr" "
+#include <netdnet/dn.h>
+
+"
+if test "x$ac_cv_type_struct_dn_naddr" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_DN_NADDR 1
+_ACEOF
+
+
+fi
+
+ fi
+
+fi
+
+
ac_fn_c_check_func "$LINENO" "vfprintf" "ac_cv_func_vfprintf"
if test "x$ac_cv_func_vfprintf" = xyes; then :
$as_echo "#define HAVE_VFPRINTF 1" >>confdefs.h
@@ -5085,65 +5187,6 @@ esac
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dnet_htoa" >&5
-$as_echo_n "checking for library containing dnet_htoa... " >&6; }
-if ${ac_cv_search_dnet_htoa+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dnet_htoa ();
-int
-main ()
-{
-return dnet_htoa ();
- ;
- return 0;
-}
-_ACEOF
-for ac_lib in '' dnet; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_search_dnet_htoa=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext
- if ${ac_cv_search_dnet_htoa+:} false; then :
- break
-fi
-done
-if ${ac_cv_search_dnet_htoa+:} false; then :
-
-else
- ac_cv_search_dnet_htoa=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dnet_htoa" >&5
-$as_echo "$ac_cv_search_dnet_htoa" >&6; }
-ac_res=$ac_cv_search_dnet_htoa
-if test "$ac_res" != no; then :
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-$as_echo "#define HAVE_DNET_HTOA 1" >>confdefs.h
-
-fi
-
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lrpc" >&5
$as_echo_n "checking for main in -lrpc... " >&6; }
if ${ac_cv_lib_rpc_main+:} false; then :
diff --git a/configure.ac b/configure.ac
index af501dba..6c845c29 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,7 +29,7 @@ if test "$ac_cv___attribute__" = "yes"; then
AC_C___ATTRIBUTE___FALLTHROUGH
fi
-AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h)
+AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h)
AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>])
@@ -394,15 +394,44 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
fi
fi
-AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
-[td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
-[AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
- td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
- td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
-if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
- AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA, 1,
- [define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>])
-fi
+AC_SEARCH_LIBS(dnet_htoa, dnet,
+[
+ AC_DEFINE(HAVE_DNET_HTOA, 1,
+ [define if you have the dnet_htoa function])
+ #
+ # OK, we have dnet_htoa(). Do we have netdnet/dnetdb.h?
+ #
+ AC_CHECK_HEADERS(netdnet/dnetdb.h)
+ if test "$ac_cv_header_netdnet_dnetdb_h" = "yes"; then
+ #
+ # Yes. Does it declare dnet_htoa()?
+ #
+ AC_CHECK_DECL(dnet_htoa,
+ [
+ # Yes.
+ AC_DEFINE(NETDNET_DNETDB_H_DECLARES_DNET_HTOA,,
+ [Define to 1 if netenet/dnetdb.h declares `dnet_htoa'])
+ ],,
+ [
+AC_INCLUDES_DEFAULT
+#include <netdnet/dnetdb.h>
+ ])
+ fi
+
+ #
+ # Do we have netdnet/dn.h?
+ #
+ AC_CHECK_HEADERS(netdnet/dn.h)
+ if test "$ac_cv_header_netdnet_dn_h" = "yes"; then
+ #
+ # Yes. Does it declare struct dn_naddr?
+ #
+ AC_CHECK_TYPES(struct dn_naddr,,,
+ [
+#include <netdnet/dn.h>
+ ])
+ fi
+])
AC_REPLACE_FUNCS(vfprintf strlcat strlcpy strdup strsep getservent getopt_long)
AC_CHECK_FUNCS(fork vfork strftime)
@@ -415,9 +444,6 @@ if test $needsnprintf = yes; then
AC_LIBOBJ(snprintf)
fi
-AC_SEARCH_LIBS(dnet_htoa, dnet,
- AC_DEFINE(HAVE_DNET_HTOA, 1, [define if you have the dnet_htoa function]))
-
AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
dnl Some platforms may need -lnsl for getrpcbynumber.
diff --git a/print-decnet.c b/print-decnet.c
index cbde8e67..2bfd538d 100644
--- a/print-decnet.c
+++ b/print-decnet.c
@@ -27,17 +27,32 @@
#include <netdissect-stdinc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
struct mbuf;
struct rtentry;
-#ifdef HAVE_NETDNET_DNETDB_H
-#include <netdnet/dnetdb.h>
+#ifdef HAVE_DNET_HTOA
+ #ifdef HAVE_NETDNET_DN_H
+ #include <netdnet/dn.h>
+ #endif
+ #ifndef HAVE_STRUCT_DN_NADDR
+#define DN_MAXADDL 20 /* max size of DECnet address */
+struct dn_naddr {
+ unsigned short a_len; /* length of address */
+ unsigned char a_addr[DN_MAXADDL]; /* address as bytes */
+};
+ #endif /* HAVE_STRUCT_DN_NADDR */
+ #ifdef HAVE_NETDNET_DNETDB_H
+ #include <netdnet/dnetdb.h>
+ #endif
+ #ifndef NETDNET_DNETDB_H_DECLARES_DNET_HTOA
+ extern char *dnet_htoa(struct dn_naddr *);
+ #endif
#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
@@ -59,15 +74,13 @@ typedef nd_uint32_t longword; /* 4 bytes field */
/*
* Definitions for DECNET Phase IV protocol headers
*/
-union etheraddress {
+typedef union {
nd_byte dne_addr[6]; /* full ethernet address */
struct {
nd_byte dne_hiord[4]; /* DECnet HIORD prefix */
nd_byte dne_nodeaddr[2]; /* DECnet node address */
} dne_remote;
-};
-
-typedef union etheraddress etheraddr; /* Ethernet address */
+} etheraddr; /* Ethernet address */
#define HIORD 0x000400aa /* high 32-bits of address (swapped) */
@@ -75,12 +88,6 @@ typedef union etheraddress etheraddr; /* Ethernet address */
#define AREASHIFT 10 /* bit-offset for area field */
#define NODEMASK 01777 /* mask for node address field */
-#define DN_MAXADDL 20 /* max size of DECnet address */
-struct dn_naddr {
- uint16_t a_len; /* length of address */
- uint8_t a_addr[DN_MAXADDL]; /* address as bytes */
-};
-
/*
* Define long and short header formats.
*/
@@ -492,10 +499,6 @@ static int print_elist(const char *, u_int);
static int print_nsp(netdissect_options *, const u_char *, u_int);
static void print_reason(netdissect_options *, u_int);
-#ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA
-extern char *dnet_htoa(struct dn_naddr *);
-#endif
-
void
decnet_print(netdissect_options *ndo,
const u_char *ap, u_int length,