]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Convert the IPv6 printer to use netdissect.
authorGuy Harris <[email protected]>
Sun, 7 Nov 2010 20:50:16 +0000 (12:50 -0800)
committerGuy Harris <[email protected]>
Sun, 7 Nov 2010 20:50:16 +0000 (12:50 -0800)
18 files changed:
interface.h
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-null.c
print-pim.c
print-ppp.c
print-sl.c

index 1823b9318e3088c7116d1a0c5b8995639bbd1e5a..09da6cb3ffc306649f694b239d75944c0b477a10 100644 (file)
@@ -315,7 +315,6 @@ extern u_int usb_linux_48_byte_print(const struct pcap_pkthdr *, const u_char *)
 extern u_int usb_linux_64_byte_print(const struct pcap_pkthdr *, const u_char *);
 
 #ifdef INET6
-extern void ip6_print(const u_char *, u_int);
 extern void ip6_opt_print(const u_char *, int);
 extern int hbhopt_print(const u_char *);
 extern int dstopt_print(const u_char *);
index 86ab1ad5c1efe1d74a365fa888b0eefb25a9e598..7d03b4c6e5f8e18d2869c457668fbf63824664bc 100644 (file)
@@ -445,9 +445,9 @@ extern void pptp_print(netdissect_options *,const u_char *, u_int);
 extern u_int ipnet_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
 extern u_int ieee802_15_4_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
 
-#if 0
 #ifdef INET6
 extern void ip6_print(netdissect_options *,const u_char *, u_int);
+#if 0
 extern void ip6_opt_print(netdissect_options *,const u_char *, int);
 extern int nextproto6_cksum(const struct ip6_hdr *, const u_short *, u_int, u_int);
 extern int hbhopt_print(netdissect_options *,const u_char *);
