X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/3c8f3e13b03380742c24070f8a7b56fe12c6b8ee..dcca20dd391f15c5c63d3b033fb7d7749bb1d8cd:/print-udp.c diff --git a/print-udp.c b/print-udp.c index e4d89e6c..1d6c5e2c 100644 --- a/print-udp.c +++ b/print-udp.c @@ -103,24 +103,24 @@ vat_print(netdissect_options *ndo, const void *hdr, register const struct udphdr u_int ts; ND_TCHECK_2((const u_int *)hdr); - ts = EXTRACT_BE_16BITS(hdr); + ts = EXTRACT_BE_U_2(hdr); if ((ts & 0xf060) != 0) { /* probably vt */ ND_TCHECK_2(&up->uh_ulen); ND_PRINT((ndo, "udp/vt %u %d / %d", - (uint32_t)(EXTRACT_BE_16BITS(&up->uh_ulen) - sizeof(*up)), + (uint32_t)(EXTRACT_BE_U_2(&up->uh_ulen) - sizeof(*up)), ts & 0x3ff, ts >> 10)); } else { /* probably vat */ uint32_t i0, i1; ND_TCHECK_4(&((const u_int *)hdr)[0]); - i0 = EXTRACT_BE_32BITS(&((const u_int *)hdr)[0]); + i0 = EXTRACT_BE_U_4(&((const u_int *)hdr)[0]); ND_TCHECK_4(&((const u_int *)hdr)[1]); - i1 = EXTRACT_BE_32BITS(&((const u_int *)hdr)[1]); + i1 = EXTRACT_BE_U_4(&((const u_int *)hdr)[1]); ND_TCHECK_2(&up->uh_ulen); ND_PRINT((ndo, "udp/vat %u c%d %u%s", - (uint32_t)(EXTRACT_BE_16BITS(&up->uh_ulen) - sizeof(*up) - 8), + (uint32_t)(EXTRACT_BE_U_2(&up->uh_ulen) - sizeof(*up) - 8), i0 & 0xffff, i1, i0 & 0x800000? "*" : "")); /* audio format */ @@ -145,11 +145,11 @@ rtp_print(netdissect_options *ndo, const void *hdr, u_int len, const char * ptype; ND_TCHECK_4(&((const u_int *)hdr)[0]); - i0 = EXTRACT_BE_32BITS(&((const u_int *)hdr)[0]); + i0 = EXTRACT_BE_U_4(&((const u_int *)hdr)[0]); ND_TCHECK_4(&((const u_int *)hdr)[1]); - i1 = EXTRACT_BE_32BITS(&((const u_int *)hdr)[1]); + i1 = EXTRACT_BE_U_4(&((const u_int *)hdr)[1]); ND_TCHECK_2(&up->uh_ulen); - dlen = EXTRACT_BE_16BITS(&up->uh_ulen) - sizeof(*up) - 8; + dlen = EXTRACT_BE_U_2(&up->uh_ulen) - sizeof(*up) - 8; ip += 2; len >>= 2; len -= 2; @@ -181,12 +181,12 @@ rtp_print(netdissect_options *ndo, const void *hdr, u_int len, i1)); if (ndo->ndo_vflag) { ND_TCHECK_4(&((const u_int *)hdr)[2]); - ND_PRINT((ndo, " %u", EXTRACT_BE_32BITS(&((const u_int *)hdr)[2]))); + ND_PRINT((ndo, " %u", EXTRACT_BE_U_4(&((const u_int *)hdr)[2]))); if (hasopt) { u_int i2, optlen; do { ND_TCHECK_4(ip); - i2 = EXTRACT_BE_32BITS(ip); + i2 = EXTRACT_BE_U_4(ip); optlen = (i2 >> 16) & 0xff; if (optlen == 0 || optlen > len) { ND_PRINT((ndo, " !opt")); @@ -199,7 +199,7 @@ rtp_print(netdissect_options *ndo, const void *hdr, u_int len, if (hasext) { u_int i2, extlen; ND_TCHECK_4(ip); - i2 = EXTRACT_BE_32BITS(ip); + i2 = EXTRACT_BE_U_4(ip); extlen = (i2 & 0xffff) + 1; if (extlen > len) { ND_PRINT((ndo, " !ext")); @@ -209,7 +209,7 @@ rtp_print(netdissect_options *ndo, const void *hdr, u_int len, } ND_TCHECK_4(ip); if (contype == 0x1f) /*XXX H.261 */ - ND_PRINT((ndo, " 0x%04x", EXTRACT_BE_32BITS(ip) >> 16)); + ND_PRINT((ndo, " 0x%04x", EXTRACT_BE_U_4(ip) >> 16)); } trunc: @@ -230,8 +230,8 @@ rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep) if ((const u_char *)(rh + 1) > ep) goto trunc; ND_TCHECK(*rh); - len = (EXTRACT_BE_16BITS(&rh->rh_len) + 1) * 4; - flags = EXTRACT_BE_16BITS(&rh->rh_flags); + len = (EXTRACT_BE_U_2(&rh->rh_len) + 1) * 4; + flags = EXTRACT_BE_U_2(&rh->rh_flags); cnt = (flags >> 8) & 0x1f; switch (flags & 0xff) { case RTCP_PT_SR: @@ -240,15 +240,15 @@ rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep) if (len != cnt * sizeof(*rr) + sizeof(*sr) + sizeof(*rh)) ND_PRINT((ndo, " [%d]", len)); if (ndo->ndo_vflag) - ND_PRINT((ndo, " %u", EXTRACT_BE_32BITS(&rh->rh_ssrc))); + ND_PRINT((ndo, " %u", EXTRACT_BE_U_4(&rh->rh_ssrc))); if ((const u_char *)(sr + 1) > ep) goto trunc; ND_TCHECK(*sr); - ts = (double)(EXTRACT_BE_32BITS(&sr->sr_ntp.upper)) + - ((double)(EXTRACT_BE_32BITS(&sr->sr_ntp.lower)) / + ts = (double)(EXTRACT_BE_U_4(&sr->sr_ntp.upper)) + + ((double)(EXTRACT_BE_U_4(&sr->sr_ntp.lower)) / 4294967296.0); - ND_PRINT((ndo, " @%.2f %u %up %ub", ts, EXTRACT_BE_32BITS(&sr->sr_ts), - EXTRACT_BE_32BITS(&sr->sr_np), EXTRACT_BE_32BITS(&sr->sr_nb))); + ND_PRINT((ndo, " @%.2f %u %up %ub", ts, EXTRACT_BE_U_4(&sr->sr_ts), + EXTRACT_BE_U_4(&sr->sr_np), EXTRACT_BE_U_4(&sr->sr_nb))); rr = (const struct rtcp_rr *)(sr + 1); break; case RTCP_PT_RR: @@ -257,18 +257,18 @@ rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep) ND_PRINT((ndo, " [%d]", len)); rr = (const struct rtcp_rr *)(rh + 1); if (ndo->ndo_vflag) - ND_PRINT((ndo, " %u", EXTRACT_BE_32BITS(&rh->rh_ssrc))); + ND_PRINT((ndo, " %u", EXTRACT_BE_U_4(&rh->rh_ssrc))); break; case RTCP_PT_SDES: ND_PRINT((ndo, " sdes %d", len)); if (ndo->ndo_vflag) - ND_PRINT((ndo, " %u", EXTRACT_BE_32BITS(&rh->rh_ssrc))); + ND_PRINT((ndo, " %u", EXTRACT_BE_U_4(&rh->rh_ssrc))); cnt = 0; break; case RTCP_PT_BYE: ND_PRINT((ndo, " bye %d", len)); if (ndo->ndo_vflag) - ND_PRINT((ndo, " %u", EXTRACT_BE_32BITS(&rh->rh_ssrc))); + ND_PRINT((ndo, " %u", EXTRACT_BE_U_4(&rh->rh_ssrc))); cnt = 0; break; default: @@ -283,13 +283,13 @@ rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep) goto trunc; ND_TCHECK(*rr); if (ndo->ndo_vflag) - ND_PRINT((ndo, " %u", EXTRACT_BE_32BITS(&rr->rr_srcid))); - ts = (double)(EXTRACT_BE_32BITS(&rr->rr_lsr)) / 65536.; - dts = (double)(EXTRACT_BE_32BITS(&rr->rr_dlsr)) / 65536.; + ND_PRINT((ndo, " %u", EXTRACT_BE_U_4(&rr->rr_srcid))); + ts = (double)(EXTRACT_BE_U_4(&rr->rr_lsr)) / 65536.; + dts = (double)(EXTRACT_BE_U_4(&rr->rr_dlsr)) / 65536.; ND_PRINT((ndo, " %ul %us %uj @%.2f+%.2f", - EXTRACT_BE_32BITS(&rr->rr_nl) & 0x00ffffff, - EXTRACT_BE_32BITS(&rr->rr_ls), - EXTRACT_BE_32BITS(&rr->rr_dv), ts, dts)); + EXTRACT_BE_U_4(&rr->rr_nl) & 0x00ffffff, + EXTRACT_BE_U_4(&rr->rr_ls), + EXTRACT_BE_U_4(&rr->rr_dv), ts, dts)); } return (hdr + len); @@ -390,8 +390,8 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length, goto trunc; } - sport = EXTRACT_BE_16BITS(&up->uh_sport); - dport = EXTRACT_BE_16BITS(&up->uh_dport); + sport = EXTRACT_BE_U_2(&up->uh_sport); + dport = EXTRACT_BE_U_2(&up->uh_dport); if (length < sizeof(struct udphdr)) { udpipaddr_print(ndo, ip, sport, dport); @@ -402,7 +402,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length, udpipaddr_print(ndo, ip, sport, dport); goto trunc; } - ulen = EXTRACT_BE_16BITS(&up->uh_ulen); + ulen = EXTRACT_BE_U_2(&up->uh_ulen); if (ulen < sizeof(struct udphdr)) { udpipaddr_print(ndo, ip, sport, dport); ND_PRINT((ndo, "truncated-udplength %d", ulen)); @@ -437,7 +437,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length, case PT_RPC: rp = (const struct sunrpc_msg *)(up + 1); - direction = (enum sunrpc_msg_type) EXTRACT_BE_32BITS(&rp->rm_direction); + direction = (enum sunrpc_msg_type) EXTRACT_BE_U_4(&rp->rm_direction); if (direction == SUNRPC_CALL) sunrpc_print(ndo, (const u_char *)rp, length, (const u_char *)ip); @@ -508,15 +508,15 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length, rp = (const struct sunrpc_msg *)(up + 1); if (ND_TTEST(rp->rm_direction)) { - direction = (enum sunrpc_msg_type) EXTRACT_BE_32BITS(&rp->rm_direction); + direction = (enum sunrpc_msg_type) EXTRACT_BE_U_4(&rp->rm_direction); if (dport == NFS_PORT && direction == SUNRPC_CALL) { - ND_PRINT((ndo, "NFS request xid %u ", EXTRACT_BE_32BITS(&rp->rm_xid))); + ND_PRINT((ndo, "NFS request xid %u ", EXTRACT_BE_U_4(&rp->rm_xid))); nfsreq_noaddr_print(ndo, (const u_char *)rp, length, (const u_char *)ip); return; } if (sport == NFS_PORT && direction == SUNRPC_REPLY) { - ND_PRINT((ndo, "NFS reply xid %u ", EXTRACT_BE_32BITS(&rp->rm_xid))); + ND_PRINT((ndo, "NFS reply xid %u ", EXTRACT_BE_U_4(&rp->rm_xid))); nfsreply_noaddr_print(ndo, (const u_char *)rp, length, (const u_char *)ip); return; @@ -539,7 +539,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length, * TCP does, and we do so for UDP-over-IPv6. */ if (IP_V(ip) == 4 && (ndo->ndo_vflag > 1)) { - udp_sum = EXTRACT_BE_16BITS(&up->uh_sum); + udp_sum = EXTRACT_BE_U_2(&up->uh_sum); if (udp_sum == 0) { ND_PRINT((ndo, "[no cksum] ")); } else if (ND_TTEST2(cp[0], length)) { @@ -557,7 +557,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length, /* for IPv6, UDP checksum is mandatory */ if (ND_TTEST2(cp[0], length)) { sum = udp6_cksum(ndo, ip6, up, length + sizeof(struct udphdr)); - udp_sum = EXTRACT_BE_16BITS(&up->uh_sum); + udp_sum = EXTRACT_BE_U_2(&up->uh_sum); if (sum != 0) { ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ",