]> The Tcpdump Group git mirrors - tcpdump/commitdiff
"icmp6_rrenum_print()" doesn't use its "icmp6len" argument (and, as that
authorguy <guy>
Wed, 19 Nov 2003 01:27:54 +0000 (01:27 +0000)
committerguy <guy>
Wed, 19 Nov 2003 01:27:54 +0000 (01:27 +0000)
just reflects the payload length, the snapshot length has been trimmed
to correspond to it, so it doesn't need to check it merely to avoid
running past the end of the IPv6 payload); get rid of it.

Pass "icmp6_print()" the IPv6 payload length (i.e., the length of the
ICMPv6 packet), rather than having it compre the length itself.

Make the length argument to "icmp6_cksum()" unsigned, to match the value
passed to it.

Fix the lengths passed to "sctp_print()", "tcp_print()", and
"udp_print()" (we update "len" in the header-processing loop to
correspond to the remaining payload, so we just pass it to those
routines).

interface.h
print-icmp6.c
print-ip6.c

index fe5bdc3f63877a1411cc23342fbd3b015cf9d3d6..840311a71ade06424974a06db00ac0411ca266d2 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.219 2003-11-18 23:26:37 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.220 2003-11-19 01:27:54 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -314,7 +314,7 @@ extern int hbhopt_print(const u_char *);
 extern int dstopt_print(const u_char *);
 extern int frag6_print(const u_char *, const u_char *);
 extern int mobility_print(const u_char *, const u_char *);
-extern void icmp6_print(const u_char *, const u_char *, int);
+extern void icmp6_print(const u_char *, u_int, const u_char *, int);
 extern void ripng_print(const u_char *, unsigned int);
 extern int rt6_print(const u_char *, const u_char *);
 extern void ospf6_print(const u_char *, u_int);
index 0585e1491ad4cb1c2b664094e323532b7e8809f5..13df7f0e232c16826496ebc0a4d71156e6827c5d 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.74 2003-11-16 09:36:22 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.75 2003-11-19 01:27:55 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -54,7 +54,7 @@ static void mld6_print(const u_char *);
 static struct udphdr *get_upperlayer(u_char *, u_int *);
 static void dnsname_print(const u_char *, const u_char *);
 static void icmp6_nodeinfo_print(u_int, const u_char *, const u_char *);
-static void icmp6_rrenum_print(u_int, const u_char *, const u_char *);
+static void icmp6_rrenum_print(const u_char *, const u_char *);
 
 #ifndef abs
 #define abs(a) ((0 < (a)) ? (a) : -(a))
@@ -102,7 +102,7 @@ print_lladdr(const u_int8_t *p, size_t l)
 }
 
 static int icmp6_cksum(const struct ip6_hdr *ip6, const struct icmp6_hdr *icp,
-       int len)
+       u_int len)
 {
        size_t i;
        register const u_int16_t *sp;
@@ -145,7 +145,7 @@ static int icmp6_cksum(const struct ip6_hdr *ip6, const struct icmp6_hdr *icp,
 }
 
 void
-icmp6_print(const u_char *bp, const u_char *bp2, int fragmented)
+icmp6_print(const u_char *bp, u_int length, const u_char *bp2, int fragmented)
 {
        const struct icmp6_hdr *dp;
        const struct ip6_hdr *ip;
@@ -155,7 +155,7 @@ icmp6_print(const u_char *bp, const u_char *bp2, int fragmented)
        int dport;
        const u_char *ep;
        char buf[256];
-       u_int icmp6len, prot;
+       u_int prot;
 
        dp = (struct icmp6_hdr *)bp;
        ip = (struct ip6_hdr *)bp2;
@@ -163,19 +163,14 @@ icmp6_print(const u_char *bp, const u_char *bp2, int fragmented)
        str = buf;
        /* 'ep' points to the end of available data. */
        ep = snapend;
-       if (ip->ip6_plen)
-               icmp6len = (EXTRACT_16BITS(&ip->ip6_plen) + sizeof(struct ip6_hdr) -
-                           (bp - bp2));
-       else                    /* XXX: jumbo payload case... */
-               icmp6len = snapend - bp;
 
        TCHECK(dp->icmp6_cksum);
 
        if (vflag && !fragmented) {
                int sum = dp->icmp6_cksum;
 
-               if (TTEST2(bp[0], icmp6len)) {
-                       sum = icmp6_cksum(ip, dp, icmp6len);
+               if (TTEST2(bp[0], length)) {
+                       sum = icmp6_cksum(ip, dp, length);
                        if (sum != 0)
                                (void)printf("[bad icmp6 cksum %x!] ", sum);
                        else
@@ -301,7 +296,7 @@ icmp6_print(const u_char *bp, const u_char *bp2, int fragmented)
                if (vflag) {
 #define RTSOLLEN 8
                        icmp6_opt_print((const u_char *)dp + RTSOLLEN,
-                                       icmp6len - RTSOLLEN);
+                                       length - RTSOLLEN);
                }
                break;
        case ND_ROUTER_ADVERT:
@@ -333,7 +328,7 @@ icmp6_print(const u_char *bp, const u_char *bp2, int fragmented)
                                EXTRACT_32BITS(&p->nd_ra_retransmit));
 #define RTADVLEN 16
                        icmp6_opt_print((const u_char *)dp + RTADVLEN,
-                                       icmp6len - RTADVLEN);
+                                       length - RTADVLEN);
                }
                break;
        case ND_NEIGHBOR_SOLICIT:
@@ -346,7 +341,7 @@ icmp6_print(const u_char *bp, const u_char *bp2, int fragmented)
                if (vflag) {
 #define NDSOLLEN 24
                        icmp6_opt_print((const u_char *)dp + NDSOLLEN,
-                                       icmp6len - NDSOLLEN);
+                                       length - NDSOLLEN);
                }
            }
                break;
