return;
}
ND_TCHECK_2((const u_int *)hdr);
- ts = EXTRACT_BE_U_2(hdr);
+ ts = GET_BE_U_2(hdr);
if ((ts & 0xf060) != 0) {
/* probably vt */
ND_PRINT("udp/vt %u %u / %u",
return;
}
ND_TCHECK_4(&((const u_int *)hdr)[0]);
- i0 = EXTRACT_BE_U_4(&((const u_int *)hdr)[0]);
+ i0 = GET_BE_U_4(&((const u_int *)hdr)[0]);
ND_TCHECK_4(&((const u_int *)hdr)[1]);
- i1 = EXTRACT_BE_U_4(&((const u_int *)hdr)[1]);
+ i1 = GET_BE_U_4(&((const u_int *)hdr)[1]);
ND_PRINT("udp/vat %u c%u %u%s",
length - 8,
i0 & 0xffff,
return;
}
ND_TCHECK_4(&((const u_int *)hdr)[0]);
- i0 = EXTRACT_BE_U_4(&((const u_int *)hdr)[0]);
+ i0 = GET_BE_U_4(&((const u_int *)hdr)[0]);
ND_TCHECK_4(&((const u_int *)hdr)[1]);
- i1 = EXTRACT_BE_U_4(&((const u_int *)hdr)[1]);
+ i1 = GET_BE_U_4(&((const u_int *)hdr)[1]);
dlen = len - 8;
ip += 2;
len >>= 2;
i1);
if (ndo->ndo_vflag) {
ND_TCHECK_4(&((const u_int *)hdr)[2]);
- ND_PRINT(" %u", EXTRACT_BE_U_4(&((const u_int *)hdr)[2]));
+ ND_PRINT(" %u", GET_BE_U_4(&((const u_int *)hdr)[2]));
if (hasopt) {
u_int i2, optlen;
do {
ND_TCHECK_4(ip);
- i2 = EXTRACT_BE_U_4(ip);
+ i2 = GET_BE_U_4(ip);
optlen = (i2 >> 16) & 0xff;
if (optlen == 0 || optlen > len) {
ND_PRINT(" !opt");
if (hasext) {
u_int i2, extlen;
ND_TCHECK_4(ip);
- i2 = EXTRACT_BE_U_4(ip);
+ i2 = GET_BE_U_4(ip);
extlen = (i2 & 0xffff) + 1;
if (extlen > len) {
ND_PRINT(" !ext");
}
ND_TCHECK_4(ip);
if (contype == 0x1f) /*XXX H.261 */
- ND_PRINT(" 0x%04x", EXTRACT_BE_U_4(ip) >> 16);
+ ND_PRINT(" 0x%04x", GET_BE_U_4(ip) >> 16);
}
return;
if ((const u_char *)(rh + 1) > ep)
goto trunc;
ND_TCHECK_SIZE(rh);
- len = (EXTRACT_BE_U_2(rh->rh_len) + 1) * 4;
- flags = EXTRACT_BE_U_2(rh->rh_flags);
+ len = (GET_BE_U_2(rh->rh_len) + 1) * 4;
+ flags = GET_BE_U_2(rh->rh_flags);
cnt = (flags >> 8) & 0x1f;
switch (flags & 0xff) {
case RTCP_PT_SR:
if (len != cnt * sizeof(*rr) + sizeof(*sr) + sizeof(*rh))
ND_PRINT(" [%u]", len);
if (ndo->ndo_vflag)
- ND_PRINT(" %u", EXTRACT_BE_U_4(rh->rh_ssrc));
+ ND_PRINT(" %u", GET_BE_U_4(rh->rh_ssrc));
if ((const u_char *)(sr + 1) > ep)
goto trunc;
ND_TCHECK_SIZE(sr);
- ts = (double)(EXTRACT_BE_U_4(sr->sr_ntp.upper)) +
- ((double)(EXTRACT_BE_U_4(sr->sr_ntp.lower)) /
+ ts = (double)(GET_BE_U_4(sr->sr_ntp.upper)) +
+ ((double)(GET_BE_U_4(sr->sr_ntp.lower)) /
4294967296.0);
- ND_PRINT(" @%.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));
+ ND_PRINT(" @%.2f %u %up %ub", ts, GET_BE_U_4(sr->sr_ts),
+ GET_BE_U_4(sr->sr_np), GET_BE_U_4(sr->sr_nb));
rr = (const struct rtcp_rr *)(sr + 1);
break;
case RTCP_PT_RR:
ND_PRINT(" [%u]", len);
rr = (const struct rtcp_rr *)(rh + 1);
if (ndo->ndo_vflag)
- ND_PRINT(" %u", EXTRACT_BE_U_4(rh->rh_ssrc));
+ ND_PRINT(" %u", GET_BE_U_4(rh->rh_ssrc));
break;
case RTCP_PT_SDES:
ND_PRINT(" sdes %u", len);
if (ndo->ndo_vflag)
- ND_PRINT(" %u", EXTRACT_BE_U_4(rh->rh_ssrc));
+ ND_PRINT(" %u", GET_BE_U_4(rh->rh_ssrc));
cnt = 0;
break;
case RTCP_PT_BYE:
ND_PRINT(" bye %u", len);
if (ndo->ndo_vflag)
- ND_PRINT(" %u", EXTRACT_BE_U_4(rh->rh_ssrc));
+ ND_PRINT(" %u", GET_BE_U_4(rh->rh_ssrc));
cnt = 0;
break;
default:
goto trunc;
ND_TCHECK_SIZE(rr);
if (ndo->ndo_vflag)
- ND_PRINT(" %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(" %u", GET_BE_U_4(rr->rr_srcid));
+ ts = (double)(GET_BE_U_4(rr->rr_lsr)) / 65536.;
+ dts = (double)(GET_BE_U_4(rr->rr_dlsr)) / 65536.;
ND_PRINT(" %ul %us %uj @%.2f+%.2f",
- EXTRACT_BE_U_4(rr->rr_nl) & 0x00ffffff,
- EXTRACT_BE_U_4(rr->rr_ls),
- EXTRACT_BE_U_4(rr->rr_dv), ts, dts);
+ GET_BE_U_4(rr->rr_nl) & 0x00ffffff,
+ GET_BE_U_4(rr->rr_ls),
+ GET_BE_U_4(rr->rr_dv), ts, dts);
cnt--;
}
return (hdr + len);
return ep;
}
-static int udp_cksum(netdissect_options *ndo, const struct ip *ip,
+static uint16_t udp_cksum(netdissect_options *ndo, const struct ip *ip,
const struct udphdr *up,
u_int len)
{
IPPROTO_UDP);
}
-static int udp6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6,
+static uint16_t udp6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6,
const struct udphdr *up, u_int len)
{
return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)up, len, len,
ip6 = NULL;
if (ip6) {
- if (EXTRACT_U_1(ip6->ip6_nxt) == IPPROTO_UDP) {
+ if (GET_U_1(ip6->ip6_nxt) == IPPROTO_UDP) {
if (sport == -1) {
ND_PRINT("%s > %s: ",
ip6addr_string(ndo, ip6->ip6_src),
} else {
ND_PRINT("%s.%s > %s.%s: ",
ip6addr_string(ndo, ip6->ip6_src),
- udpport_string(ndo, sport),
+ udpport_string(ndo, (uint16_t)sport),
ip6addr_string(ndo, ip6->ip6_dst),
- udpport_string(ndo, dport));
+ udpport_string(ndo, (uint16_t)dport));
}
} else {
if (sport != -1) {
ND_PRINT("%s > %s: ",
- udpport_string(ndo, sport),
- udpport_string(ndo, dport));
+ udpport_string(ndo, (uint16_t)sport),
+ udpport_string(ndo, (uint16_t)dport));
}
}
} else {
- if (EXTRACT_U_1(ip->ip_p) == IPPROTO_UDP) {
+ if (GET_U_1(ip->ip_p) == IPPROTO_UDP) {
if (sport == -1) {
ND_PRINT("%s > %s: ",
ipaddr_string(ndo, ip->ip_src),
} else {
ND_PRINT("%s.%s > %s.%s: ",
ipaddr_string(ndo, ip->ip_src),
- udpport_string(ndo, sport),
+ udpport_string(ndo, (uint16_t)sport),
ipaddr_string(ndo, ip->ip_dst),
- udpport_string(ndo, dport));
+ udpport_string(ndo, (uint16_t)dport));
}
} else {
if (sport != -1) {
ND_PRINT("%s > %s: ",
- udpport_string(ndo, sport),
- udpport_string(ndo, dport));
+ udpport_string(ndo, (uint16_t)sport),
+ udpport_string(ndo, (uint16_t)dport));
}
}
}
void
udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
- const u_char *bp2, int fragmented)
+ const u_char *bp2, int fragmented, u_int ttl_hl)
{
const struct udphdr *up;
const struct ip *ip;
const u_char *cp;
const u_char *ep = ndo->ndo_snapend;
- uint16_t sport, dport, ulen;
+ uint16_t sport, dport;
+ u_int ulen;
const struct ip6_hdr *ip6;
ndo->ndo_protocol = "udp";
goto trunc;
}
- sport = EXTRACT_BE_U_2(up->uh_sport);
- dport = EXTRACT_BE_U_2(up->uh_dport);
+ sport = GET_BE_U_2(up->uh_sport);
+ dport = GET_BE_U_2(up->uh_dport);
if (length < sizeof(struct udphdr)) {
udpipaddr_print(ndo, ip, sport, dport);
udpipaddr_print(ndo, ip, sport, dport);
goto trunc;
}
- ulen = EXTRACT_BE_U_2(up->uh_ulen);
+ ulen = GET_BE_U_2(up->uh_ulen);
+ /*
+ * IPv6 Jumbo Datagrams; see RFC 2675.
+ * If the length is zero, and the length provided to us is
+ * > 65535, use the provided length as the length.
+ */
+ if (ulen == 0 && length > 65535)
+ ulen = length;
if (ulen < sizeof(struct udphdr)) {
udpipaddr_print(ndo, ip, sport, dport);
ND_PRINT("truncated-udplength %u", ulen);
case PT_RPC:
rp = (const struct sunrpc_msg *)(up + 1);
ND_TCHECK_4(rp->rm_direction);
- direction = (enum sunrpc_msg_type) EXTRACT_BE_U_4(rp->rm_direction);
+ direction = (enum sunrpc_msg_type) GET_BE_U_4(rp->rm_direction);
if (direction == SUNRPC_CALL)
sunrpc_print(ndo, (const u_char *)rp, length,
(const u_char *)ip);
rp = (const struct sunrpc_msg *)(up + 1);
if (ND_TTEST_4(rp->rm_direction)) {
- direction = (enum sunrpc_msg_type) EXTRACT_BE_U_4(rp->rm_direction);
+ direction = (enum sunrpc_msg_type) GET_BE_U_4(rp->rm_direction);
if (dport == NFS_PORT && direction == SUNRPC_CALL) {
ND_PRINT("NFS request xid %u ",
- EXTRACT_BE_U_4(rp->rm_xid));
+ GET_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("NFS reply xid %u ",
- EXTRACT_BE_U_4(rp->rm_xid));
+ GET_BE_U_4(rp->rm_xid));
nfsreply_noaddr_print(ndo, (const u_char *)rp, length,
(const u_char *)ip);
return;
*/
if (IP_V(ip) == 4 && (ndo->ndo_vflag > 1)) {
ND_TCHECK_2(up->uh_sum);
- udp_sum = EXTRACT_BE_U_2(up->uh_sum);
+ udp_sum = GET_BE_U_2(up->uh_sum);
if (udp_sum == 0) {
ND_PRINT("[no cksum] ");
} else if (ND_TTEST_LEN(cp, length)) {
ND_PRINT("[udp sum ok] ");
}
}
- else if (IP_V(ip) == 6 && ip6->ip6_plen) {
+ else if (IP_V(ip) == 6) {
/* for IPv6, UDP checksum is mandatory */
if (ND_TTEST_LEN(cp, length)) {
sum = udp6_cksum(ndo, ip6, up, length + sizeof(struct udphdr));
ND_TCHECK_2(up->uh_sum);
- udp_sum = EXTRACT_BE_U_2(up->uh_sum);
+ udp_sum = GET_BE_U_2(up->uh_sum);
if (sum != 0) {
ND_PRINT("[bad udp cksum 0x%04x -> 0x%04x!] ",
else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT))
isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT_NATT))
- isakmp_rfc3948_print(ndo, (const u_char *)(up + 1), length, bp2);
+ isakmp_rfc3948_print(ndo, (const u_char *)(up + 1), length, bp2, IP_V(ip), fragmented, ttl_hl);
else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT_USER1) || IS_SRC_OR_DST_PORT(ISAKMP_PORT_USER2))
isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
else if (IS_SRC_OR_DST_PORT(SNMP_PORT) || IS_SRC_OR_DST_PORT(SNMPTRAP_PORT))
else if (IS_SRC_OR_DST_PORT(MPLS_LSP_PING_PORT))
lspping_print(ndo, (const u_char *)(up + 1), length);
else if (dport == BFD_CONTROL_PORT ||
+ dport == BFD_MULTIHOP_PORT ||
+ dport == BFD_LAG_PORT ||
dport == BFD_ECHO_PORT )
bfd_print(ndo, (const u_char *)(up+1), length, dport);
else if (IS_SRC_OR_DST_PORT(LMP_PORT))
else if (IS_SRC_OR_DST_PORT(ZEP_PORT))
zep_print(ndo, (const u_char *)(up + 1), length);
else if (ND_TTEST_1(((const struct LAP *)cp)->type) &&
- EXTRACT_U_1(((const struct LAP *)cp)->type) == lapDDP &&
+ GET_U_1(((const struct LAP *)cp)->type) == lapDDP &&
(atalk_port(sport) || atalk_port(dport))) {
if (ndo->ndo_vflag)
ND_PRINT("kip ");