]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-icmp.c
Not all systems have "sa_family_t"; use "u_int8_t" instead.
[tcpdump] / print-icmp.c
index df0970c80bf78c86effad19b5704893d1c9bd71b..a8e21b0ac28826cd6af687ede14cd6d67aa88158 100644 (file)
@@ -20,8 +20,8 @@
  */
 
 #ifndef lint
-static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.71 2002-12-11 07:14:01 guy Exp $ (LBL)";
+static const char rcsid[] _U_ =
+    "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.73.2.3 2004-03-24 00:56:34 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -39,6 +39,7 @@ static const char rcsid[] =
 
 #include "ip.h"
 #include "udp.h"
+#include "ipproto.h"
 
 /*
  * Interface Control Message Protocol Definitions.
@@ -260,7 +261,7 @@ struct id_rdiscovery {
 };
 
 void
-icmp_print(const u_char *bp, u_int plen, const u_char *bp2)
+icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
 {
        char *cp;
        const struct icmp *dp;
@@ -304,6 +305,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2)
                        oip = &dp->icmp_ip;
                        hlen = IP_HL(oip) * 4;
                        ouh = (struct udphdr *)(((u_char *)oip) + hlen);
+                       TCHECK(ouh->uh_dport);
                        dport = EXTRACT_16BITS(&ouh->uh_dport);
                        switch (oip->ip_p) {
 
@@ -476,7 +478,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2)
                break;
        }
        (void)printf("icmp %d: %s", plen, str);
-       if (vflag) {
+       if (vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
                u_int16_t sum, icmp_sum;
                if (TTEST2(*bp, plen)) {
                        sum = in_cksum((u_short*)dp, plen, 0);