@@ -378,7 +373,7 @@ icmp6_print(const u_char *bp, const u_char *bp2, int fragmented)
                        }
 #define NDADVLEN 24
                        icmp6_opt_print((const u_char *)dp + NDADVLEN,
-                                       icmp6len - NDADVLEN);
+                                       length - NDADVLEN);
 #undef NDADVLEN
                }
            }
@@ -393,17 +388,17 @@ icmp6_print(const u_char *bp, const u_char *bp2, int fragmented)
 #define REDIRECTLEN 40
                if (vflag) {
                        icmp6_opt_print((const u_char *)dp + REDIRECTLEN,
-                                       icmp6len - REDIRECTLEN);
+                                       length - REDIRECTLEN);
                }
                break;
 #undef REDIRECTLEN
 #undef RDR
        case ICMP6_ROUTER_RENUMBERING:
-               icmp6_rrenum_print(icmp6len, bp, ep);
+               icmp6_rrenum_print(bp, ep);
                break;
        case ICMP6_NI_QUERY:
        case ICMP6_NI_REPLY:
-               icmp6_nodeinfo_print(icmp6len, bp, ep);
+               icmp6_nodeinfo_print(length, bp, ep);
                break;
        case ICMP6_HADISCOV_REQUEST:
                printf("icmp6: ha discovery request");
@@ -420,7 +415,7 @@ icmp6_print(const u_char *bp, const u_char *bp2, int fragmented)
 
                        TCHECK(dp->icmp6_data16[0]);
                        printf("(id=%d", EXTRACT_16BITS(&dp->icmp6_data16[0]));
-                       cp = (u_char *)dp + icmp6len;
+                       cp = (u_char *)dp + length;
                        in6 = (struct in6_addr *)(dp + 1);
                        for (; (u_char *)in6 < cp; in6++) {
                                TCHECK(*in6);
@@ -450,7 +445,7 @@ icmp6_print(const u_char *bp, const u_char *bp2, int fragmented)
                        printf(")");
 #define MPADVLEN 8
                        icmp6_opt_print((const u_char *)dp + MPADVLEN,
-                                       icmp6len - MPADVLEN);
+                                       length - MPADVLEN);
                }
                break;
        default:
@@ -999,7 +994,7 @@ trunc:
 }
 
 static void
-icmp6_rrenum_print(u_int icmp6len, const u_char *bp, const u_char *ep)
+icmp6_rrenum_print(const u_char *bp, const u_char *ep)
 {
        struct icmp6_router_renum *rr6;
        struct icmp6_hdr *dp;
index a566093376de615966f4dbf2cadeed82217168d6..d0722a7fe90a9210fc601e549e40cc4ad7053c93 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.36 2003-11-19 00:36:07 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.37 2003-11-19 01:27:55 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -122,19 +122,16 @@ ip6_print(register const u_char *bp, register u_int length)
                        nh = *cp;
                        break;
                case IPPROTO_SCTP:
-                       sctp_print(cp, (const u_char *)ip6, 
-                               len + sizeof(struct ip6_hdr) - (cp - bp));
+                       sctp_print(cp, (const u_char *)ip6, len);
                        goto end;
                case IPPROTO_TCP:
-                       tcp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp),
-                               (const u_char *)ip6, fragmented);
+                       tcp_print(cp, len, (const u_char *)ip6, fragmented);
                        goto end;
                case IPPROTO_UDP:
-                       udp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp),
-                               (const u_char *)ip6, fragmented);
+                       udp_print(cp, len, (const u_char *)ip6, fragmented);
                        goto end;
                case IPPROTO_ICMPV6:
-                       icmp6_print(cp, (const u_char *)ip6, fragmented);
+                       icmp6_print(cp, len, (const u_char *)ip6, fragmented);
                        goto end;
                case IPPROTO_AH:
                        advance = ah_print(cp);