@@ -464,11 +464,13 @@ extern void dhcp6_print(netdissect_options *,const u_char *,
 
 extern void zephyr_print(netdissect_options * ndo,
                         const u_char *cp, int length);
+#endif /* 0 */
 
 #endif /*INET6*/
+
+#if 0
 extern u_short in_cksum(const u_short *,
                        register u_int, int);
-
 #endif
 
 extern void esp_print_decodesecret(netdissect_options *ndo);
index a7b9f0da6bd78d15411a9c686c9e9b83bbdb70f5..9531f346bff70e1610536a4f68c0f2fa4a4347ba 100644 (file)
@@ -265,14 +265,14 @@ arcnet_encap_print(u_char arctype, const u_char *p,
 
 #ifdef INET6
        case ARCTYPE_INET6:
-               ip6_print(p, length);
+               ip6_print(gndo, p, length);
                return (1);
 #endif /*INET6*/
 
        case ARCTYPE_ARP_OLD:
        case ARCTYPE_ARP:
        case ARCTYPE_REVARP:
-         arp_print(gndo, p, length, caplen);
+               arp_print(gndo, p, length, caplen);
                return (1);
 
        case ARCTYPE_ATALK:     /* XXX was this ever used? */
index 238e91a98ce107836c90d2d056245d7c830501ad..261b15ad7efde71dd9c16b8dce4fdfc4baae13a1 100644 (file)
@@ -85,7 +85,7 @@ chdlc_print(register const u_char *p, u_int length) {
                break;
 #ifdef INET6
        case ETHERTYPE_IPV6:
-               ip6_print(p, length);
+               ip6_print(gndo, p, length);
                break;
 #endif
        case CHDLC_TYPE_SLARP:
index e98f7f78215cc93d5310cbd9dd510df7fffaf352..5c01f3ef7b6142c39e59028141857ba310252851 100644 (file)
@@ -80,7 +80,7 @@ enc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
                break;
 #ifdef INET6
        case AF_INET6:
-               ip6_print(p, length);
+               ip6_print(gndo, p, length);
                break;
 #endif /*INET6*/
        }
index 014ee67ce8e7a040ad7c8a27732d7cb450d43b58..8727bff59d3dcdb7ebd881aba69a359b63af2724 100644 (file)
@@ -272,7 +272,7 @@ ethertype_print(netdissect_options *ndo,
 
 #ifdef INET6
        case ETHERTYPE_IPV6:
-               ip6_print(/*ndo,*/ p, length);
+               ip6_print(ndo, p, length);
                return (1);
 #endif /*INET6*/
 
index 6a7c49ddf97d81a9d6eb6cf251d467bfa315225e..51263066a77efeac3b08a17630d6e07b6dd96b5e 100644 (file)
@@ -286,7 +286,7 @@ fr_print(register const u_char *p, u_int length)
 
 #ifdef INET6
        case NLPID_IP6:
-               ip6_print(p, length);
+               ip6_print(gndo, p, length);
                break;
 #endif
        case NLPID_CLNP:
index b45c5b07b068ba1fc7247f8ef121b26b788ca36d..b6fa52236695daa3df5c19d5e8cddec89799bb0b 100644 (file)
@@ -210,7 +210,7 @@ gre_print_0(const u_char *bp, u_int length)
                break;
 #ifdef INET6
        case ETHERTYPE_IPV6:
-               ip6_print(bp, len);
+               ip6_print(gndo, bp, len);
                break;
 #endif
        case ETHERTYPE_MPLS:
index 890085c74a5cc3cf35aeeb29eba4e905da449c43..f42276dc71ade61b4413ffb9ba8e3b4a75d51d8f 100644 (file)
@@ -480,7 +480,7 @@ again:
 
        case IPPROTO_IPV4:
                /* DVMRP multicast tunnel (ip-in-ip encapsulation) */
-               ip_print(gndo, ipds->cp, ipds->len);
+               ip_print(ndo, ipds->cp, ipds->len);
                if (! vflag) {
                        ND_PRINT((ndo, " (ipip-proto-4)"));
                        return;
@@ -490,7 +490,7 @@ again:
 #ifdef INET6
        case IPPROTO_IPV6:
                /* ip6-in-ip encapsulation */
-               ip6_print(ipds->cp, ipds->len);
+               ip6_print(ndo, ipds->cp, ipds->len);
                break;
 #endif /*INET6*/
 
@@ -722,7 +722,7 @@ ipN_print(register const u_char *bp, register u_int length)
                return;
 #ifdef INET6
        case 6:
-               ip6_print (bp, length);
+               ip6_print (gndo, bp, length);
                return;
 #endif
        default:
index 1599cf28b60f90ff153277c23449d2fa88c2f942..9add03efa28afa15e224d2be92dfd63abf4bf3aa 100644 (file)
@@ -73,7 +73,7 @@ nextproto6_cksum(const struct ip6_hdr *ip6, const u_short *data,
  * print an IP6 datagram.
  */
 void
-ip6_print(register const u_char *bp, register u_int length)
+ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
        register const struct ip6_hdr *ip6;
        register int advance;
@@ -89,62 +89,62 @@ ip6_print(register const u_char *bp, register u_int length)
 
        TCHECK(*ip6);
        if (length < sizeof (struct ip6_hdr)) {
-               (void)printf("truncated-ip6 %u", length);
+               (void)ND_PRINT((ndo, "truncated-ip6 %u", length));
                return;
        }
 
-        if (!eflag)
-            printf("IP6 ");
+        if (!ndo->ndo_eflag)
+            ND_PRINT((ndo, "IP6 "));
 
        payload_len = EXTRACT_16BITS(&ip6->ip6_plen);
        len = payload_len + sizeof(struct ip6_hdr);
        if (length < len)
-               (void)printf("truncated-ip6 - %u bytes missing!",
-                       len - length);
+               (void)ND_PRINT((ndo, "truncated-ip6 - %u bytes missing!",
+                       len - length));
 
-        if (vflag) {
+        if (ndo->ndo_vflag) {
             flow = EXTRACT_32BITS(&ip6->ip6_flow);
-            printf("(");
+            ND_PRINT((ndo, "("));
 #if 0
             /* rfc1883 */
             if (flow & 0x0f000000)
-               (void)printf("pri 0x%02x, ", (flow & 0x0f000000) >> 24);
+               (void)ND_PRINT((ndo, "pri 0x%02x, ", (flow & 0x0f000000) >> 24));
             if (flow & 0x00ffffff)
-               (void)printf("flowlabel 0x%06x, ", flow & 0x00ffffff);
+               (void)ND_PRINT((ndo, "flowlabel 0x%06x, ", flow & 0x00ffffff));
 #else
             /* RFC 2460 */
             if (flow & 0x0ff00000)
-               (void)printf("class 0x%02x, ", (flow & 0x0ff00000) >> 20);
+               (void)ND_PRINT((ndo, "class 0x%02x, ", (flow & 0x0ff00000) >> 20));
             if (flow & 0x000fffff)
-               (void)printf("flowlabel 0x%05x, ", flow & 0x000fffff);
+               (void)ND_PRINT((ndo, "flowlabel 0x%05x, ", flow & 0x000fffff));
 #endif
 
-            (void)printf("hlim %u, next-header %s (%u) payload length: %u) ",
+            (void)ND_PRINT((ndo, "hlim %u, next-header %s (%u) payload length: %u) ",
                          ip6->ip6_hlim,
                          tok2str(ipproto_values,"unknown",ip6->ip6_nxt),
                          ip6->ip6_nxt,
-                         payload_len);
+                         payload_len));
         }
 
        /*
         * Cut off the snapshot length to the end of the IP payload.
         */
        ipend = bp + len;
-       if (ipend < snapend)
-               snapend = ipend;
+       if (ipend < ndo->ndo_snapend)
+               ndo->ndo_snapend = ipend;
 
        cp = (const u_char *)ip6;
        advance = sizeof(struct ip6_hdr);
        nh = ip6->ip6_nxt;
-       while (cp < snapend && advance > 0) {
+       while (cp < ndo->ndo_snapend && advance > 0) {
                cp += advance;
                len -= advance;
 
                if (cp == (const u_char *)(ip6 + 1) &&
                    nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
                    nh != IPPROTO_DCCP && nh != IPPROTO_SCTP) {
-                       (void)printf("%s > %s: ", ip6addr_string(&ip6->ip6_src),
-                                    ip6addr_string(&ip6->ip6_dst));
+                       (void)ND_PRINT((ndo, "%s > %s: ", ip6addr_string(&ip6->ip6_src),
+                                    ip6addr_string(&ip6->ip6_dst)));
                }
 
                switch (nh) {
@@ -158,7 +158,7 @@ ip6_print(register const u_char *bp, register u_int length)
                        break;
                case IPPROTO_FRAGMENT:
                        advance = frag6_print(cp, (const u_char *)ip6);
-                       if (snapend <= cp + advance)
+                       if (ndo->ndo_snapend <= cp + advance)
                                return;
                        nh = *cp;
                        fragmented = 1;
@@ -196,7 +196,7 @@ ip6_print(register const u_char *bp, register u_int length)
                        udp_print(cp, len, (const u_char *)ip6, fragmented);
                        return;
                case IPPROTO_ICMPV6:
-                       icmp6_print(gndo, cp, len, (const u_char *)ip6, fragmented);
+                       icmp6_print(ndo, cp, len, (const u_char *)ip6, fragmented);
                        return;
                case IPPROTO_AH:
                        advance = ah_print(cp);
@@ -205,7 +205,7 @@ ip6_print(register const u_char *bp, register u_int length)
                case IPPROTO_ESP:
                    {
                        int enh, padlen;
-                       advance = esp_print(gndo, cp, len, (const u_char *)ip6, &enh, &padlen);
+                       advance = esp_print(ndo, cp, len, (const u_char *)ip6, &enh, &padlen);
                        nh = enh & 0xff;
                        len -= padlen;
                        break;
@@ -228,11 +228,11 @@ ip6_print(register const u_char *bp, register u_int length)
                        return;
 
                case IPPROTO_IPV6:
-                       ip6_print(cp, len);
+                       ip6_print(ndo, cp, len);
                        return;
 
                case IPPROTO_IPV4:
-                       ip_print(gndo, cp, len);
+                       ip_print(ndo, cp, len);
                        return;
 
                 case IPPROTO_PGM:
@@ -248,18 +248,18 @@ ip6_print(register const u_char *bp, register u_int length)
                        return;
 
                case IPPROTO_NONE:
-                       (void)printf("no next header");
+                       (void)ND_PRINT((ndo, "no next header"));
                        return;
 
                default:
-                       (void)printf("ip-proto-%d %d", nh, len);
+                       (void)ND_PRINT((ndo, "ip-proto-%d %d", nh, len));
                        return;
                }
        }
 
        return;
 trunc:
-       (void)printf("[|ip6]");
+       (void)ND_PRINT((ndo, "[|ip6]"));
 }
 
 #endif /* INET6 */
index 957bd4f52341ea74f0a6d4f0cde3d5d63fcd9b31..187f939d3f8c130ceef06bcc62a47767a3669579 100644 (file)
@@ -69,7 +69,7 @@ ipnet_print(struct netdissect_options *ndo, const u_char *p, u_int length, u_int
 
 #ifdef INET6
        case IPH_AF_INET6:
-               ip6_print(p, length);
+               ip6_print(ndo, p, length);
                break;
 #endif /*INET6*/
 
index ea58d8a3d0982f82ce76c84366af631822cfaef0..60bf515a5fc8954e9bd7a9b045519f55a77660f5 100644 (file)
@@ -662,7 +662,7 @@ void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
 
 #ifdef INET6
         case NLPID_IP6:
-                ip6_print(p+1, length-1);
+                ip6_print(gndo, p+1, length-1);
                 break;
 #endif
 
index 901db3238550fc5dd2570f78babf3848cde28961..3bf68c382797461a4a81fdc2eede275a1741ac9f 100644 (file)
@@ -486,7 +486,7 @@ juniper_ggsn_print(const struct pcap_pkthdr *h, register const u_char *p)
             break;
 #ifdef INET6
         case JUNIPER_PROTO_IPV6:
-            ip6_print(p, l2info.length);
+            ip6_print(gndo, p, l2info.length);
             break;
 #endif /* INET6 */
         default:
@@ -779,7 +779,7 @@ juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p)
             return l2info.header_len;
 #ifdef INET6
         case JUNIPER_LSQ_L3_PROTO_IPV6:
-            ip6_print(p,l2info.length);
+            ip6_print(gndo, p,l2info.length);
             return l2info.header_len;
 #endif
         case JUNIPER_LSQ_L3_PROTO_MPLS:
@@ -834,7 +834,7 @@ juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p)
                 return l2info.header_len;
 #ifdef INET6
             case JUNIPER_LSQ_L3_PROTO_IPV6:
-                ip6_print(p,l2info.length);
+                ip6_print(gndo, p,l2info.length);
                 return l2info.header_len;
 #endif
             case JUNIPER_LSQ_L3_PROTO_MPLS:
@@ -1073,7 +1073,7 @@ ip_heuristic_guess(register const u_char *p, u_int length) {
     case 0x6d:
     case 0x6e:
     case 0x6f:
-        ip6_print(p, length);
+        ip6_print(gndo, p, length);
         break;
 #endif
     default:
index 13ad0fddecd927765fe838ccb3c8840bcc49f6b0..d97cce5278b4871cf31df384c8122d2b3a55d7a9 100644 (file)
@@ -199,7 +199,7 @@ mpls_print(const u_char *bp, u_int length)
 
        case PT_IPV6:
 #ifdef INET6
-               ip6_print(p, length - (p - bp));
+               ip6_print(gndo, p, length - (p - bp));
 #else
                printf("IPv6, length: %u", length);
 #endif
index a69997da12e312e692dcdbb2f739403a32328921..8eabe5dd994a8c8cf3e9411f394de14d1483a296 100644 (file)
@@ -125,7 +125,7 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
        case BSD_AFNUM_INET6_BSD:
        case BSD_AFNUM_INET6_FREEBSD:
        case BSD_AFNUM_INET6_DARWIN:
-               ip6_print(p, length);
+               ip6_print(gndo, p, length);
                break;
 #endif
 
index f9fd0c69f553b9a272742a9c3e932018f6ef060c..34b1dd46ea6a69a09725627590fe9c6db10b3aa9 100644 (file)
@@ -768,7 +768,7 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
                        break;
 #ifdef INET6
                case 6: /* IPv6 */
-                       ip6_print(bp, len);
+                       ip6_print(gndo, bp, len);
                        break;
 #endif
                 default:
index 7f231ead9cdcc52d046224ac2edfbf5de6acde6d..ea8e00b244f9194d1810dc92a08791ad0f513c75 100644 (file)
@@ -1303,11 +1303,11 @@ ppp_hdlc(const u_char *p, int length)
                goto cleanup;
 #ifdef INET6
         case PPP_IPV6:
-            ip6_print(b+1, t - b - 1);
-            goto cleanup;
+               ip6_print(gndo, b+1, t - b - 1);
+               goto cleanup;
 #endif
         default: /* no luck - try next guess */
-            break;
+               break;
         }
 
         proto = EXTRACT_16BITS(b); /* next guess - load two octets */
@@ -1368,7 +1368,7 @@ handle_ppp(u_int proto, const u_char *p, int length)
 #ifdef INET6
        case ETHERTYPE_IPV6:    /*XXX*/
        case PPP_IPV6:
-               ip6_print(p, length);
+               ip6_print(gndo, p, length);
                break;
 #endif
        case ETHERTYPE_IPX:     /*XXX*/
@@ -1675,11 +1675,11 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
                        p += hdrlength;
                        switch (ptype) {
                        case PPP_IP:
-                               ip_print(p, length);
+                               ip_print(gndo, p, length);
                                break;
 #ifdef INET6
                        case PPP_IPV6:
-                               ip6_print(p, length);
+                               ip6_print(gndo, p, length);
                                break;
 #endif
                        case PPP_MPLS_UCAST:
@@ -1694,11 +1694,11 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
                        p += hdrlength;
                        switch (ptype) {
                        case PPP_IP:
-                               ip_print(p, length);
+                               ip_print(gndo, p, length);
                                break;
 #ifdef INET6
                        case PPP_IPV6:
-                               ip6_print(p, length);
+                               ip6_print(gndo, p, length);
                                break;
 #endif
                        case PPP_MPLS_UCAST:
@@ -1730,12 +1730,12 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
                break;
 #ifdef INET6
        case PPP_IPV6:
-               ip6_print(p, length);
+               ip6_print(gndo, p, length);
                break;
 #endif
         case PPP_MPLS_UCAST:
         case PPP_MPLS_MCAST:
-                mpls_print(p, length);
+                mpls_print(gndo, p, length);
                 break;
        default:
                printf("%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", ptype));
index f00d3943d320a6d4613f8ad9265210fa4238eb6a..91dbaadc275b19341a0a793dd10362420445ecc8 100644 (file)
@@ -73,7 +73,7 @@ sl_if_print(const struct pcap_pkthdr *h, const u_char *p)
                break;
 #ifdef INET6
        case 6:
-               ip6_print((u_char *)ip, length);
+               ip6_print(gndo, (u_char *)ip, length);
                break;
 #endif
        default: