From: Francois-Xavier Le Bail Date: Mon, 20 Nov 2017 07:05:29 +0000 (+0100) Subject: Use more the EXTRACT_8BITS() macro to fetch a one-byte value (12/n) X-Git-Tag: tcpdump-4.99-bp~1746 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/716e07e0602694c434414de78f278a2451ea92cf Use more the EXTRACT_8BITS() macro to fetch a one-byte value (12/n) In ND_PRINT() macro calls. --- diff --git a/print-aoe.c b/print-aoe.c index 19d301b9..c790ee2a 100644 --- a/print-aoe.c +++ b/print-aoe.c @@ -226,7 +226,7 @@ aoev1_query_print(netdissect_options *ndo, cp += 1; /* AoE/CCmd */ ND_TCHECK2(*cp, 1); - ND_PRINT((ndo, ", AoE: %u, CCmd: %s", (*cp & 0xF0) >> 4, + ND_PRINT((ndo, ", AoE: %u, CCmd: %s", (EXTRACT_8BITS(cp) & 0xF0) >> 4, tok2str(aoev1_ccmd_str, "Unknown (0x02x)", EXTRACT_8BITS(cp) & 0x0F))); cp += 1; /* Config String Length */ diff --git a/print-bgp.c b/print-bgp.c index 26404015..0c7e18b0 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -2126,7 +2126,7 @@ bgp_attr_print(netdissect_options *ndo, tok2str(l2vpn_encaps_values, "unknown encaps", EXTRACT_8BITS((tptr + 2))), - *(tptr+3), + EXTRACT_8BITS((tptr + 3)), EXTRACT_BE_16BITS(tptr + 4))); break; case BGP_EXT_COM_SOURCE_AS: @@ -2705,7 +2705,7 @@ bgp_notification_print(netdissect_options *ndo, EXTRACT_BE_16BITS(tptr)), EXTRACT_BE_16BITS(tptr), tok2str(bgp_safi_values, "Unknown", EXTRACT_8BITS((tptr + 2))), - *(tptr+2), + EXTRACT_8BITS((tptr + 2)), EXTRACT_BE_32BITS(tptr + 3))); } /* diff --git a/print-cdp.c b/print-cdp.c index 9b12e413..d8d654ae 100644 --- a/print-cdp.c +++ b/print-cdp.c @@ -105,7 +105,7 @@ cdp_print(netdissect_options *ndo, tptr = pptr; /* temporary pointer */ ND_TCHECK2(*tptr, CDP_HEADER_LEN); - ND_PRINT((ndo, "CDPv%u, ttl: %us", *(tptr + CDP_HEADER_VERSION_OFFSET), + ND_PRINT((ndo, "CDPv%u, ttl: %us", EXTRACT_8BITS((tptr + CDP_HEADER_VERSION_OFFSET)), *(tptr + CDP_HEADER_TTL_OFFSET))); if (ndo->ndo_vflag) ND_PRINT((ndo, ", checksum: 0x%04x (unverified), length %u", EXTRACT_BE_16BITS(tptr + CDP_HEADER_CHECKSUM_OFFSET), length)); @@ -211,7 +211,7 @@ cdp_print(netdissect_options *ndo, case 0x0e: /* ATA-186 VoIP VLAN request - incomplete doc. */ if (len < 3) goto trunc; - ND_PRINT((ndo, "app %d, vlan %d", *(tptr), EXTRACT_BE_16BITS(tptr + 1))); + ND_PRINT((ndo, "app %d, vlan %d", EXTRACT_8BITS((tptr)), EXTRACT_BE_16BITS(tptr + 1))); break; case 0x10: /* ATA-186 VoIP VLAN assignment - incomplete doc. */ ND_PRINT((ndo, "%1.2fW", cdp_get_number(tptr, len) / 1000.0)); @@ -341,7 +341,7 @@ cdp_print_addr(netdissect_options *ndo, ND_TCHECK2(*p, pl); if (p + pl > endp) goto trunc; - ND_PRINT((ndo, "pt=0x%02x, pl=%d, pb=", *(p - 2), pl)); + ND_PRINT((ndo, "pt=0x%02x, pl=%d, pb=", EXTRACT_8BITS((p - 2)), pl)); while (pl-- > 0) ND_PRINT((ndo, " %02x", *p++)); ND_TCHECK2(*p, 2); diff --git a/print-dtp.c b/print-dtp.c index 2c981fc6..43e1291e 100644 --- a/print-dtp.c +++ b/print-dtp.c @@ -57,7 +57,7 @@ dtp_print (netdissect_options *ndo, const u_char *pptr, u_int length) ND_TCHECK2(*tptr, DTP_HEADER_LEN); ND_PRINT((ndo, "DTPv%u, length %u", - (*tptr), + EXTRACT_8BITS(tptr), length)); /* diff --git a/print-eap.c b/print-eap.c index 182b81e2..895dbfe1 100644 --- a/print-eap.c +++ b/print-eap.c @@ -189,7 +189,7 @@ eap_print(netdissect_options *ndo, ND_PRINT((ndo, ", %s (%u), id %u, len %u", tok2str(eap_code_values, "unknown", type), type, - *(tptr+1), + EXTRACT_8BITS((tptr + 1)), len)); ND_TCHECK2(*tptr, len); diff --git a/print-hncp.c b/print-hncp.c index d606116d..068a2391 100644 --- a/print-hncp.c +++ b/print-hncp.c @@ -580,7 +580,7 @@ hncp_print_rec(netdissect_options *ndo, break; } ND_PRINT((ndo, " Verdict: %u Fingerprint: %s Common Name: ", - *value, + EXTRACT_8BITS(value), format_256(value + 4))); safeputs(ndo, value + 36, bodylen - 36); } diff --git a/print-ldp.c b/print-ldp.c index facb2313..ed176b70 100644 --- a/print-ldp.c +++ b/print-ldp.c @@ -446,10 +446,10 @@ ldp_tlv_print(netdissect_options *ndo, case LDP_FEC_MARTINI_IFPARM_VCCV: ND_PRINT((ndo, "\n\t\t Control Channels (0x%02x) = [%s]", - *(tptr+2), + EXTRACT_8BITS((tptr + 2)), bittok2str(ldp_fec_martini_ifparm_vccv_cc_values, "none", EXTRACT_8BITS((tptr + 2))))); ND_PRINT((ndo, "\n\t\t CV Types (0x%02x) = [%s]", - *(tptr+3), + EXTRACT_8BITS((tptr + 3)), bittok2str(ldp_fec_martini_ifparm_vccv_cv_values, "none", EXTRACT_8BITS((tptr + 3))))); break; diff --git a/print-rsvp.c b/print-rsvp.c index 1e0972a6..b37fe595 100644 --- a/print-rsvp.c +++ b/print-rsvp.c @@ -741,7 +741,7 @@ rsvp_obj_print(netdissect_options *ndo, *(obj_tptr + sizeof(struct in_addr)))); ND_PRINT((ndo, "%s Flags: [0x%02x], DestPort %u", indent, - *(obj_tptr+5), + EXTRACT_8BITS((obj_tptr + 5)), EXTRACT_BE_16BITS(obj_tptr + 6))); obj_tlen-=8; obj_tptr+=8; @@ -755,7 +755,7 @@ rsvp_obj_print(netdissect_options *ndo, *(obj_tptr + sizeof(struct in6_addr)))); ND_PRINT((ndo, "%s Flags: [0x%02x], DestPort %u", indent, - *(obj_tptr+sizeof(struct in6_addr)+1), + EXTRACT_8BITS((obj_tptr + sizeof(struct in6_addr) + 1)), EXTRACT_BE_16BITS(obj_tptr + sizeof(struct in6_addr) + 2))); obj_tlen-=20; obj_tptr+=20; @@ -1100,7 +1100,7 @@ rsvp_obj_print(netdissect_options *ndo, ND_PRINT((ndo, ", %s, %s/%u, Flags: [%s]", RSVP_OBJ_XRO_MASK_LOOSE(EXTRACT_8BITS(obj_tptr)) ? "Loose" : "Strict", ipaddr_string(ndo, obj_tptr+2), - *(obj_tptr+6), + EXTRACT_8BITS((obj_tptr + 6)), bittok2str(rsvp_obj_rro_flag_values, "none", EXTRACT_8BITS((obj_tptr + 7))))); /* rfc3209 says that this field is rsvd. */ @@ -1119,7 +1119,7 @@ rsvp_obj_print(netdissect_options *ndo, tok2str(rsvp_ctype_values, "Unknown", EXTRACT_8BITS((obj_tptr + 3)) + (256 * RSVP_OBJ_RRO)), - *(obj_tptr+3), + EXTRACT_8BITS((obj_tptr + 3)), EXTRACT_BE_32BITS(obj_tptr + 4))); } obj_tlen-=*(obj_tptr+1); @@ -1369,7 +1369,7 @@ rsvp_obj_print(netdissect_options *ndo, return-1; ND_PRINT((ndo, "%s Msg-Version: %u, length: %u", indent, - (*obj_tptr & 0xf0) >> 4, + (EXTRACT_8BITS(obj_tptr) & 0xf0) >> 4, EXTRACT_BE_16BITS(obj_tptr + 2) << 2)); obj_tptr+=4; /* get to the start of the service header */ obj_tlen-=4; @@ -1647,7 +1647,7 @@ rsvp_obj_print(netdissect_options *ndo, ND_PRINT((ndo, "%s %s TLV (0x%02x), length: %u", /* length includes header */ indent, tok2str(rsvp_obj_prop_tlv_values,"unknown",EXTRACT_8BITS(obj_tptr)), - *obj_tptr, + EXTRACT_8BITS(obj_tptr), *(obj_tptr + 1))); if (obj_tlen < *(obj_tptr+1)) return-1; @@ -1673,7 +1673,7 @@ rsvp_obj_print(netdissect_options *ndo, return-1; ND_PRINT((ndo, "%s Flags [0x%02x], epoch: %u", indent, - *obj_tptr, + EXTRACT_8BITS(obj_tptr), EXTRACT_BE_24BITS(obj_tptr + 1))); obj_tlen-=4; obj_tptr+=4; diff --git a/print-slow.c b/print-slow.c index 46de14c2..8b3dca10 100644 --- a/print-slow.c +++ b/print-slow.c @@ -292,7 +292,7 @@ slow_print(netdissect_options *ndo, if (print_version == 1) { ND_PRINT((ndo, "%sv%u, length %u", tok2str(slow_proto_values, "unknown (%u)", subtype), - *(pptr+1), + EXTRACT_8BITS((pptr + 1)), len)); } else { /* some slow protos don't have a version number in the header */ diff --git a/print-udld.c b/print-udld.c index 4b9105ba..011fd8ad 100644 --- a/print-udld.c +++ b/print-udld.c @@ -113,7 +113,7 @@ udld_print (netdissect_options *ndo, const u_char *pptr, u_int length) tok2str(udld_code_values, "Reserved", code), code, bittok2str(udld_flags_values, "none", EXTRACT_8BITS((tptr + 1))), - *(tptr+1), + EXTRACT_8BITS((tptr + 1)), length)); /*