]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ip.c
Add test pcap+output for nested and recursive pathdata
[tcpdump] / print-ip.c
index 847868402a73d7a9aa01ca4c8f6d605a09f3e0e3..f42276dc71ade61b4413ffb9ba8e3b4a75d51d8f 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.155 2006-02-19 05:00:19 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.159 2007-09-14 01:29:28 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -50,6 +50,7 @@ struct tok ip_option_values[] = {
     { IPOPT_SSRR, "SSRR" },
     { IPOPT_LSRR, "LSRR" },
     { IPOPT_RA, "RA" },
+    { IPOPT_RFC1393, "traceroute" },
     { 0, NULL }
 };
 
@@ -479,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;
@@ -489,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*/
 
@@ -507,7 +508,8 @@ again:
                break;
 
        case IPPROTO_PIM:
-               pim_print(ipds->cp,  ipds->len);
+               pim_print(ipds->cp,  ipds->len,
+                         in_cksum((const u_short*)ipds->cp, ipds->len, 0));
                break;
 
        case IPPROTO_VRRP:
@@ -571,7 +573,7 @@ ip_print(netdissect_options *ndo,
         else if (!eflag)
            printf("IP ");
 
-       if ((u_char *)(ipds->ip + 1) > snapend) {
+       if ((u_char *)(ipds->ip + 1) > ndo->ndo_snapend) {
                printf("[|ip]");
                return;
        }
@@ -609,8 +611,8 @@ ip_print(netdissect_options *ndo,
         * Cut off the snapshot length to the end of the IP payload.
         */
        ipend = bp + ipds->len;
-       if (ipend < snapend)
-               snapend = ipend;
+       if (ipend < ndo->ndo_snapend)
+               ndo->ndo_snapend = ipend;
 
        ipds->len -= hlen;
 
@@ -633,7 +635,7 @@ ip_print(netdissect_options *ndo,
             }
 
             if (ipds->ip->ip_ttl >= 1)
-                (void)printf(", ttl %3u", ipds->ip->ip_ttl);    
+                (void)printf(", ttl %u", ipds->ip->ip_ttl);    
 
            /*
             * for the firewall guys, print id, offset.
@@ -641,14 +643,14 @@ ip_print(netdissect_options *ndo,
             * For unfragmented datagrams, note the don't fragment flag.
             */
 
-           (void)printf(", id %u, offset %u, flags [%s], proto: %s (%u)",
+           (void)printf(", id %u, offset %u, flags [%s], proto %s (%u)",
                          EXTRACT_16BITS(&ipds->ip->ip_id),
                          (ipds->off & 0x1fff) * 8,
-                         bittok2str(ip_frag_values, "none", ipds->off&0xe000 ),
+                         bittok2str(ip_frag_values, "none", ipds->off&0xe000),
                          tok2str(ipproto_values,"unknown",ipds->ip->ip_p),
                          ipds->ip->ip_p);
 
-            (void)printf(", length: %u", EXTRACT_16BITS(&ipds->ip->ip_len));
+            (void)printf(", length %u", EXTRACT_16BITS(&ipds->ip->ip_len));
 
             if ((hlen - sizeof(struct ip)) > 0) {
                 printf(", options (");
@@ -656,7 +658,7 @@ ip_print(netdissect_options *ndo,
                 printf(")");
             }
 
-           if ((u_char *)ipds->ip + hlen <= snapend) {
+           if (!Kflag && (u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
                sum = in_cksum((const u_short *)ipds->ip, hlen, 0);
                if (sum != 0) {
                    ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum);
@@ -665,7 +667,7 @@ ip_print(netdissect_options *ndo,
                }
            }
 
-            printf(") ");
+            printf(")\n    ");
        }
 
        /*
@@ -720,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: