summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-10-01 15:32:11 -0700
committerGuy Harris <guy@alum.mit.edu>2014-10-01 15:32:11 -0700
commita6f81d534ddc1026442664d21a2122d64ab571a9 (patch)
tree0c856b94619099775613d6a07a6f56e17014f392
parent214eb814eeced4f3ffa3c84455f0b168c756e57e (diff)
downloadtcpdump-a6f81d534ddc1026442664d21a2122d64ab571a9.tar.gz
Leave it up to ip6_print() to handle non-IPv6-capable systems.
Always define and declare ip6_print(), always compile print-ip6.c, and always call it if we recognize a payload as IPv6. If INET6 isn't defined, ip6_print() will just print the length and note that printing isn't supported. That way, we don't do weird dissection of IPv6 packets on systems without IPv6 support, due to, for example, ethertype_print() returning 0 ("not dissected") for IPv6 packets on those systems (IPv6-over-Frame Relay was dissected weirdly due to this).
-rw-r--r--Makefile.in2
-rwxr-xr-xconfigure4
-rw-r--r--configure.in4
-rw-r--r--netdissect.h2
-rw-r--r--print-arcnet.c2
-rw-r--r--print-chdlc.c2
-rw-r--r--print-enc.c4
-rw-r--r--print-ether.c2
-rw-r--r--print-fr.c3
-rw-r--r--print-gre.c2
-rw-r--r--print-ip.c4
-rw-r--r--print-ip6.c12
-rw-r--r--print-ipnet.c2
-rw-r--r--print-isoclns.c2
-rw-r--r--print-juniper.c8
-rw-r--r--print-mpls.c4
-rw-r--r--print-nflog.c4
-rw-r--r--print-null.c2
-rw-r--r--print-pflog.c10
-rw-r--r--print-pim.c4
-rw-r--r--print-ppp.c10
-rw-r--r--print-sl.c2
22 files changed, 29 insertions, 62 deletions
diff --git a/Makefile.in b/Makefile.in
index 2e172d76..5879b932 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -131,6 +131,7 @@ LIBNETDISSECT_SRC=\
print-igmp.c \
print-igrp.c \
print-ip.c \
+ print-ip6.c \
print-ipcomp.c \
print-ipfc.c \
print-ipnet.c \
@@ -329,7 +330,6 @@ EXTRA_DIST = \
print-dhcp6.c \
print-frag6.c \
print-icmp6.c \
- print-ip6.c \
print-ip6opts.c \
print-mobility.c \
print-ospf6.c \
diff --git a/configure b/configure
index 3e195e25..2d6577db 100755
--- a/configure
+++ b/configure
@@ -4837,7 +4837,7 @@ if test "${enable_ipv6+set}" = set; then :
enableval=$enable_ipv6; case "$enableval" in
yes) { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
+ LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
$as_echo "#define INET6 1" >>confdefs.h
@@ -4872,7 +4872,7 @@ _ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
+ LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
$as_echo "#define INET6 1" >>confdefs.h
diff --git a/configure.in b/configure.in
index 7babb611..d0e90ddf 100644
--- a/configure.in
+++ b/configure.in
@@ -233,7 +233,7 @@ AC_ARG_ENABLE(ipv6,
--disable-ipv6 disable ipv6 support],
[ case "$enableval" in
yes) AC_MSG_RESULT(yes)
- LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
+ LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
AC_DEFINE(INET6, 1, [Define if you enable IPv6 support])
ipv6=yes
;;
@@ -262,7 +262,7 @@ foo(struct in6_addr *addr)
]])
],
[ AC_MSG_RESULT(yes)
- LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
+ LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
AC_DEFINE(INET6, 1, [Define if you enable IPv6 support])
ipv6=yes],
[ AC_MSG_RESULT(no)
diff --git a/netdissect.h b/netdissect.h
index ceea4690..d39e26b3 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -564,8 +564,8 @@ extern u_int ieee802_11_if_print(netdissect_options *, const struct pcap_pkthdr
extern u_int ieee802_11_radio_avs_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern u_int prism_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-#ifdef INET6
extern void ip6_print(netdissect_options *,const u_char *, u_int);
+#ifdef INET6
extern int frag6_print(netdissect_options *, const u_char *, const u_char *);
extern int rt6_print(netdissect_options *, const u_char *, const u_char *);
extern int hbhopt_print(netdissect_options *, const u_char *);
diff --git a/print-arcnet.c b/print-arcnet.c
index cdd4a650..47d70d8b 100644
--- a/print-arcnet.c
+++ b/print-arcnet.c
@@ -326,11 +326,9 @@ arcnet_encap_print(netdissect_options *ndo, u_char arctype, const u_char *p,
ip_print(ndo, p, length);
return (1);
-#ifdef INET6
case ARCTYPE_INET6:
ip6_print(ndo, p, length);
return (1);
-#endif /*INET6*/
case ARCTYPE_ARP_OLD:
case ARCTYPE_ARP:
diff --git a/print-chdlc.c b/print-chdlc.c
index c1f3d346..8230c87e 100644
--- a/print-chdlc.c
+++ b/print-chdlc.c
@@ -75,11 +75,9 @@ chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length) {
case ETHERTYPE_IP:
ip_print(ndo, p, length);
break;
-#ifdef INET6
case ETHERTYPE_IPV6:
ip6_print(ndo, p, length);
break;
-#endif
case CHDLC_TYPE_SLARP:
chdlc_slarp_print(ndo, p, length);
break;
diff --git a/print-enc.c b/print-enc.c
index 89daae1b..7bd8631e 100644
--- a/print-enc.c
+++ b/print-enc.c
@@ -117,11 +117,11 @@ enc_if_print(netdissect_options *ndo,
case AF_INET:
ip_print(ndo, p, length);
break;
-#ifdef INET6
+#ifdef AF_INET6
case AF_INET6:
ip6_print(ndo, p, length);
break;
-#endif /*INET6*/
+#endif
}
out:
diff --git a/print-ether.c b/print-ether.c
index 0e7777e9..49e7803c 100644
--- a/print-ether.c
+++ b/print-ether.c
@@ -326,11 +326,9 @@ ethertype_print(netdissect_options *ndo,
ip_print(ndo, p, length);
return (1);
-#ifdef INET6
case ETHERTYPE_IPV6:
ip6_print(ndo, p, length);
return (1);
-#endif /*INET6*/
case ETHERTYPE_ARP:
case ETHERTYPE_REVARP:
diff --git a/print-fr.c b/print-fr.c
index ae476528..7d63e0d6 100644
--- a/print-fr.c
+++ b/print-fr.c
@@ -282,11 +282,10 @@ fr_print(netdissect_options *ndo,
ip_print(ndo, p, length);
break;
-#ifdef INET6
case NLPID_IP6:
ip6_print(ndo, p, length);
break;
-#endif
+
case NLPID_CLNP:
case NLPID_ESIS:
case NLPID_ISIS:
diff --git a/print-gre.c b/print-gre.c
index 604a9696..4d7705f8 100644
--- a/print-gre.c
+++ b/print-gre.c
@@ -200,11 +200,9 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
case ETHERTYPE_IP:
ip_print(ndo, bp, len);
break;
-#ifdef INET6
case ETHERTYPE_IPV6:
ip6_print(ndo, bp, len);
break;
-#endif
case ETHERTYPE_MPLS:
mpls_print(ndo, bp, len);
break;
diff --git a/print-ip.c b/print-ip.c
index 362465e6..3476ed7a 100644
--- a/print-ip.c
+++ b/print-ip.c
@@ -436,12 +436,10 @@ again:
}
break;
-#ifdef INET6
case IPPROTO_IPV6:
/* ip6-in-ip encapsulation */
ip6_print(ndo, ipds->cp, ipds->len);
break;
-#endif /*INET6*/
case IPPROTO_RSVP:
rsvp_print(ndo, ipds->cp, ipds->len);
@@ -685,11 +683,9 @@ ipN_print(netdissect_options *ndo, register const u_char *bp, register u_int len
case 4:
ip_print (ndo, bp, length);
return;
-#ifdef INET6
case 6:
ip6_print (ndo, bp, length);
return;
-#endif
default:
ND_PRINT((ndo, "unknown ip %d", IP_V(&hdr)));
return;
diff --git a/print-ip6.c b/print-ip6.c
index 7311c8ff..dd6b7f51 100644
--- a/print-ip6.c
+++ b/print-ip6.c
@@ -24,8 +24,6 @@
#include "config.h"
#endif
-#ifdef INET6
-
#include <tcpdump-stdinc.h>
#include <string.h>
@@ -34,6 +32,8 @@
#include "addrtoname.h"
#include "extract.h"
+#ifdef INET6
+
#include "ip6.h"
#include "ipproto.h"
@@ -266,4 +266,12 @@ trunc:
ND_PRINT((ndo, "[|ip6]"));
}
+#else /* INET6 */
+
+void
+ip6_print(netdissect_options *ndo, const u_char *bp _U_, u_int length)
+{
+ ND_PRINT((ndo, "IP6, length: %u (printing not supported)", length));
+}
+
#endif /* INET6 */
diff --git a/print-ipnet.c b/print-ipnet.c
index e1cd59e1..c4ff16ab 100644
--- a/print-ipnet.c
+++ b/print-ipnet.c
@@ -76,11 +76,9 @@ ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
ip_print(ndo, p, length);
break;
-#ifdef INET6
case IPH_AF_INET6:
ip6_print(ndo, p, length);
break;
-#endif /*INET6*/
default:
if (!ndo->ndo_eflag)
diff --git a/print-isoclns.c b/print-isoclns.c
index bc710e4a..d6dfcf21 100644
--- a/print-isoclns.c
+++ b/print-isoclns.c
@@ -703,11 +703,9 @@ void isoclns_print(netdissect_options *ndo,
ip_print(ndo, p + 1, length - 1);
break;
-#ifdef INET6
case NLPID_IP6:
ip6_print(ndo, p + 1, length - 1);
break;
-#endif
case NLPID_PPP:
ppp_print(ndo, p + 1, length - 1);
diff --git a/print-juniper.c b/print-juniper.c
index f2aa8cfa..31874b7d 100644
--- a/print-juniper.c
+++ b/print-juniper.c
@@ -480,11 +480,9 @@ juniper_ggsn_print(netdissect_options *ndo,
case JUNIPER_PROTO_IPV4:
ip_print(ndo, p, l2info.length);
break;
-#ifdef INET6
case JUNIPER_PROTO_IPV6:
ip6_print(ndo, p, l2info.length);
break;
-#endif /* INET6 */
default:
if (!ndo->ndo_eflag)
ND_PRINT((ndo, "unknown GGSN proto (%u)", gh->proto));
@@ -784,11 +782,9 @@ juniper_mlppp_print(netdissect_options *ndo,
else
ip_print(ndo, p, l2info.length);
return l2info.header_len;
-#ifdef INET6
case JUNIPER_LSQ_L3_PROTO_IPV6:
ip6_print(ndo, p,l2info.length);
return l2info.header_len;
-#endif
case JUNIPER_LSQ_L3_PROTO_MPLS:
mpls_print(ndo, p, l2info.length);
return l2info.header_len;
@@ -840,11 +836,9 @@ juniper_mfr_print(netdissect_options *ndo,
case JUNIPER_LSQ_L3_PROTO_IPV4:
ip_print(ndo, p, l2info.length);
return l2info.header_len;
-#ifdef INET6
case JUNIPER_LSQ_L3_PROTO_IPV6:
ip6_print(ndo, p,l2info.length);
return l2info.header_len;
-#endif
case JUNIPER_LSQ_L3_PROTO_MPLS:
mpls_print(ndo, p, l2info.length);
return l2info.header_len;
@@ -1071,7 +1065,6 @@ ip_heuristic_guess(netdissect_options *ndo,
case 0x4f:
ip_print(ndo, p, length);
break;
-#ifdef INET6
case 0x60:
case 0x61:
case 0x62:
@@ -1090,7 +1083,6 @@ ip_heuristic_guess(netdissect_options *ndo,
case 0x6f:
ip6_print(ndo, p, length);
break;
-#endif
default:
return 0; /* did not find a ip header */
break;
diff --git a/print-mpls.c b/print-mpls.c
index 039781ad..bc34d506 100644
--- a/print-mpls.c
+++ b/print-mpls.c
@@ -186,11 +186,7 @@ mpls_print(netdissect_options *ndo, const u_char *bp, u_int length)
break;
case PT_IPV6:
-#ifdef INET6
ip6_print(ndo, p, length - (p - bp));
-#else
- ND_PRINT((ndo, "IPv6, length: %u", length));
-#endif
break;
case PT_OSI:
diff --git a/print-nflog.c b/print-nflog.c
index cd0428bc..95da4cba 100644
--- a/print-nflog.c
+++ b/print-nflog.c
@@ -145,11 +145,11 @@ nflog_if_print(netdissect_options *ndo,
ip_print(ndo, p, length);
break;
-#ifdef INET6
+#ifdef AF_INET6
case AF_INET6:
ip6_print(ndo, p, length);
break;
-#endif /*INET6*/
+#endif /* AF_INET6 */
default:
if (!ndo->ndo_eflag)
diff --git a/print-null.c b/print-null.c
index 47df451e..166f777d 100644
--- a/print-null.c
+++ b/print-null.c
@@ -109,13 +109,11 @@ null_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
ip_print(ndo, p, length);
break;
-#ifdef INET6
case BSD_AFNUM_INET6_BSD:
case BSD_AFNUM_INET6_FREEBSD:
case BSD_AFNUM_INET6_DARWIN:
ip6_print(ndo, p, length);
break;
-#endif
case BSD_AFNUM_ISO:
isoclns_print(ndo, p, length, caplen);
diff --git a/print-pflog.c b/print-pflog.c
index 4263a469..72ae2763 100644
--- a/print-pflog.c
+++ b/print-pflog.c
@@ -152,14 +152,16 @@ pflog_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
ip_print(ndo, p, length);
break;
-#ifdef INET6
+#if defined(AF_INET6) || defined(OPENBSD_AF_INET6)
+#ifdef AF_INET6
case AF_INET6:
-#if OPENBSD_AF_INET6 != AF_INET6
+#endif /* AF_INET6 */
+#if !defined(AF_INET6) || OPENBSD_AF_INET6 != AF_INET6
case OPENBSD_AF_INET6: /* XXX: read pcap files */
-#endif
+#endif /* !defined(AF_INET6) || OPENBSD_AF_INET6 != AF_INET6 */
ip6_print(ndo, p, length);
break;
-#endif
+#endif /* defined(AF_INET6) || defined(OPENBSD_AF_INET6) */
default:
/* address family not handled, print raw packet */
diff --git a/print-pim.c b/print-pim.c
index 567d3d99..15f4c513 100644
--- a/print-pim.c
+++ b/print-pim.c
@@ -768,11 +768,11 @@ pimv2_print(netdissect_options *ndo,
case 4: /* IPv4 */
ip_print(ndo, bp, len);
break;
-#ifdef INET6
+
case 6: /* IPv6 */
ip6_print(ndo, bp, len);
break;
-#endif
+
default:
ND_PRINT((ndo, "IP ver %d", IP_V(ip)));
break;
diff --git a/print-ppp.c b/print-ppp.c
index b858b73c..8e098f05 100644
--- a/print-ppp.c
+++ b/print-ppp.c
@@ -1392,11 +1392,9 @@ ppp_hdlc(netdissect_options *ndo,
case PPP_IP:
ip_print(ndo, b + 1, length - 1);
goto cleanup;
-#ifdef INET6
case PPP_IPV6:
ip6_print(ndo, b + 1, length - 1);
goto cleanup;
-#endif
default: /* no luck - try next guess */
break;
}
@@ -1466,12 +1464,10 @@ handle_ppp(netdissect_options *ndo,
case PPP_IP:
ip_print(ndo, p, length);
break;
-#ifdef INET6
case ETHERTYPE_IPV6: /*XXX*/
case PPP_IPV6:
ip6_print(ndo, p, length);
break;
-#endif
case ETHERTYPE_IPX: /*XXX*/
case PPP_IPX:
ipx_print(ndo, p, length);
@@ -1781,11 +1777,9 @@ ppp_bsdos_if_print(netdissect_options *ndo _U_,
case PPP_IP:
ip_print(ndo, p, length);
break;
-#ifdef INET6
case PPP_IPV6:
ip6_print(ndo, p, length);
break;
-#endif
case PPP_MPLS_UCAST:
case PPP_MPLS_MCAST:
mpls_print(ndo, p, length);
@@ -1800,11 +1794,9 @@ ppp_bsdos_if_print(netdissect_options *ndo _U_,
case PPP_IP:
ip_print(ndo, p, length);
break;
-#ifdef INET6
case PPP_IPV6:
ip6_print(ndo, p, length);
break;
-#endif
case PPP_MPLS_UCAST:
case PPP_MPLS_MCAST:
mpls_print(ndo, p, length);
@@ -1832,11 +1824,9 @@ ppp_bsdos_if_print(netdissect_options *ndo _U_,
case PPP_IP:
ip_print(p, length);
break;
-#ifdef INET6
case PPP_IPV6:
ip6_print(ndo, p, length);
break;
-#endif
case PPP_MPLS_UCAST:
case PPP_MPLS_MCAST:
mpls_print(ndo, p, length);
diff --git a/print-sl.c b/print-sl.c
index a12a2bd6..fb6a59ce 100644
--- a/print-sl.c
+++ b/print-sl.c
@@ -78,11 +78,9 @@ sl_if_print(netdissect_options *ndo,
case 4:
ip_print(ndo, (u_char *)ip, length);
break;
-#ifdef INET6
case 6:
ip6_print(ndo, (u_char *)ip, length);
break;
-#endif
default:
ND_PRINT((ndo, "ip v%d", IP_V(ip)));
}