/* \summary: UDP printer */
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
#include "netdissect.h"
#include "addrtoname.h"
#include "nfs.h"
-static const char vat_tstr[] = " [|vat]";
-static const char rtp_tstr[] = " [|rtp]";
-static const char rtcp_tstr[] = " [|rtcp]";
-static const char udp_tstr[] = " [|udp]";
struct rtcphdr {
nd_uint16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */
/* vat/vt audio */
u_int ts;
+ ndo->ndo_protocol = "vat";
if (length < 2) {
ND_PRINT("udp/va/vat, length %u < 2", length);
return;
if (i0 & 0x3f000000)
ND_PRINT(" s%u", (i0 >> 24) & 0x3f);
}
+ return;
trunc:
- ND_PRINT("%s", vat_tstr);
+ nd_print_trunc(ndo);
}
static void
uint32_t i0, i1;
const char * ptype;
+ ndo->ndo_protocol = "rtp";
if (len < 8) {
ND_PRINT("udp/rtp, length %u < 8", len);
return;
if (contype == 0x1f) /*XXX H.261 */
ND_PRINT(" 0x%04x", EXTRACT_BE_U_4(ip) >> 16);
}
+ return;
trunc:
- ND_PRINT("%s", rtp_tstr);
+ nd_print_trunc(ndo);
}
static const u_char *
uint16_t flags;
u_int cnt;
double ts, dts;
+
+ ndo->ndo_protocol = "rtcp";
if ((const u_char *)(rh + 1) > ep)
goto trunc;
ND_TCHECK_SIZE(rh);
return (hdr + len);
trunc:
- ND_PRINT("%s", rtcp_tstr);
+ nd_print_trunc(ndo);
return ep;
}
if (EXTRACT_U_1(ip6->ip6_nxt) == IPPROTO_UDP) {
if (sport == -1) {
ND_PRINT("%s > %s: ",
- ip6addr_string(ndo, &ip6->ip6_src),
- ip6addr_string(ndo, &ip6->ip6_dst));
+ ip6addr_string(ndo, ip6->ip6_src),
+ ip6addr_string(ndo, ip6->ip6_dst));
} else {
ND_PRINT("%s.%s > %s.%s: ",
- ip6addr_string(ndo, &ip6->ip6_src),
+ ip6addr_string(ndo, ip6->ip6_src),
udpport_string(ndo, sport),
- ip6addr_string(ndo, &ip6->ip6_dst),
+ ip6addr_string(ndo, ip6->ip6_dst),
udpport_string(ndo, dport));
}
} else {
if (EXTRACT_U_1(ip->ip_p) == IPPROTO_UDP) {
if (sport == -1) {
ND_PRINT("%s > %s: ",
- ipaddr_string(ndo, &ip->ip_src),
- ipaddr_string(ndo, &ip->ip_dst));
+ ipaddr_string(ndo, ip->ip_src),
+ ipaddr_string(ndo, ip->ip_dst));
} else {
ND_PRINT("%s.%s > %s.%s: ",
- ipaddr_string(ndo, &ip->ip_src),
+ ipaddr_string(ndo, ip->ip_src),
udpport_string(ndo, sport),
- ipaddr_string(ndo, &ip->ip_dst),
+ ipaddr_string(ndo, ip->ip_dst),
udpport_string(ndo, dport));
}
} else {
const struct udphdr *up;
const struct ip *ip;
const u_char *cp;
- const u_char *ep = bp + length;
+ const u_char *ep = ndo->ndo_snapend;
uint16_t sport, dport, ulen;
const struct ip6_hdr *ip6;
- if (ep > ndo->ndo_snapend)
- ep = ndo->ndo_snapend;
+ ndo->ndo_protocol = "udp";
up = (const struct udphdr *)bp;
ip = (const struct ip *)bp2;
if (IP_V(ip) == 6)
ip6 = (const struct ip6_hdr *)bp2;
else
ip6 = NULL;
- if (!ND_TTEST(up->uh_dport)) {
+ if (!ND_TTEST_2(up->uh_dport)) {
udpipaddr_print(ndo, ip, -1, -1);
goto trunc;
}
ND_PRINT("truncated-udp %u", length);
return;
}
- if (!ND_TTEST(up->uh_ulen)) {
+ if (!ND_TTEST_2(up->uh_ulen)) {
udpipaddr_print(ndo, ip, sport, dport);
goto trunc;
}
case PT_RPC:
rp = (const struct sunrpc_msg *)(up + 1);
- direction = (enum sunrpc_msg_type) EXTRACT_BE_U_4(&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);
enum sunrpc_msg_type direction;
rp = (const struct sunrpc_msg *)(up + 1);
- if (ND_TTEST(rp->rm_direction)) {
- direction = (enum sunrpc_msg_type) EXTRACT_BE_U_4(&rp->rm_direction);
+ if (ND_TTEST_4(rp->rm_direction)) {
+ direction = (enum sunrpc_msg_type) EXTRACT_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));
+ ND_PRINT("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("NFS reply xid %u ", EXTRACT_BE_U_4(&rp->rm_xid));
+ ND_PRINT("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;
lisp_print(ndo, (const u_char *)(up + 1), length);
else if (IS_SRC_OR_DST_PORT(VXLAN_GPE_PORT))
vxlan_gpe_print(ndo, (const u_char *)(up + 1), length);
- else if (ND_TTEST(((const struct LAP *)cp)->type) &&
- EXTRACT_U_1(((const struct LAP *)cp)->type) == lapDDP &&
- (atalk_port(sport) || atalk_port(dport))) {
+ else if (ND_TTEST_1(((const struct LAP *)cp)->type) &&
+ EXTRACT_U_1(((const struct LAP *)cp)->type) == lapDDP &&
+ (atalk_port(sport) || atalk_port(dport))) {
if (ndo->ndo_vflag)
ND_PRINT("kip ");
llap_print(ndo, cp, length);
return;
trunc:
- ND_PRINT("%s", udp_tstr);
+ nd_print_trunc(ndo);
}
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */