summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump/print-icmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tcpdump/print-icmp.c')
-rw-r--r--contrib/tcpdump/print-icmp.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/contrib/tcpdump/print-icmp.c b/contrib/tcpdump/print-icmp.c
index 811d599..f064485 100644
--- a/contrib/tcpdump/print-icmp.c
+++ b/contrib/tcpdump/print-icmp.c
@@ -348,6 +348,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header;
u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype;
char buf[MAXHOSTNAMELEN + 100];
+ struct cksum_vec vec[1];
dp = (struct icmp *)bp;
ext_dp = (struct icmp_ext_t *)bp;
@@ -562,8 +563,11 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
(void)printf("ICMP %s, length %u", str, plen);
if (vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
u_int16_t sum, icmp_sum;
+ struct cksum_vec vec[1];
if (TTEST2(*bp, plen)) {
- sum = in_cksum((u_short*)dp, plen, 0);
+ vec[0].ptr = (const u_int8_t *)(void *)dp;
+ vec[0].len = plen;
+ sum = in_cksum(vec, 1);
if (sum != 0) {
icmp_sum = EXTRACT_16BITS(&dp->icmp_cksum);
(void)printf(" (wrong icmp cksum %x (->%x)!)",
@@ -600,10 +604,12 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
* to check if an extension header is present. This is expedient,
* however not all implementations set the length field proper.
*/
- if (!ext_dp->icmp_length &&
- in_cksum((const u_short *)&ext_dp->icmp_ext_version_res,
- plen - ICMP_EXTD_MINLEN, 0)) {
- return;
+ if (!ext_dp->icmp_length) {
+ vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res;
+ vec[0].len = plen - ICMP_EXTD_MINLEN;
+ if (in_cksum(vec, 1)) {
+ return;
+ }
}
printf("\n\tMPLS extension v%u",
@@ -619,10 +625,11 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
}
hlen = plen - ICMP_EXTD_MINLEN;
+ vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res;
+ vec[0].len = hlen;
printf(", checksum 0x%04x (%scorrect), length %u",
EXTRACT_16BITS(ext_dp->icmp_ext_checksum),
- in_cksum((const u_short *)&ext_dp->icmp_ext_version_res,
- plen - ICMP_EXTD_MINLEN, 0) ? "in" : "",
+ in_cksum(vec, 1) ? "in" : "",
hlen);
hlen -= 4; /* subtract common header size */
OpenPOWER on IntegriCloud