summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ovsienko <denis@ovsienko.info>2018-07-23 23:28:24 +0100
committerDenis Ovsienko <denis@ovsienko.info>2019-11-03 23:46:28 +0000
commitc9e5ac541bbb4f01af0a6545fafe6c181d1eebbb (patch)
tree4fb07ed4169c357dd94939e69c482b4d426a01ff
parenteabcd87c1dc79255cbde14ef4559b327bb90d01e (diff)
downloadtcpdump-c9e5ac541bbb4f01af0a6545fafe6c181d1eebbb.tar.gz
libdnet has bugs, do not use it.
The only function tcpdump used in libdnet was dnet_htoa(), which tries to translate a binary DECnet address to a nodename through a lookup in /etc/decnet.conf. The translation is slow and has a bug, so stop using the function and remove the dependency on libdnet. This makes tcpdump always print DECnet addresses in numeric format, if anybody needs the translation back they are welcome to fix libdnet or (more realistically) add an implementation of dnet_htoa() to the tcpdump source code and use it. (This is a forward-port of commit 9a6eb27 from tcpdump-4.9 to master. Sadly, together with libdnet this change removes the fine work that Guy had done in the master branch in commits ebf3f19 and 4ef8d63 to put libdnet usage right whilst my original "do not use libdnet" commit was aging in the pipeline.)
-rw-r--r--.travis.yml1
-rw-r--r--CMakeLists.txt39
-rw-r--r--addrtoname.c5
-rw-r--r--cmakeconfig.h.in15
-rw-r--r--config.h.in15
-rwxr-xr-xconfigure129
-rw-r--r--configure.ac39
-rw-r--r--netdissect.h1
-rw-r--r--print-decnet.c38
-rw-r--r--tcpdump.c3
10 files changed, 1 insertions, 284 deletions
diff --git a/.travis.yml b/.travis.yml
index 798afe5c..ae9d06ee 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -74,7 +74,6 @@ addons:
- libibverbs-dev
- libssl-dev
- libssl1.0.0
- - libdnet-dev
- libsmi2-dev
- libcap-ng-dev
- libpcap-dev
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3d2ab654..59ecbf92 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -482,45 +482,6 @@ if(HAVE_ETHER_NTOHOST)
endif()
cmake_pop_check_state()
-check_function_exists(dnet_htoa STDLIBS_HAVE_DNET_HTOA)
-if(STDLIBS_HAVE_DNET_HTOA)
- set(HAVE_DNET_HTOA TRUE)
-else(STDLIBS_HAVE_DNET_HTOA)
- check_library_exists(dnet dnet_htoa "" HAVE_DNET_HTOA)
- if(HAVE_DNET_HTOA)
- set(TCPDUMP_LINK_LIBRARIES dnet ${TCPDUMP_LINK_LIBRARIES})
- endif(HAVE_DNET_HTOA)
-endif(STDLIBS_HAVE_DNET_HTOA)
-if(HAVE_DNET_HTOA)
- #
- # OK, we have dnet_htoa(). Do we have netdnet/dnetdb.h?
- #
- check_include_files("sys/types.h;netdnet/dnetdb.h" HAVE_NETDNET_DNETDB_H)
- if(HAVE_NETDNET_DNETDB_H)
- #
- # Yes. Does it declare dnet_htoa()?
- #
- cmake_push_check_state()
- set(CMAKE_REQUIRED_LIBRARIES dnet)
- check_symbol_exists(dnet_htoa "sys/types.h;netdnet/dnetdb.h" NETDNET_DNETDB_H_DECLARES_DNET_HTOA)
- cmake_pop_check_state()
- endif(HAVE_NETDNET_DNETDB_H)
-
- #
- # Do we have netdnet/dn.h?
- #
- check_include_file(netdnet/dn.h HAVE_NETDNET_DN_H)
- if(HAVE_NETDNET_DN_H)
- #
- # Yes. Does it declare struct dn_naddr?
- #
- cmake_push_check_state()
- set(CMAKE_EXTRA_INCLUDE_FILES netdnet/dn.h)
- check_type_size("struct dn_naddr" STRUCT_DN_NADDR)
- cmake_pop_check_state()
- endif(HAVE_NETDNET_DN_H)
-endif(HAVE_DNET_HTOA)
-
#
# Data types.
#
diff --git a/addrtoname.c b/addrtoname.c
index aa43be76..ce05903b 100644
--- a/addrtoname.c
+++ b/addrtoname.c
@@ -1280,10 +1280,7 @@ dnaddr_string(netdissect_options *ndo, u_short dnaddr)
tp->addr = dnaddr;
tp->nxt = newhnamemem(ndo);
- if (ndo->ndo_nflag)
- tp->name = dnnum_string(ndo, dnaddr);
- else
- tp->name = dnname_string(ndo, dnaddr);
+ tp->name = dnnum_string(ndo, dnaddr);
return(tp->name);
}
diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in
index 5c753284..38925d7b 100644
--- a/cmakeconfig.h.in
+++ b/cmakeconfig.h.in
@@ -30,9 +30,6 @@
/* Define to 1 if you have the declaration of `ether_ntohost' */
#cmakedefine HAVE_DECL_ETHER_NTOHOST 1
-/* define if you have the dnet_htoa function */
-#cmakedefine HAVE_DNET_HTOA 1
-
/* Define to 1 if you have the `ether_ntohost' function. */
#cmakedefine HAVE_ETHER_NTOHOST 1
@@ -72,12 +69,6 @@
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H 1
-/* Define to 1 if you have the <netdnet/dnetdb.h> header file. */
-#cmakedefine HAVE_NETDNET_DNETDB_H 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 <net/if.h> header file. */
#cmakedefine HAVE_NET_IF_H 1
@@ -213,9 +204,6 @@
/* Define to 1 if you have the `strsep' function. */
#cmakedefine HAVE_STRSEP 1
-/* Define to 1 if the system has the type `struct dn_naddr'. */
-#cmakedefine HAVE_STRUCT_DN_NADDR 1
-
/* Define to 1 if the system has the type `struct ether_addr'. */
#cmakedefine HAVE_STRUCT_ETHER_ADDR 1
@@ -240,9 +228,6 @@
/* define if libpcap has yydebug */
#cmakedefine HAVE_YYDEBUG 1
-/* Define to 1 if netenet/dnetdb.h declares `dnet_htoa' */
-#cmakedefine NETDNET_DNETDB_H_DECLARES_DNET_HTOA 1
-
/* Define to 1 if netinet/ether.h declares `ether_ntohost' */
#cmakedefine NETINET_ETHER_H_DECLARES_ETHER_NTOHOST 1
diff --git a/config.h.in b/config.h.in
index e40e1089..4b22e15c 100644
--- a/config.h.in
+++ b/config.h.in
@@ -30,9 +30,6 @@
/* Define to 1 if you have the declaration of `ether_ntohost' */
#undef HAVE_DECL_ETHER_NTOHOST
-/* define if you have the dnet_htoa function */
-#undef HAVE_DNET_HTOA
-
/* Define to 1 if you have the `ether_ntohost' function. */
#undef HAVE_ETHER_NTOHOST
@@ -72,12 +69,6 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
-/* Define to 1 if you have the <netdnet/dnetdb.h> header file. */
-#undef HAVE_NETDNET_DNETDB_H
-
-/* Define to 1 if you have the <netdnet/dn.h> header file. */
-#undef HAVE_NETDNET_DN_H
-
/* Define to 1 if you have the <net/if.h> header file. */
#undef HAVE_NET_IF_H
@@ -210,9 +201,6 @@
/* 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
@@ -234,9 +222,6 @@
/* define if libpcap has yydebug */
#undef HAVE_YYDEBUG
-/* 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 0660441f..3b2041c9 100755
--- a/configure
+++ b/configure
@@ -4927,135 +4927,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
fi
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
-
- #
- # 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
-
-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" "strlcat" "ac_cv_func_strlcat"
if test "x$ac_cv_func_strlcat" = xyes; then :
$as_echo "#define HAVE_STRLCAT 1" >>confdefs.h
diff --git a/configure.ac b/configure.ac
index ed3e14e3..26c1b3a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -385,45 +385,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
fi
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(strlcat strlcpy strdup strsep getservent getopt_long)
AC_CHECK_FUNCS(fork vfork strftime)
AC_CHECK_FUNCS(setlinebuf)
diff --git a/netdissect.h b/netdissect.h
index d3e38a80..7267cff8 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -718,7 +718,6 @@ extern void nd_print_invalid(netdissect_options *);
extern int mask2plen(uint32_t);
extern int mask62plen(const u_char *);
-extern const char *dnname_string(netdissect_options *, u_short);
extern const char *dnnum_string(netdissect_options *, u_short);
extern int decode_prefix4(netdissect_options *, const u_char *, u_int, char *, size_t);
diff --git a/print-decnet.c b/print-decnet.c
index 31166e3f..047916d3 100644
--- a/print-decnet.c
+++ b/print-decnet.c
@@ -31,25 +31,6 @@
#include <stdlib.h>
#include <string.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 "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
@@ -1248,22 +1229,3 @@ dnnum_string(netdissect_options *ndo, u_short dnaddr)
snprintf(str, siz, "%u.%u", area, node);
return(str);
}
-
-const char *
-dnname_string(netdissect_options *ndo, u_short dnaddr)
-{
-#ifdef HAVE_DNET_HTOA
- struct dn_naddr dna;
- char *dnname;
-
- dna.a_len = sizeof(short);
- memcpy((char *)dna.a_addr, (char *)&dnaddr, sizeof(short));
- dnname = dnet_htoa(&dna);
- if(dnname != NULL)
- return (strdup(dnname));
- else
- return(dnnum_string(ndo, dnaddr));
-#else
- return(dnnum_string(ndo, dnaddr)); /* punt */
-#endif
-}
diff --git a/tcpdump.c b/tcpdump.c
index bf4f2ef5..a63cdcf0 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -3065,9 +3065,6 @@ print_version(void)
smi_version_string = nd_smi_version_string();
if (smi_version_string != NULL)
(void)fprintf (stderr, "SMI-library: %s\n", smi_version_string);
-#ifdef HAVE_DNET_HTOA
- (void)fprintf(stderr, "libdnet unknown version\n");
-#endif
#if defined(__SANITIZE_ADDRESS__)
(void)fprintf (stderr, "Compiled with AddressSanitizer/GCC.\n");