]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Keep the remaining payload length in a separate variable from the total
authorguy <guy>
Wed, 19 Nov 2003 06:17:36 +0000 (06:17 +0000)
committerguy <guy>
Wed, 19 Nov 2003 06:17:36 +0000 (06:17 +0000)
payload length, so we can report the latter at the end of dissection.

print-ip6.c

index 4f9129b45807064a8d06ee3c31b96a8d4008b778..c1763e3ab1da9edfcdfd635ff2c9408da8838b73 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.32.2.5 2003-11-19 01:28:19 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.32.2.6 2003-11-19 06:17:36 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -51,9 +51,10 @@ ip6_print(register const u_char *bp, register u_int length)
 {
        register const struct ip6_hdr *ip6;
        register int advance;
 {
        register const struct ip6_hdr *ip6;
        register int advance;
-       register u_int len;
+       u_int len;
        const u_char *ipend;
        register const u_char *cp;
        const u_char *ipend;
        register const u_char *cp;
+       register u_int payload_len;
        int nh;
        int fragmented = 0;
        u_int flow;
        int nh;
        int fragmented = 0;
        u_int flow;
@@ -79,11 +80,12 @@ ip6_print(register const u_char *bp, register u_int length)
                snapend = ipend;
 
        cp = (const u_char *)ip6;
                snapend = ipend;
 
        cp = (const u_char *)ip6;
+       payload_len = len;
        advance = sizeof(struct ip6_hdr);
        nh = ip6->ip6_nxt;
        while (cp < snapend && advance > 0) {
                cp += advance;
        advance = sizeof(struct ip6_hdr);
        nh = ip6->ip6_nxt;
        while (cp < snapend && advance > 0) {
                cp += advance;
-               len -= advance;
+               payload_len -= advance;
 
                if (cp == (const u_char *)(ip6 + 1) &&
                    nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
 
                if (cp == (const u_char *)(ip6 + 1) &&
                    nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
@@ -122,16 +124,19 @@ ip6_print(register const u_char *bp, register u_int length)
                        nh = *cp;
                        break;
                case IPPROTO_SCTP:
                        nh = *cp;
                        break;
                case IPPROTO_SCTP:
-                       sctp_print(cp, (const u_char *)ip6, len);
+                       sctp_print(cp, (const u_char *)ip6, payload_len);
                        goto end;
                case IPPROTO_TCP:
                        goto end;
                case IPPROTO_TCP:
-                       tcp_print(cp, len, (const u_char *)ip6, fragmented);
+                       tcp_print(cp, payload_len, (const u_char *)ip6,
+                           fragmented);
                        goto end;
                case IPPROTO_UDP:
                        goto end;
                case IPPROTO_UDP:
-                       udp_print(cp, len, (const u_char *)ip6, fragmented);
+                       udp_print(cp, payload_len, (const u_char *)ip6,
+                           fragmented);
                        goto end;
                case IPPROTO_ICMPV6:
                        goto end;
                case IPPROTO_ICMPV6:
-                       icmp6_print(cp, len, (const u_char *)ip6, fragmented);
+                       icmp6_print(cp, payload_len, (const u_char *)ip6,
+                           fragmented);
                        goto end;
                case IPPROTO_AH:
                        advance = ah_print(cp);
                        goto end;
                case IPPROTO_AH:
                        advance = ah_print(cp);
@@ -154,18 +159,18 @@ ip6_print(register const u_char *bp, register u_int length)
                    }
 
                case IPPROTO_PIM:
                    }
 
                case IPPROTO_PIM:
-                       pim_print(cp, len);
+                       pim_print(cp, payload_len);
                        goto end;
                case IPPROTO_OSPF:
                        goto end;
                case IPPROTO_OSPF:
-                       ospf6_print(cp, len);
+                       ospf6_print(cp, payload_len);
                        goto end;
 
                case IPPROTO_IPV6:
                        goto end;
 
                case IPPROTO_IPV6:
-                       ip6_print(cp, len);
+                       ip6_print(cp, payload_len);
                        goto end;
 
                case IPPROTO_IPV4:
                        goto end;
 
                case IPPROTO_IPV4:
-                       ip_print(cp, len);
+                       ip_print(cp, payload_len);
                        goto end;
 
                case IPPROTO_NONE:
                        goto end;
 
                case IPPROTO_NONE:
@@ -173,7 +178,8 @@ ip6_print(register const u_char *bp, register u_int length)
                        goto end;
 
                default:
                        goto end;
 
                default:
-                       (void)printf("ip-proto-%d %d", ip6->ip6_nxt, len);
+                       (void)printf("ip-proto-%d %d", ip6->ip6_nxt,
+                           payload_len);
                        goto end;
                }
        }
                        goto end;
                }
        }