]> 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:28:18 +0000 (01:28 +0000)
committerguy <guy>
Wed, 19 Nov 2003 01:28:18 +0000 (01:28 +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 c2c1f5c36023b8738e14d80001ac1e10a2ad1702..eab0a21ad737ad9dabb428283ead34abc5dfe30e 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.217.2.2 2003-11-18 23:26:14 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.217.2.3 2003-11-19 01:28:18 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
  */
 
 #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 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);
 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 4fb3215c82dd41d2211acb83e2e503e9a796a143..6f4697f9375dd51eb7b9a72bcd00b9c3c9a33660 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-icmp6.c,v 1.72.2.2 2003-11-16 08:51:25 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.72.2.3 2003-11-19 01:28:19 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #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 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))
 
 #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,
 }
 
 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;
 {
        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
 }
 
 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;
 {
        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];
        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;
 
        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;
        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;
 
 
        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
                        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,
                if (vflag) {
 #define RTSOLLEN 8
                        icmp6_opt_print((const u_char *)dp + RTSOLLEN,
-                                       icmp6len - RTSOLLEN);
+                                       length - RTSOLLEN);
                }
                break;
        case ND_ROUTER_ADVERT:
                }
                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,
                                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:
                }
                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,
                if (vflag) {
 #define NDSOLLEN 24
                        icmp6_opt_print((const u_char *)dp + NDSOLLEN,
-                                       icmp6len - NDSOLLEN);
+                                       length - NDSOLLEN);
                }
            }
                break;
                }
            }
                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,
                        }
 #define NDADVLEN 24
                        icmp6_opt_print((const u_char *)dp + NDADVLEN,
-                                       icmp6len - NDADVLEN);
+                                       length - NDADVLEN);
 #undef 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,
 #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:
                }
                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:
                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");
                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]));
 
                        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);
                        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,
                        printf(")");
 #define MPADVLEN 8
                        icmp6_opt_print((const u_char *)dp + MPADVLEN,
-                                       icmp6len - MPADVLEN);
+                                       length - MPADVLEN);
                }
                break;
        default:
                }
                break;
        default:
@@ -999,7 +994,7 @@ trunc:
 }
 
 static void
 }
 
 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;
 {
        struct icmp6_router_renum *rr6;
        struct icmp6_hdr *dp;
index 1916c17fa9cdad4f74ba5a0088d47a009447bd8e..4f9129b45807064a8d06ee3c31b96a8d4008b778 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.4 2003-11-19 00:35:44 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.32.2.5 2003-11-19 01:28:19 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
 #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:
                        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:
                        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:
                        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:
                        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);
                        goto end;
                case IPPROTO_AH:
                        advance = ah_print(cp);