]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Leave it up to ip6_print() to handle non-IPv6-capable systems.
authorGuy Harris <[email protected]>
Wed, 1 Oct 2014 22:32:11 +0000 (15:32 -0700)
committerGuy Harris <[email protected]>
Wed, 1 Oct 2014 22:32:11 +0000 (15:32 -0700)
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).

22 files changed:
Makefile.in
configure
configure.in
netdissect.h
print-arcnet.c
print-chdlc.c
print-enc.c
print-ether.c
print-fr.c
print-gre.c
print-ip.c
print-ip6.c
print-ipnet.c
print-isoclns.c
print-juniper.c
print-mpls.c
print-nflog.c
print-null.c
print-pflog.c
print-pim.c
print-ppp.c
print-sl.c

index 2e172d76ef17bbe3f6f2d928194b99ea399154a9..5879b932c9459cc0ad23db378d2a08e2acc17a9d 100644 (file)
@@ -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 \
index 3e195e25c6a2b4480fe3c0ff0df311ff8ec1a339..2d6577db9cb9b3f4fe84b4167dc7fea9bccdc9cf 100755 (executable)
--- 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
 
index 7babb611a57d8dc3a1d2b6ee2d501aea54bc653d..d0e90ddf0b1a9c3bab87eda226928b20629331ed 100644 (file)
@@ -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)
index ceea4690ea23e47cf45ce84c8e29c9efa06384a1..d39e26b3fa04e1954132d3baa722bc0dfa3a794a 100644 (file)
@@ -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 *);
index cdd4a650513a3c3b237d8fc14e69658b25461f0b..47d70d8bc7c50d47a0f671fa05c11854f0d82f9d 100644 (file)
@@ -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:
index c1f3d346482820d90c345951ba726f3bc5033c9d..8230c87e6cb2c1bd4d3c494864ff986853d75b5d 100644 (file)
@@ -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;
index 89daae1bb4a3610d3930d015d8f0b95e4829e567..7bd8631e5207b35fd09c05acefe82c5669ffddda 100644 (file)
@@ -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:
index 0e7777e90a7fb426a126ff86c3842c8433afe117..49e7803cfe727d1064a4b07d698d5c3113e05b5f 100644 (file)
@@ -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:
index ae476528a26ba5b6c41de702b15c91c241b8b449..7d63e0d69264162ceef0743e8c189354972a8c23 100644 (file)
@@ -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:
index 604a969604648abfc0094a8b1e6dc5f137b1b292..4d7705f80edca018fa25b76862d035582a8306ff 100644 (file)
@@ -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;
index 362465e698defc7804718061be1acbb7d494c54e..3476ed7afe61a55c00a1aa650e36d00424f50310 100644 (file)
@@ -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;
index 7311c8ff869a4fa33dd9050d005a18dcb1f01163..dd6b7f5105adb6037059988ca943547d566d14bf 100644 (file)
@@ -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 */
index e1cd59e198231fa64c9bdf3199fa34106b6d14dc..c4ff16aba2f6daf29dbb38113fbe28e83a7c179f 100644 (file)
@@ -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)
index bc710e4aa8e9e89469f15970ff693e068cc29a3f..d6dfcf21a110e0bc1afb12f51c1cdb3f5d1233ce 100644 (file)
@@ -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);
index f2aa8cfa1daa6a31705ef6c2c67fa128519154ef..31874b7df41f1ff6ce8611042b8c077667aedc73 100644 (file)
@@ -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;
index 039781ada2d1a751bd3f7ad0175356fe9d98d376..bc34d50623d3e0e6c066585174981ccd81287f30 100644 (file)
@@ -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:
index cd0428bc2862b24fd00e49e01fff4d2c826bfe4a..95da4cba4f2dba97b6797e06fd5953ffdb4cb7ae 100644 (file)
@@ -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)
index 47df451ee7803d4771da099a3ff7a88d5afba7e2..166f777dee2b24b660950fbd201b7ef171308c4f 100644 (file)
@@ -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);
index 4263a469b527f5aa1e62c58629751c5a495f2c9c..72ae276320ce9a18ee669ff582cfb69e972616c5 100644 (file)
@@ -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 */
index 567d3d9954ca508ddd6fa0e54f44e9a93516a069..15f4c51300e880b8fc447b5a5bf0cb9f1ff0ecaf 100644 (file)
@@ -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;
index b858b73ca824ed7a3e6733e6d042f25e13dc0af6..8e098f05a953e3230bfa97f726ed2cc144db9c79 100644 (file)
@@ -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);
index a12a2bd6f35f5d9ce6506b54397a9c7182daaa84..fb6a59ceb586992318d18af3762d1d0a665994df 100644 (file)
@@ -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)));
        }