X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/da20bc56d6100b5275d6f85c4a25bac1dab4e57e..1a04b92e365f5ed01ca38619b41bcc4fc9cbd63c:/print-icmp.c?ds=sidebyside diff --git a/print-icmp.c b/print-icmp.c index b949ffb1..a9a72014 100644 --- a/print-icmp.c +++ b/print-icmp.c @@ -336,6 +336,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * const struct ip *ip; const char *str, *fmt; const struct ip *oip; + uint8_t ip_proto; const struct udphdr *ouh; const uint8_t *obj_tptr; uint32_t raw_label; @@ -368,11 +369,11 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * switch (dp->icmp_code) { case ICMP_UNREACH_PROTOCOL: - ND_TCHECK(dp->icmp_ip.ip_p); + ND_TCHECK_1(dp->icmp_ip.ip_p); (void)snprintf(buf, sizeof(buf), "%s protocol %d unreachable", ipaddr_string(ndo, &dp->icmp_ip.ip_dst), - dp->icmp_ip.ip_p); + EXTRACT_U_1(dp->icmp_ip.ip_p)); break; case ICMP_UNREACH_PORT: @@ -382,7 +383,8 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * ouh = (const struct udphdr *)(((const u_char *)oip) + hlen); ND_TCHECK(ouh->uh_dport); dport = EXTRACT_BE_U_2(&ouh->uh_dport); - switch (oip->ip_p) { + ip_proto = EXTRACT_U_1(oip->ip_p); + switch (ip_proto) { case IPPROTO_TCP: (void)snprintf(buf, sizeof(buf), @@ -402,14 +404,14 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * (void)snprintf(buf, sizeof(buf), "%s protocol %u port %u unreachable", ipaddr_string(ndo, &oip->ip_dst), - oip->ip_p, dport); + ip_proto, dport); break; } break; case ICMP_UNREACH_NEEDFRAG: { - register const struct mtu_discovery *mp; + const struct mtu_discovery *mp; mp = (const struct mtu_discovery *)(const u_char *)&dp->icmp_void; mtu = EXTRACT_BE_U_2(&mp->nexthopmtu); if (mtu) { @@ -444,8 +446,8 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * case ICMP_ROUTERADVERT: { - register const struct ih_rdiscovery *ihp; - register const struct id_rdiscovery *idp; + const struct ih_rdiscovery *ihp; + const struct id_rdiscovery *idp; u_int lifetime, num, size; (void)snprintf(buf, sizeof(buf), "router advertisement"); @@ -557,7 +559,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * } ND_PRINT((ndo, "ICMP %s, length %u", str, plen)); if (ndo->ndo_vflag && !fragmented) { /* don't attempt checksumming if this is a frag */ - if (ND_TTEST2(*bp, plen)) { + if (ND_TTEST_LEN(bp, plen)) { uint16_t sum; vec[0].ptr = (const uint8_t *)(const void *)dp; @@ -600,7 +602,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * * however not all implementations set the length field proper. */ if (!ext_dp->icmp_length && - ND_TTEST2(ext_dp->icmp_ext_version_res, plen - ICMP_EXTD_MINLEN)) { + ND_TTEST_LEN(ext_dp->icmp_ext_version_res, plen - ICMP_EXTD_MINLEN)) { vec[0].ptr = (const uint8_t *)(const void *)&ext_dp->icmp_ext_version_res; vec[0].len = plen - ICMP_EXTD_MINLEN; if (in_cksum(vec, 1)) { @@ -621,7 +623,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * } hlen = plen - ICMP_EXTD_MINLEN; - if (ND_TTEST2(ext_dp->icmp_ext_version_res, hlen)) { + if (ND_TTEST_LEN(ext_dp->icmp_ext_version_res, hlen)) { vec[0].ptr = (const uint8_t *)(const void *)&ext_dp->icmp_ext_version_res; vec[0].len = hlen; ND_PRINT((ndo, ", checksum 0x%04x (%scorrect), length %u", @@ -661,7 +663,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char * case 1: switch(obj_ctype) { case 1: - ND_TCHECK2(*obj_tptr, 4); + ND_TCHECK_4(obj_tptr); raw_label = EXTRACT_BE_U_4(obj_tptr); ND_PRINT((ndo, "\n\t label %u, exp %u", MPLS_LABEL(raw_label), MPLS_EXP(raw_label))); if (MPLS_STACK(raw_label))