mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-27 12:03:44 +08:00
Make nd_uint8_t and nd_int8_t arrays, to catch direct references.
This catches direct references, so we can change them to use EXTRACT_U_1 or EXTRACT_S_1. Also, change some structures to use the nd_ types that weren't already using them. Then make the appropriate EXTRACT_{U,S}_1() changes.
This commit is contained in:
parent
fa2faabe61
commit
3f3f2505f2
4
ip.h
4
ip.h
@ -51,8 +51,8 @@
|
||||
*/
|
||||
struct ip {
|
||||
nd_uint8_t ip_vhl; /* header length, version */
|
||||
#define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4)
|
||||
#define IP_HL(ip) ((ip)->ip_vhl & 0x0f)
|
||||
#define IP_V(ip) ((EXTRACT_U_1((ip)->ip_vhl) & 0xf0) >> 4)
|
||||
#define IP_HL(ip) (EXTRACT_U_1((ip)->ip_vhl) & 0x0f)
|
||||
nd_uint8_t ip_tos; /* type of service */
|
||||
nd_uint16_t ip_len; /* total length */
|
||||
nd_uint16_t ip_id; /* identification */
|
||||
|
@ -355,7 +355,7 @@ static const char *netdb_protocol_names[256] = {
|
||||
|
||||
/* The function enforces the array index to be 8-bit. */
|
||||
const char *
|
||||
netdb_protoname (const nd_uint8_t protoid)
|
||||
netdb_protoname (const uint8_t protoid)
|
||||
{
|
||||
return netdb_protocol_names[protoid];
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
extern const struct tok ipproto_values[];
|
||||
extern const char *netdb_protoname (const nd_uint8_t);
|
||||
extern const char *netdb_protoname (const uint8_t);
|
||||
|
||||
#ifndef IPPROTO_IP
|
||||
#define IPPROTO_IP 0 /* dummy for IP */
|
||||
|
13
netdissect.h
13
netdissect.h
@ -41,7 +41,11 @@
|
||||
* use the EXTRACT_ macros to extract them (which you should be doing
|
||||
* *anyway*, so as not to assume a particular byte order or alignment
|
||||
* in your code).
|
||||
*
|
||||
* We even want EXTRACT_U_1 used for 8-bit integral values, so we
|
||||
* define nd_uint8_t and nd_int8_t as arrays as well.
|
||||
*/
|
||||
typedef unsigned char nd_uint8_t[1];
|
||||
typedef unsigned char nd_uint16_t[2];
|
||||
typedef unsigned char nd_uint24_t[3];
|
||||
typedef unsigned char nd_uint32_t[4];
|
||||
@ -50,6 +54,8 @@ typedef unsigned char nd_uint48_t[6];
|
||||
typedef unsigned char nd_uint56_t[7];
|
||||
typedef unsigned char nd_uint64_t[8];
|
||||
|
||||
typedef signed char nd_int8_t[1];
|
||||
|
||||
/*
|
||||
* Use this for IPv4 addresses. It's defined as an array of octets, so
|
||||
* that it's not aligned on its "natural" boundary, and it's defined as
|
||||
@ -72,13 +78,6 @@ typedef struct {
|
||||
unsigned char bytes[4];
|
||||
} nd_ipv4;
|
||||
|
||||
/*
|
||||
* Data types corresponding to single-byte integral values, for
|
||||
* completeness.
|
||||
*/
|
||||
typedef unsigned char nd_uint8_t;
|
||||
typedef signed char nd_int8_t;
|
||||
|
||||
/* snprintf et al */
|
||||
|
||||
#include <stdarg.h>
|
||||
|
@ -792,6 +792,7 @@ dhcp6_print(netdissect_options *ndo,
|
||||
{
|
||||
const struct dhcp6 *dh6;
|
||||
const struct dhcp6_relay *dh6relay;
|
||||
uint8_t msgtype;
|
||||
const u_char *ep;
|
||||
const u_char *extp;
|
||||
const char *name;
|
||||
@ -805,7 +806,8 @@ dhcp6_print(netdissect_options *ndo,
|
||||
dh6 = (const struct dhcp6 *)cp;
|
||||
dh6relay = (const struct dhcp6_relay *)cp;
|
||||
ND_TCHECK(dh6->dh6_xid);
|
||||
name = tok2str(dh6_msgtype_str, "msgtype-%u", dh6->dh6_msgtype);
|
||||
msgtype = EXTRACT_U_1(dh6->dh6_msgtype);
|
||||
name = tok2str(dh6_msgtype_str, "msgtype-%u", msgtype);
|
||||
|
||||
if (!ndo->ndo_vflag) {
|
||||
ND_PRINT((ndo, " %s", name));
|
||||
@ -815,9 +817,8 @@ dhcp6_print(netdissect_options *ndo,
|
||||
/* XXX relay agent messages have to be handled differently */
|
||||
|
||||
ND_PRINT((ndo, " %s (", name)); /*)*/
|
||||
if (dh6->dh6_msgtype != DH6_RELAY_FORW &&
|
||||
dh6->dh6_msgtype != DH6_RELAY_REPLY) {
|
||||
ND_PRINT((ndo, "xid=%x", EXTRACT_BE_U_4(&dh6->dh6_xid) & DH6_XIDMASK));
|
||||
if (msgtype != DH6_RELAY_FORW && msgtype != DH6_RELAY_REPLY) {
|
||||
ND_PRINT((ndo, "xid=%x", EXTRACT_BE_U_4(dh6->dh6_xid) & DH6_XIDMASK));
|
||||
extp = (const u_char *)(dh6 + 1);
|
||||
dhcp6opt_print(ndo, extp, ep);
|
||||
} else { /* relay messages */
|
||||
|
@ -154,23 +154,23 @@ static const struct tok ForCES_TPs[] = {
|
||||
*/
|
||||
struct forcesh {
|
||||
nd_uint8_t fm_vrsvd; /* version and reserved */
|
||||
#define ForCES_V(forcesh) ((forcesh)->fm_vrsvd >> 4)
|
||||
#define ForCES_V(forcesh) (EXTRACT_U_1((forcesh)->fm_vrsvd) >> 4)
|
||||
nd_uint8_t fm_tom; /* type of message */
|
||||
nd_uint16_t fm_len; /* total length * 4 bytes */
|
||||
#define ForCES_BLN(forcesh) ((uint32_t)(EXTRACT_BE_U_2(&(forcesh)->fm_len) << 2))
|
||||
#define ForCES_BLN(forcesh) ((uint32_t)(EXTRACT_BE_U_2((forcesh)->fm_len) << 2))
|
||||
nd_uint32_t fm_sid; /* Source ID */
|
||||
#define ForCES_SID(forcesh) EXTRACT_BE_U_4(&(forcesh)->fm_sid)
|
||||
#define ForCES_SID(forcesh) EXTRACT_BE_U_4((forcesh)->fm_sid)
|
||||
nd_uint32_t fm_did; /* Destination ID */
|
||||
#define ForCES_DID(forcesh) EXTRACT_BE_U_4(&(forcesh)->fm_did)
|
||||
#define ForCES_DID(forcesh) EXTRACT_BE_U_4((forcesh)->fm_did)
|
||||
nd_uint8_t fm_cor[8]; /* correlator */
|
||||
nd_uint32_t fm_flags; /* flags */
|
||||
#define ForCES_ACK(forcesh) ((EXTRACT_BE_U_4(&(forcesh)->fm_flags)&0xC0000000) >> 30)
|
||||
#define ForCES_PRI(forcesh) ((EXTRACT_BE_U_4(&(forcesh)->fm_flags)&0x38000000) >> 27)
|
||||
#define ForCES_RS1(forcesh) ((EXTRACT_BE_U_4(&(forcesh)->fm_flags)&0x07000000) >> 24)
|
||||
#define ForCES_EM(forcesh) ((EXTRACT_BE_U_4(&(forcesh)->fm_flags)&0x00C00000) >> 22)
|
||||
#define ForCES_AT(forcesh) ((EXTRACT_BE_U_4(&(forcesh)->fm_flags)&0x00200000) >> 21)
|
||||
#define ForCES_TP(forcesh) ((EXTRACT_BE_U_4(&(forcesh)->fm_flags)&0x00180000) >> 19)
|
||||
#define ForCES_RS2(forcesh) ((EXTRACT_BE_U_4(&(forcesh)->fm_flags)&0x0007FFFF) >> 0)
|
||||
#define ForCES_ACK(forcesh) ((EXTRACT_BE_U_4((forcesh)->fm_flags)&0xC0000000) >> 30)
|
||||
#define ForCES_PRI(forcesh) ((EXTRACT_BE_U_4((forcesh)->fm_flags)&0x38000000) >> 27)
|
||||
#define ForCES_RS1(forcesh) ((EXTRACT_BE_U_4((forcesh)->fm_flags)&0x07000000) >> 24)
|
||||
#define ForCES_EM(forcesh) ((EXTRACT_BE_U_4((forcesh)->fm_flags)&0x00C00000) >> 22)
|
||||
#define ForCES_AT(forcesh) ((EXTRACT_BE_U_4((forcesh)->fm_flags)&0x00200000) >> 21)
|
||||
#define ForCES_TP(forcesh) ((EXTRACT_BE_U_4((forcesh)->fm_flags)&0x00180000) >> 19)
|
||||
#define ForCES_RS2(forcesh) ((EXTRACT_BE_U_4((forcesh)->fm_flags)&0x0007FFFF) >> 0)
|
||||
};
|
||||
|
||||
#define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \
|
||||
@ -648,6 +648,7 @@ prestlv_print(netdissect_options *ndo,
|
||||
register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
|
||||
const struct res_val *r = (const struct res_val *)tdp;
|
||||
u_int dlen;
|
||||
uint8_t result;
|
||||
|
||||
/*
|
||||
* pdatacnt_print() has ensured that len (the TLV length)
|
||||
@ -660,15 +661,16 @@ prestlv_print(netdissect_options *ndo,
|
||||
}
|
||||
|
||||
ND_TCHECK(*r);
|
||||
if (r->result >= 0x18 && r->result <= 0xFE) {
|
||||
ND_PRINT((ndo, "illegal reserved result code: 0x%x!\n", r->result));
|
||||
result = EXTRACT_U_1(r->result);
|
||||
if (result >= 0x18 && result <= 0xFE) {
|
||||
ND_PRINT((ndo, "illegal reserved result code: 0x%x!\n", result));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ndo->ndo_vflag >= 3) {
|
||||
char *ib = indent_pr(indent, 0);
|
||||
ND_PRINT((ndo, "%s Result: %s (code 0x%x)\n", ib,
|
||||
tok2str(ForCES_errs, NULL, r->result), r->result));
|
||||
tok2str(ForCES_errs, NULL, result), result));
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -1680,21 +1682,23 @@ forces_print(netdissect_options *ndo,
|
||||
const struct forcesh *fhdr;
|
||||
u_int mlen;
|
||||
uint32_t flg_raw;
|
||||
uint8_t tom;
|
||||
const struct tom_h *tops;
|
||||
int rc = 0;
|
||||
|
||||
fhdr = (const struct forcesh *)pptr;
|
||||
ND_TCHECK(*fhdr);
|
||||
if (!tom_valid(fhdr->fm_tom)) {
|
||||
ND_PRINT((ndo, "Invalid ForCES message type %d\n", fhdr->fm_tom));
|
||||
tom = EXTRACT_U_1(fhdr->fm_tom);
|
||||
if (!tom_valid(tom)) {
|
||||
ND_PRINT((ndo, "Invalid ForCES message type %d\n", tom));
|
||||
goto error;
|
||||
}
|
||||
|
||||
mlen = ForCES_BLN(fhdr);
|
||||
|
||||
tops = get_forces_tom(fhdr->fm_tom);
|
||||
tops = get_forces_tom(tom);
|
||||
if (tops->v == TOM_RSVD) {
|
||||
ND_PRINT((ndo, "\n\tUnknown ForCES message type=0x%x", fhdr->fm_tom));
|
||||
ND_PRINT((ndo, "\n\tUnknown ForCES message type=0x%x", tom));
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
10
print-icmp.c
10
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,7 +404,7 @@ 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;
|
||||
|
@ -267,8 +267,8 @@ struct nd_redirect { /* redirect */
|
||||
#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
|
||||
|
||||
struct nd_opt_hdr { /* Neighbor discovery option header */
|
||||
uint8_t nd_opt_type;
|
||||
uint8_t nd_opt_len;
|
||||
nd_uint8_t nd_opt_type;
|
||||
nd_uint8_t nd_opt_len;
|
||||
/* followed by option specific data*/
|
||||
};
|
||||
|
||||
@ -1239,6 +1239,7 @@ static void
|
||||
icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
|
||||
{
|
||||
const struct nd_opt_hdr *op;
|
||||
uint8_t opt_type, opt_len;
|
||||
const struct nd_opt_prefix_info *opp;
|
||||
const struct nd_opt_mtu *opm;
|
||||
const struct nd_opt_rdnss *oprd;
|
||||
@ -1264,24 +1265,26 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
|
||||
ECHECK(op->nd_opt_len);
|
||||
if (resid <= 0)
|
||||
return;
|
||||
if (op->nd_opt_len == 0)
|
||||
opt_type = EXTRACT_U_1(op->nd_opt_type);
|
||||
opt_len = EXTRACT_U_1(op->nd_opt_len);
|
||||
if (opt_len == 0)
|
||||
goto trunc;
|
||||
if (cp + (op->nd_opt_len << 3) > ep)
|
||||
if (cp + (opt_len << 3) > ep)
|
||||
goto trunc;
|
||||
|
||||
ND_PRINT((ndo,"\n\t %s option (%u), length %u (%u): ",
|
||||
tok2str(icmp6_opt_values, "unknown", op->nd_opt_type),
|
||||
op->nd_opt_type,
|
||||
op->nd_opt_len << 3,
|
||||
op->nd_opt_len));
|
||||
tok2str(icmp6_opt_values, "unknown", opt_type),
|
||||
opt_type,
|
||||
opt_len << 3,
|
||||
opt_len));
|
||||
|
||||
switch (op->nd_opt_type) {
|
||||
switch (opt_type) {
|
||||
case ND_OPT_SOURCE_LINKADDR:
|
||||
l = (op->nd_opt_len << 3) - 2;
|
||||
l = (opt_len << 3) - 2;
|
||||
print_lladdr(ndo, cp + 2, l);
|
||||
break;
|
||||
case ND_OPT_TARGET_LINKADDR:
|
||||
l = (op->nd_opt_len << 3) - 2;
|
||||
l = (opt_len << 3) - 2;
|
||||
print_lladdr(ndo, cp + 2, l);
|
||||
break;
|
||||
case ND_OPT_PREFIX_INFORMATION:
|
||||
@ -1289,14 +1292,14 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
|
||||
ND_TCHECK(opp->nd_opt_pi_prefix);
|
||||
ND_PRINT((ndo,"%s/%u%s, Flags [%s], valid time %s",
|
||||
ip6addr_string(ndo, &opp->nd_opt_pi_prefix),
|
||||
opp->nd_opt_pi_prefix_len,
|
||||
(op->nd_opt_len != 4) ? "badlen" : "",
|
||||
bittok2str(icmp6_opt_pi_flag_values, "none", opp->nd_opt_pi_flags_reserved),
|
||||
get_lifetime(EXTRACT_BE_U_4(&opp->nd_opt_pi_valid_time))));
|
||||
ND_PRINT((ndo,", pref. time %s", get_lifetime(EXTRACT_BE_U_4(&opp->nd_opt_pi_preferred_time))));
|
||||
EXTRACT_U_1(opp->nd_opt_pi_prefix_len),
|
||||
(opt_len != 4) ? "badlen" : "",
|
||||
bittok2str(icmp6_opt_pi_flag_values, "none", EXTRACT_U_1(opp->nd_opt_pi_flags_reserved)),
|
||||
get_lifetime(EXTRACT_BE_U_4(opp->nd_opt_pi_valid_time))));
|
||||
ND_PRINT((ndo,", pref. time %s", get_lifetime(EXTRACT_BE_U_4(opp->nd_opt_pi_preferred_time))));
|
||||
break;
|
||||
case ND_OPT_REDIRECTED_HEADER:
|
||||
print_unknown_data(ndo, bp,"\n\t ",op->nd_opt_len<<3);
|
||||
print_unknown_data(ndo, bp,"\n\t ",opt_len<<3);
|
||||
/* xxx */
|
||||
break;
|
||||
case ND_OPT_MTU:
|
||||
@ -1304,11 +1307,11 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
|
||||
ND_TCHECK(opm->nd_opt_mtu_mtu);
|
||||
ND_PRINT((ndo," %u%s",
|
||||
EXTRACT_BE_U_4(&opm->nd_opt_mtu_mtu),
|
||||
(op->nd_opt_len != 1) ? "bad option length" : "" ));
|
||||
(opt_len != 1) ? "bad option length" : "" ));
|
||||
break;
|
||||
case ND_OPT_RDNSS:
|
||||
oprd = (const struct nd_opt_rdnss *)op;
|
||||
l = (op->nd_opt_len - 1) / 2;
|
||||
l = (opt_len - 1) / 2;
|
||||
ND_PRINT((ndo," lifetime %us,",
|
||||
EXTRACT_BE_U_4(&oprd->nd_opt_rdnss_lifetime)));
|
||||
for (i = 0; i < l; i++) {
|
||||
@ -1322,7 +1325,7 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
|
||||
ND_PRINT((ndo," lifetime %us, domain(s):",
|
||||
EXTRACT_BE_U_4(&opds->nd_opt_dnssl_lifetime)));
|
||||
domp = cp + 8; /* domain names, variable-sized, RFC1035-encoded */
|
||||
while (domp < cp + (op->nd_opt_len << 3) && EXTRACT_U_1(domp) != '\0')
|
||||
while (domp < cp + (opt_len << 3) && EXTRACT_U_1(domp) != '\0')
|
||||
{
|
||||
ND_PRINT((ndo, " "));
|
||||
if ((domp = ns_nprint (ndo, domp, bp)) == NULL)
|
||||
@ -1346,7 +1349,7 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
|
||||
ND_TCHECK(opri->nd_opt_rti_lifetime);
|
||||
memset(&in6, 0, sizeof(in6));
|
||||
in6p = (const struct in6_addr *)(opri + 1);
|
||||
switch (op->nd_opt_len) {
|
||||
switch (opt_len) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
@ -1368,17 +1371,17 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
|
||||
break;
|
||||
default:
|
||||
if (ndo->ndo_vflag <= 1) {
|
||||
print_unknown_data(ndo,cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */
|
||||
print_unknown_data(ndo,cp+2,"\n\t ", (opt_len << 3) - 2); /* skip option header */
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* do we want to see an additional hexdump ? */
|
||||
if (ndo->ndo_vflag> 1)
|
||||
print_unknown_data(ndo, cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */
|
||||
print_unknown_data(ndo, cp+2,"\n\t ", (opt_len << 3) - 2); /* skip option header */
|
||||
|
||||
cp += op->nd_opt_len << 3;
|
||||
resid -= op->nd_opt_len << 3;
|
||||
cp += opt_len << 3;
|
||||
resid -= opt_len << 3;
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -124,7 +124,7 @@ print_mtrace(netdissect_options *ndo,
|
||||
ipaddr_string(ndo, tr->tr_src), ipaddr_string(ndo, tr->tr_dst),
|
||||
ipaddr_string(ndo, tr->tr_raddr)));
|
||||
if (IN_CLASSD(EXTRACT_BE_U_4(tr->tr_raddr)))
|
||||
ND_PRINT((ndo, " with-ttl %u", EXTRACT_U_1(&tr->tr_rttl)));
|
||||
ND_PRINT((ndo, " with-ttl %u", EXTRACT_U_1(tr->tr_rttl)));
|
||||
return;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
@ -146,7 +146,7 @@ print_mresp(netdissect_options *ndo,
|
||||
ipaddr_string(ndo, tr->tr_src), ipaddr_string(ndo, tr->tr_dst),
|
||||
ipaddr_string(ndo, tr->tr_raddr)));
|
||||
if (IN_CLASSD(EXTRACT_BE_U_4(tr->tr_raddr)))
|
||||
ND_PRINT((ndo, " with-ttl %u", EXTRACT_U_1(&tr->tr_rttl)));
|
||||
ND_PRINT((ndo, " with-ttl %u", EXTRACT_U_1(tr->tr_rttl)));
|
||||
return;
|
||||
trunc:
|
||||
ND_PRINT((ndo, "%s", tstr));
|
||||
|
36
print-ip.c
36
print-ip.c
@ -484,14 +484,16 @@ again:
|
||||
ND_PRINT((ndo, "carp %s > %s: ",
|
||||
ipaddr_string(ndo, &ipds->ip->ip_src),
|
||||
ipaddr_string(ndo, &ipds->ip->ip_dst)));
|
||||
carp_print(ndo, ipds->cp, ipds->len, ipds->ip->ip_ttl);
|
||||
carp_print(ndo, ipds->cp, ipds->len,
|
||||
EXTRACT_U_1(ipds->ip->ip_ttl));
|
||||
} else {
|
||||
if (ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, "vrrp %s > %s: ",
|
||||
ipaddr_string(ndo, &ipds->ip->ip_src),
|
||||
ipaddr_string(ndo, &ipds->ip->ip_dst)));
|
||||
vrrp_print(ndo, ipds->cp, ipds->len,
|
||||
(const u_char *)ipds->ip, ipds->ip->ip_ttl);
|
||||
(const u_char *)ipds->ip,
|
||||
EXTRACT_U_1(ipds->ip->ip_ttl));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -541,6 +543,7 @@ ip_print(netdissect_options *ndo,
|
||||
const u_char *ipend;
|
||||
u_int hlen;
|
||||
struct cksum_vec vec[1];
|
||||
uint8_t ip_tos, ip_ttl, ip_proto;
|
||||
uint16_t sum, ip_sum;
|
||||
const char *p_name;
|
||||
|
||||
@ -598,10 +601,13 @@ ip_print(netdissect_options *ndo,
|
||||
|
||||
ipds->off = EXTRACT_BE_U_2(&ipds->ip->ip_off);
|
||||
|
||||
ip_proto = EXTRACT_U_1(ipds->ip->ip_p);
|
||||
|
||||
if (ndo->ndo_vflag) {
|
||||
ND_PRINT((ndo, "(tos 0x%x", ipds->ip->ip_tos));
|
||||
ip_tos = EXTRACT_U_1(ipds->ip->ip_tos);
|
||||
ND_PRINT((ndo, "(tos 0x%x", ip_tos));
|
||||
/* ECN bits */
|
||||
switch (ipds->ip->ip_tos & 0x03) {
|
||||
switch (ip_tos & 0x03) {
|
||||
|
||||
case 0:
|
||||
break;
|
||||
@ -619,23 +625,23 @@ ip_print(netdissect_options *ndo,
|
||||
break;
|
||||
}
|
||||
|
||||
if (ipds->ip->ip_ttl >= 1)
|
||||
ND_PRINT((ndo, ", ttl %u", ipds->ip->ip_ttl));
|
||||
ip_ttl = EXTRACT_U_1(ipds->ip->ip_ttl);
|
||||
if (ip_ttl >= 1)
|
||||
ND_PRINT((ndo, ", ttl %u", ip_ttl));
|
||||
|
||||
/*
|
||||
* for the firewall guys, print id, offset.
|
||||
* On all but the last stick a "+" in the flags portion.
|
||||
* For unfragmented datagrams, note the don't fragment flag.
|
||||
*/
|
||||
|
||||
ND_PRINT((ndo, ", id %u, offset %u, flags [%s], proto %s (%u)",
|
||||
EXTRACT_BE_U_2(&ipds->ip->ip_id),
|
||||
(ipds->off & 0x1fff) * 8,
|
||||
bittok2str(ip_frag_values, "none", ipds->off&0xe000),
|
||||
tok2str(ipproto_values,"unknown",ipds->ip->ip_p),
|
||||
ipds->ip->ip_p));
|
||||
tok2str(ipproto_values, "unknown", ip_proto),
|
||||
ip_proto));
|
||||
|
||||
ND_PRINT((ndo, ", length %u", EXTRACT_BE_U_2(&ipds->ip->ip_len)));
|
||||
ND_PRINT((ndo, ", length %u", EXTRACT_BE_U_2(ipds->ip->ip_len)));
|
||||
|
||||
if ((hlen - sizeof(struct ip)) > 0) {
|
||||
ND_PRINT((ndo, ", options ("));
|
||||
@ -648,7 +654,7 @@ ip_print(netdissect_options *ndo,
|
||||
vec[0].len = hlen;
|
||||
sum = in_cksum(vec, 1);
|
||||
if (sum != 0) {
|
||||
ip_sum = EXTRACT_BE_U_2(&ipds->ip->ip_sum);
|
||||
ip_sum = EXTRACT_BE_U_2(ipds->ip->ip_sum);
|
||||
ND_PRINT((ndo, ", bad cksum %x (->%x)!", ip_sum,
|
||||
in_cksum_shouldbe(ip_sum, sum)));
|
||||
}
|
||||
@ -663,7 +669,7 @@ ip_print(netdissect_options *ndo,
|
||||
*/
|
||||
if ((ipds->off & 0x1fff) == 0) {
|
||||
ipds->cp = (const u_char *)ipds->ip + hlen;
|
||||
ipds->nh = ipds->ip->ip_p;
|
||||
ipds->nh = EXTRACT_U_1(ipds->ip->ip_p);
|
||||
|
||||
if (ipds->nh != IPPROTO_TCP && ipds->nh != IPPROTO_UDP &&
|
||||
ipds->nh != IPPROTO_SCTP && ipds->nh != IPPROTO_DCCP) {
|
||||
@ -687,10 +693,10 @@ ip_print(netdissect_options *ndo,
|
||||
*/
|
||||
ND_PRINT((ndo, "%s > %s:", ipaddr_string(ndo, &ipds->ip->ip_src),
|
||||
ipaddr_string(ndo, &ipds->ip->ip_dst)));
|
||||
if (!ndo->ndo_nflag && (p_name = netdb_protoname(ipds->ip->ip_p)) != NULL)
|
||||
if (!ndo->ndo_nflag && (p_name = netdb_protoname(ip_proto)) != NULL)
|
||||
ND_PRINT((ndo, " %s", p_name));
|
||||
else
|
||||
ND_PRINT((ndo, " ip-proto-%d", ipds->ip->ip_p));
|
||||
ND_PRINT((ndo, " ip-proto-%u", ip_proto));
|
||||
}
|
||||
return;
|
||||
|
||||
@ -716,7 +722,7 @@ ipN_print(netdissect_options *ndo, register const u_char *bp, register u_int len
|
||||
ip6_print (ndo, bp, length);
|
||||
break;
|
||||
default:
|
||||
ND_PRINT((ndo, "unknown ip %d", (EXTRACT_U_1(bp) & 0xF0) >> 4));
|
||||
ND_PRINT((ndo, "unknown ip %u", (EXTRACT_U_1(bp) & 0xF0) >> 4));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
40
print-lisp.c
40
print-lisp.c
@ -205,8 +205,7 @@ typedef struct map_register_eid {
|
||||
nd_uint8_t eid_prefix_mask_length;
|
||||
nd_uint8_t act_auth_inc_res;
|
||||
nd_uint8_t reserved;
|
||||
nd_uint8_t reserved_version_hi;
|
||||
nd_uint8_t version_low;
|
||||
nd_uint16_t reserved_and_version;
|
||||
nd_uint16_t eid_prefix_afi;
|
||||
} lisp_map_register_eid;
|
||||
|
||||
@ -232,6 +231,7 @@ static void loc_hdr_flag(netdissect_options *, uint16_t);
|
||||
void
|
||||
lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
|
||||
{
|
||||
uint8_t type_and_flag;
|
||||
uint8_t type;
|
||||
uint8_t mask_len;
|
||||
uint8_t loc_count;
|
||||
@ -255,21 +255,22 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
|
||||
lisp_hdr = (const lisp_map_register_hdr *) bp;
|
||||
lisp_hdr_flag(ndo, lisp_hdr);
|
||||
/* Supporting only MAP NOTIFY and MAP REGISTER LISP packets */
|
||||
type = extract_lisp_type(lisp_hdr->type_and_flag);
|
||||
type_and_flag = EXTRACT_U_1(lisp_hdr->type_and_flag);
|
||||
type = extract_lisp_type(type_and_flag);
|
||||
if ((type != LISP_MAP_REGISTER) && (type != LISP_MAP_NOTIFY))
|
||||
return;
|
||||
|
||||
/* Find if the packet contains xTR and Site-ID data */
|
||||
xtr_present = is_xtr_data_present(type, lisp_hdr->type_and_flag);
|
||||
xtr_present = is_xtr_data_present(type, type_and_flag);
|
||||
|
||||
/* Extract the number of EID records present */
|
||||
auth_data_len = EXTRACT_BE_U_2(&lisp_hdr->auth_data_len);
|
||||
auth_data_len = EXTRACT_BE_U_2(lisp_hdr->auth_data_len);
|
||||
packet_iterator = (const u_char *)(lisp_hdr);
|
||||
packet_offset = MAP_REGISTER_HDR_LEN;
|
||||
record_count = lisp_hdr->record_count;
|
||||
record_count = EXTRACT_U_1(lisp_hdr->record_count);
|
||||
|
||||
if (ndo->ndo_vflag) {
|
||||
key_id = EXTRACT_BE_U_2(&lisp_hdr->key_id);
|
||||
key_id = EXTRACT_BE_U_2(lisp_hdr->key_id);
|
||||
ND_PRINT((ndo, "\n %u record(s), ", record_count));
|
||||
ND_PRINT((ndo, "Authentication %s,",
|
||||
tok2str(auth_type, "unknown-type", key_id)));
|
||||
@ -291,16 +292,15 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
|
||||
lisp_eid = (const lisp_map_register_eid *)
|
||||
((const u_char *)lisp_hdr + packet_offset);
|
||||
packet_offset += MAP_REGISTER_EID_LEN;
|
||||
mask_len = lisp_eid->eid_prefix_mask_length;
|
||||
eid_afi = EXTRACT_BE_U_2(&lisp_eid->eid_prefix_afi);
|
||||
loc_count = lisp_eid->locator_count;
|
||||
mask_len = EXTRACT_U_1(lisp_eid->eid_prefix_mask_length);
|
||||
eid_afi = EXTRACT_BE_U_2(lisp_eid->eid_prefix_afi);
|
||||
loc_count = EXTRACT_U_1(lisp_eid->locator_count);
|
||||
|
||||
if (ndo->ndo_vflag) {
|
||||
ttl = EXTRACT_BE_U_4(&lisp_eid->ttl);
|
||||
ttl = EXTRACT_BE_U_4(lisp_eid->ttl);
|
||||
ND_PRINT((ndo, " Record TTL %u,", ttl));
|
||||
action_flag(ndo, lisp_eid->act_auth_inc_res);
|
||||
map_version = (((lisp_eid->reserved_version_hi) & 15 ) * 255) +
|
||||
lisp_eid->version_low;
|
||||
action_flag(ndo, EXTRACT_U_1(lisp_eid->act_auth_inc_res));
|
||||
map_version = EXTRACT_BE_U_2(lisp_eid->reserved_and_version) & 0x0FFF;
|
||||
ND_PRINT((ndo, " Map Version: %u,", map_version));
|
||||
}
|
||||
|
||||
@ -332,7 +332,7 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
|
||||
lisp_loc = (const lisp_map_register_loc *) (packet_iterator + packet_offset);
|
||||
loc_ip_pointer = (const u_char *) (lisp_loc + 1);
|
||||
packet_offset += MAP_REGISTER_LOC_LEN;
|
||||
loc_afi = EXTRACT_BE_U_2(&lisp_loc->locator_afi);
|
||||
loc_afi = EXTRACT_BE_U_2(lisp_loc->locator_afi);
|
||||
|
||||
if (ndo->ndo_vflag)
|
||||
ND_PRINT((ndo, "\n "));
|
||||
@ -354,10 +354,12 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
|
||||
if (ndo->ndo_vflag) {
|
||||
ND_PRINT((ndo, "\n Priority/Weight %u/%u,"
|
||||
" Multicast Priority/Weight %u/%u,",
|
||||
lisp_loc->priority, lisp_loc->weight,
|
||||
lisp_loc->m_priority, lisp_loc->m_weight));
|
||||
EXTRACT_U_1(lisp_loc->priority),
|
||||
EXTRACT_U_1(lisp_loc->weight),
|
||||
EXTRACT_U_1(lisp_loc->m_priority),
|
||||
EXTRACT_U_1(lisp_loc->m_weight)));
|
||||
loc_hdr_flag(ndo,
|
||||
EXTRACT_BE_U_2(&lisp_loc->unused_and_flag));
|
||||
EXTRACT_BE_U_2(lisp_loc->unused_and_flag));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -408,7 +410,7 @@ static inline uint8_t is_xtr_data_present(uint8_t type, uint8_t lisp_hdr_flags)
|
||||
|
||||
static void lisp_hdr_flag(netdissect_options *ndo, const lisp_map_register_hdr *lisp_hdr)
|
||||
{
|
||||
uint8_t type = extract_lisp_type(lisp_hdr->type_and_flag);
|
||||
uint8_t type = extract_lisp_type(EXTRACT_U_1(lisp_hdr->type_and_flag));
|
||||
|
||||
if (!ndo->ndo_vflag) {
|
||||
ND_PRINT((ndo, "%s,", tok2str(lisp_type, "unknown-type-%u", type)));
|
||||
|
86
print-ntp.c
86
print-ntp.c
@ -24,6 +24,14 @@
|
||||
|
||||
/* \summary: Network Time Protocol (NTP) printer */
|
||||
|
||||
/*
|
||||
* specification:
|
||||
*
|
||||
* RFC 1119 - NTPv2
|
||||
* RFC 1305 - NTPv3
|
||||
* RFC 5905 - NTPv4
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
@ -256,20 +264,23 @@ static void
|
||||
ntp_time_print(netdissect_options *ndo,
|
||||
register const struct ntp_time_data *bp, u_int length)
|
||||
{
|
||||
uint8_t stratum;
|
||||
|
||||
if (length < NTP_TIMEMSG_MINLEN)
|
||||
goto invalid;
|
||||
|
||||
ND_TCHECK(bp->stratum);
|
||||
ND_TCHECK_1(bp->stratum);
|
||||
stratum = EXTRACT_U_1(bp->stratum);
|
||||
ND_PRINT((ndo, ", Stratum %u (%s)",
|
||||
bp->stratum,
|
||||
tok2str(ntp_stratum_values, (bp->stratum >=2 && bp->stratum<=15) ? "secondary reference" : "reserved", bp->stratum)));
|
||||
stratum,
|
||||
tok2str(ntp_stratum_values, (stratum >=2 && stratum<=15) ? "secondary reference" : "reserved", stratum)));
|
||||
|
||||
ND_TCHECK(bp->ppoll);
|
||||
ND_PRINT((ndo, ", poll %d", bp->ppoll));
|
||||
p_poll(ndo, bp->ppoll);
|
||||
ND_TCHECK_1(bp->ppoll);
|
||||
ND_PRINT((ndo, ", poll %d", EXTRACT_S_1(bp->ppoll)));
|
||||
p_poll(ndo, EXTRACT_U_1(bp->ppoll));
|
||||
|
||||
ND_TCHECK(bp->precision);
|
||||
ND_PRINT((ndo, ", precision %d", bp->precision));
|
||||
ND_TCHECK_1(bp->precision);
|
||||
ND_PRINT((ndo, ", precision %d", EXTRACT_S_1(bp->precision)));
|
||||
|
||||
ND_TCHECK(bp->root_delay);
|
||||
ND_PRINT((ndo, "\n\tRoot Delay: "));
|
||||
@ -282,7 +293,7 @@ ntp_time_print(netdissect_options *ndo,
|
||||
ND_TCHECK(bp->refid);
|
||||
ND_PRINT((ndo, ", Reference-ID: "));
|
||||
/* Interpretation depends on stratum */
|
||||
switch (bp->stratum) {
|
||||
switch (stratum) {
|
||||
|
||||
case UNSPECIFIED:
|
||||
ND_PRINT((ndo, "(unspec)"));
|
||||
@ -334,11 +345,11 @@ ntp_time_print(netdissect_options *ndo,
|
||||
|
||||
/* FIXME: this code is not aware of any extension fields */
|
||||
if (length == NTP_TIMEMSG_MINLEN + 4) { /* Optional: key-id (crypto-NAK) */
|
||||
ND_TCHECK(bp->key_id);
|
||||
ND_PRINT((ndo, "\n\tKey id: %u", EXTRACT_BE_U_4(&bp->key_id)));
|
||||
ND_TCHECK_4(bp->key_id);
|
||||
ND_PRINT((ndo, "\n\tKey id: %u", EXTRACT_BE_U_4(bp->key_id)));
|
||||
} else if (length == NTP_TIMEMSG_MINLEN + 4 + 16) { /* Optional: key-id + 128-bit digest */
|
||||
ND_TCHECK(bp->key_id);
|
||||
ND_PRINT((ndo, "\n\tKey id: %u", EXTRACT_BE_U_4(&bp->key_id)));
|
||||
ND_TCHECK_4(bp->key_id);
|
||||
ND_PRINT((ndo, "\n\tKey id: %u", EXTRACT_BE_U_4(bp->key_id)));
|
||||
ND_TCHECK2(bp->message_digest, 16);
|
||||
ND_PRINT((ndo, "\n\tAuthentication: %08x%08x%08x%08x",
|
||||
EXTRACT_BE_U_4(bp->message_digest),
|
||||
@ -346,8 +357,8 @@ ntp_time_print(netdissect_options *ndo,
|
||||
EXTRACT_BE_U_4(bp->message_digest + 8),
|
||||
EXTRACT_BE_U_4(bp->message_digest + 12)));
|
||||
} else if (length == NTP_TIMEMSG_MINLEN + 4 + 20) { /* Optional: key-id + 160-bit digest */
|
||||
ND_TCHECK(bp->key_id);
|
||||
ND_PRINT((ndo, "\n\tKey id: %u", EXTRACT_BE_U_4(&bp->key_id)));
|
||||
ND_TCHECK_4(bp->key_id);
|
||||
ND_PRINT((ndo, "\n\tKey id: %u", EXTRACT_BE_U_4(bp->key_id)));
|
||||
ND_TCHECK2(bp->message_digest, 20);
|
||||
ND_PRINT((ndo, "\n\tAuthentication: %08x%08x%08x%08x%08x",
|
||||
EXTRACT_BE_U_4(bp->message_digest),
|
||||
@ -376,39 +387,40 @@ static void
|
||||
ntp_control_print(netdissect_options *ndo,
|
||||
register const struct ntp_control_data *cd, u_int length)
|
||||
{
|
||||
u_char R, E, M, opcode;
|
||||
u_int8_t control, R, E, M, opcode;
|
||||
uint16_t sequence, status, assoc, offset, count;
|
||||
|
||||
if (length < NTP_CTRLMSG_MINLEN)
|
||||
goto invalid;
|
||||
|
||||
ND_TCHECK(cd->control);
|
||||
R = (cd->control & 0x80) != 0;
|
||||
E = (cd->control & 0x40) != 0;
|
||||
M = (cd->control & 0x20) != 0;
|
||||
opcode = cd->control & 0x1f;
|
||||
ND_TCHECK_1(cd->control);
|
||||
control = EXTRACT_U_1(cd->control);
|
||||
R = (control & 0x80) != 0;
|
||||
E = (control & 0x40) != 0;
|
||||
M = (control & 0x20) != 0;
|
||||
opcode = control & 0x1f;
|
||||
ND_PRINT((ndo, ", %s, %s, %s, OpCode=%u\n",
|
||||
R ? "Response" : "Request", E ? "Error" : "OK",
|
||||
M ? "More" : "Last", (unsigned)opcode));
|
||||
M ? "More" : "Last", opcode));
|
||||
|
||||
ND_TCHECK(cd->sequence);
|
||||
sequence = EXTRACT_BE_U_2(&cd->sequence);
|
||||
ND_TCHECK_2(cd->sequence);
|
||||
sequence = EXTRACT_BE_U_2(cd->sequence);
|
||||
ND_PRINT((ndo, "\tSequence=%hu", sequence));
|
||||
|
||||
ND_TCHECK(cd->status);
|
||||
status = EXTRACT_BE_U_2(&cd->status);
|
||||
ND_TCHECK_2(cd->status);
|
||||
status = EXTRACT_BE_U_2(cd->status);
|
||||
ND_PRINT((ndo, ", Status=%#hx", status));
|
||||
|
||||
ND_TCHECK(cd->assoc);
|
||||
assoc = EXTRACT_BE_U_2(&cd->assoc);
|
||||
ND_TCHECK_2(cd->assoc);
|
||||
assoc = EXTRACT_BE_U_2(cd->assoc);
|
||||
ND_PRINT((ndo, ", Assoc.=%hu", assoc));
|
||||
|
||||
ND_TCHECK(cd->offset);
|
||||
offset = EXTRACT_BE_U_2(&cd->offset);
|
||||
ND_TCHECK_2(cd->offset);
|
||||
offset = EXTRACT_BE_U_2(cd->offset);
|
||||
ND_PRINT((ndo, ", Offset=%hu", offset));
|
||||
|
||||
ND_TCHECK(cd->count);
|
||||
count = EXTRACT_BE_U_2(&cd->count);
|
||||
ND_TCHECK_2(cd->count);
|
||||
count = EXTRACT_BE_U_2(cd->count);
|
||||
ND_PRINT((ndo, ", Count=%hu", count));
|
||||
|
||||
if (NTP_CTRLMSG_MINLEN + count > length)
|
||||
@ -442,13 +454,15 @@ ntp_print(netdissect_options *ndo,
|
||||
{
|
||||
register const union ntpdata *bp = (const union ntpdata *)cp;
|
||||
int mode, version, leapind;
|
||||
uint8_t status;
|
||||
|
||||
ND_TCHECK(bp->td.status);
|
||||
status = EXTRACT_U_1(bp->td.status);
|
||||
|
||||
version = (bp->td.status & VERSIONMASK) >> VERSIONSHIFT;
|
||||
version = (status & VERSIONMASK) >> VERSIONSHIFT;
|
||||
ND_PRINT((ndo, "NTPv%d", version));
|
||||
|
||||
mode = (bp->td.status & MODEMASK) >> MODESHIFT;
|
||||
mode = (status & MODEMASK) >> MODESHIFT;
|
||||
if (!ndo->ndo_vflag) {
|
||||
ND_PRINT((ndo, ", %s, length %u",
|
||||
tok2str(ntp_mode_values, "Unknown mode", mode),
|
||||
@ -459,8 +473,8 @@ ntp_print(netdissect_options *ndo,
|
||||
ND_PRINT((ndo, ", %s, length %u\n",
|
||||
tok2str(ntp_mode_values, "Unknown mode", mode), length));
|
||||
|
||||
/* leapind = (bp->td.status & LEAPMASK) >> LEAPSHIFT; */
|
||||
leapind = (bp->td.status & LEAPMASK);
|
||||
/* leapind = (status & LEAPMASK) >> LEAPSHIFT; */
|
||||
leapind = (status & LEAPMASK);
|
||||
ND_PRINT((ndo, "\tLeap indicator: %s (%u)",
|
||||
tok2str(ntp_leapind_values, "Unknown", leapind),
|
||||
leapind));
|
||||
|
@ -192,7 +192,7 @@ pgm_print(netdissect_options *ndo,
|
||||
tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
|
||||
}
|
||||
} else {
|
||||
if (ip->ip_p == IPPROTO_PGM) {
|
||||
if (EXTRACT_U_1(ip->ip_p) == IPPROTO_PGM) {
|
||||
ND_PRINT((ndo, "%s.%s > %s.%s: ",
|
||||
ipaddr_string(ndo, &ip->ip_src),
|
||||
tcpport_string(ndo, sport),
|
||||
@ -446,11 +446,11 @@ pgm_print(netdissect_options *ndo,
|
||||
return;
|
||||
}
|
||||
opts_len = EXTRACT_BE_U_2(bp);
|
||||
bp += sizeof(uint16_t);
|
||||
if (opts_len < 4) {
|
||||
ND_PRINT((ndo, "[Bad total option length %u < 4]", opts_len));
|
||||
return;
|
||||
}
|
||||
bp += sizeof(uint16_t);
|
||||
ND_PRINT((ndo, " OPTS LEN %d", opts_len));
|
||||
opts_len -= 4;
|
||||
|
||||
|
@ -961,7 +961,7 @@ handle_pap(netdissect_options *ndo,
|
||||
return;
|
||||
}
|
||||
length = len;
|
||||
if (length < (p - p0)) {
|
||||
if (length < (size_t)(p - p0)) {
|
||||
ND_PRINT((ndo, ", length %u < PAP header length", length));
|
||||
return;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ rt6_print(netdissect_options *ndo, register const u_char *bp, const u_char *bp2
|
||||
ND_TCHECK(dp0->ip6r0_reserved);
|
||||
if (EXTRACT_BE_U_4(dp0->ip6r0_reserved) || ndo->ndo_vflag) {
|
||||
ND_PRINT((ndo, ", rsv=0x%0x",
|
||||
EXTRACT_BE_U_4(&dp0->ip6r0_reserved)));
|
||||
EXTRACT_BE_U_4(dp0->ip6r0_reserved)));
|
||||
}
|
||||
|
||||
if (len % 2 == 1)
|
||||
@ -80,7 +80,7 @@ rt6_print(netdissect_options *ndo, register const u_char *bp, const u_char *bp2
|
||||
}
|
||||
/*(*/
|
||||
ND_PRINT((ndo, ") "));
|
||||
return((dp0->ip6r0_len + 1) << 3);
|
||||
return((EXTRACT_U_1(dp0->ip6r0_len) + 1) << 3);
|
||||
break;
|
||||
default:
|
||||
goto trunc;
|
||||
|
146
print-rx.c
146
print-rx.c
@ -112,15 +112,18 @@ struct rx_header {
|
||||
#define RX_MAXACKS 255
|
||||
|
||||
struct rx_ackPacket {
|
||||
uint16_t bufferSpace; /* Number of packet buffers available */
|
||||
uint16_t maxSkew; /* Max diff between ack'd packet and */
|
||||
nd_uint16_t bufferSpace; /* Number of packet buffers available */
|
||||
nd_uint16_t maxSkew; /* Max diff between ack'd packet and */
|
||||
/* highest packet received */
|
||||
uint32_t firstPacket; /* The first packet in ack list */
|
||||
uint32_t previousPacket; /* Previous packet recv'd (obsolete) */
|
||||
uint32_t serial; /* # of packet that prompted the ack */
|
||||
uint8_t reason; /* Reason for acknowledgement */
|
||||
uint8_t nAcks; /* Number of acknowledgements */
|
||||
nd_uint32_t firstPacket; /* The first packet in ack list */
|
||||
nd_uint32_t previousPacket; /* Previous packet recv'd (obsolete) */
|
||||
nd_uint32_t serial; /* # of packet that prompted the ack */
|
||||
nd_uint8_t reason; /* Reason for acknowledgement */
|
||||
nd_uint8_t nAcks; /* Number of acknowledgements */
|
||||
/* Followed by nAcks acknowledgments */
|
||||
#if 0
|
||||
uint8_t acks[RX_MAXACKS]; /* Up to RX_MAXACKS acknowledgements */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
@ -528,6 +531,7 @@ rx_print(netdissect_options *ndo,
|
||||
{
|
||||
register const struct rx_header *rxh;
|
||||
uint32_t i;
|
||||
uint8_t type, flags;
|
||||
uint32_t opcode;
|
||||
|
||||
if (!ND_TTEST2(*bp, sizeof (struct rx_header))) {
|
||||
@ -537,30 +541,32 @@ rx_print(netdissect_options *ndo,
|
||||
|
||||
rxh = (const struct rx_header *) bp;
|
||||
|
||||
ND_PRINT((ndo, " rx %s", tok2str(rx_types, "type %u", rxh->type)));
|
||||
type = EXTRACT_U_1(rxh->type);
|
||||
ND_PRINT((ndo, " rx %s", tok2str(rx_types, "type %u", type)));
|
||||
|
||||
flags = EXTRACT_U_1(rxh->flags);
|
||||
if (ndo->ndo_vflag) {
|
||||
int firstflag = 0;
|
||||
|
||||
if (ndo->ndo_vflag > 1)
|
||||
ND_PRINT((ndo, " cid %08x call# %u",
|
||||
EXTRACT_BE_U_4(&rxh->cid),
|
||||
EXTRACT_BE_U_4(&rxh->callNumber)));
|
||||
EXTRACT_BE_U_4(rxh->cid),
|
||||
EXTRACT_BE_U_4(rxh->callNumber)));
|
||||
|
||||
ND_PRINT((ndo, " seq %u ser %u",
|
||||
EXTRACT_BE_U_4(&rxh->seq),
|
||||
EXTRACT_BE_U_4(&rxh->serial)));
|
||||
EXTRACT_BE_U_4(rxh->seq),
|
||||
EXTRACT_BE_U_4(rxh->serial)));
|
||||
|
||||
if (ndo->ndo_vflag > 2)
|
||||
ND_PRINT((ndo, " secindex %u serviceid %hu",
|
||||
rxh->securityIndex,
|
||||
EXTRACT_BE_U_2(&rxh->serviceId)));
|
||||
EXTRACT_U_1(rxh->securityIndex),
|
||||
EXTRACT_BE_U_2(rxh->serviceId)));
|
||||
|
||||
if (ndo->ndo_vflag > 1)
|
||||
for (i = 0; i < NUM_RX_FLAGS; i++) {
|
||||
if (rxh->flags & rx_flags[i].flag &&
|
||||
if (flags & rx_flags[i].flag &&
|
||||
(!rx_flags[i].packetType ||
|
||||
rxh->type == rx_flags[i].packetType)) {
|
||||
type == rx_flags[i].packetType)) {
|
||||
if (!firstflag) {
|
||||
firstflag = 1;
|
||||
ND_PRINT((ndo, " "));
|
||||
@ -581,9 +587,9 @@ rx_print(netdissect_options *ndo,
|
||||
* as well.
|
||||
*/
|
||||
|
||||
if (rxh->type == RX_PACKET_TYPE_DATA &&
|
||||
EXTRACT_BE_U_4(&rxh->seq) == 1 &&
|
||||
rxh->flags & RX_CLIENT_INITIATED) {
|
||||
if (type == RX_PACKET_TYPE_DATA &&
|
||||
EXTRACT_BE_U_4(rxh->seq) == 1 &&
|
||||
flags & RX_CLIENT_INITIATED) {
|
||||
|
||||
/*
|
||||
* Insert this call into the call cache table, so we
|
||||
@ -625,10 +631,10 @@ rx_print(netdissect_options *ndo,
|
||||
* because printing out the return code can be useful at times.
|
||||
*/
|
||||
|
||||
} else if (((rxh->type == RX_PACKET_TYPE_DATA &&
|
||||
EXTRACT_BE_U_4(&rxh->seq) == 1) ||
|
||||
rxh->type == RX_PACKET_TYPE_ABORT) &&
|
||||
(rxh->flags & RX_CLIENT_INITIATED) == 0 &&
|
||||
} else if (((type == RX_PACKET_TYPE_DATA &&
|
||||
EXTRACT_BE_U_4(rxh->seq) == 1) ||
|
||||
type == RX_PACKET_TYPE_ABORT) &&
|
||||
(flags & RX_CLIENT_INITIATED) == 0 &&
|
||||
rx_cache_find(rxh, (const struct ip *) bp2,
|
||||
sport, &opcode)) {
|
||||
|
||||
@ -664,7 +670,7 @@ rx_print(netdissect_options *ndo,
|
||||
* ack packet, so we can use one for all AFS services)
|
||||
*/
|
||||
|
||||
} else if (rxh->type == RX_PACKET_TYPE_ACK)
|
||||
} else if (type == RX_PACKET_TYPE_ACK)
|
||||
rx_ack_print(ndo, bp, length);
|
||||
|
||||
|
||||
@ -690,11 +696,11 @@ rx_cache_insert(netdissect_options *ndo,
|
||||
if (++rx_cache_next >= RX_CACHE_SIZE)
|
||||
rx_cache_next = 0;
|
||||
|
||||
rxent->callnum = EXTRACT_BE_U_4(&rxh->callNumber);
|
||||
rxent->callnum = EXTRACT_BE_U_4(rxh->callNumber);
|
||||
UNALIGNED_MEMCPY(&rxent->client, &ip->ip_src, sizeof(uint32_t));
|
||||
UNALIGNED_MEMCPY(&rxent->server, &ip->ip_dst, sizeof(uint32_t));
|
||||
rxent->dport = dport;
|
||||
rxent->serviceId = EXTRACT_BE_U_4(&rxh->serviceId);
|
||||
rxent->serviceId = EXTRACT_BE_U_4(rxh->serviceId);
|
||||
rxent->opcode = EXTRACT_BE_U_4(bp + sizeof(struct rx_header));
|
||||
}
|
||||
|
||||
@ -722,10 +728,10 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, u_int sport,
|
||||
i = rx_cache_hint;
|
||||
do {
|
||||
rxent = &rx_cache[i];
|
||||
if (rxent->callnum == EXTRACT_BE_U_4(&rxh->callNumber) &&
|
||||
if (rxent->callnum == EXTRACT_BE_U_4(rxh->callNumber) &&
|
||||
rxent->client.s_addr == clip &&
|
||||
rxent->server.s_addr == sip &&
|
||||
rxent->serviceId == EXTRACT_BE_U_4(&rxh->serviceId) &&
|
||||
rxent->serviceId == EXTRACT_BE_U_4(rxh->serviceId) &&
|
||||
rxent->dport == sport) {
|
||||
|
||||
/* We got a match! */
|
||||
@ -1057,6 +1063,7 @@ fs_reply_print(netdissect_options *ndo,
|
||||
{
|
||||
uint32_t i;
|
||||
const struct rx_header *rxh;
|
||||
uint8_t type;
|
||||
|
||||
if (length <= sizeof(struct rx_header))
|
||||
return;
|
||||
@ -1070,13 +1077,14 @@ fs_reply_print(netdissect_options *ndo,
|
||||
|
||||
ND_PRINT((ndo, " fs reply %s", tok2str(fs_req, "op#%u", opcode)));
|
||||
|
||||
type = EXTRACT_U_1(rxh->type);
|
||||
bp += sizeof(struct rx_header);
|
||||
|
||||
/*
|
||||
* If it was a data packet, interpret the response
|
||||
*/
|
||||
|
||||
if (rxh->type == RX_PACKET_TYPE_DATA) {
|
||||
if (type == RX_PACKET_TYPE_DATA) {
|
||||
switch (opcode) {
|
||||
case 131: /* Fetch ACL */
|
||||
{
|
||||
@ -1106,7 +1114,7 @@ fs_reply_print(netdissect_options *ndo,
|
||||
default:
|
||||
;
|
||||
}
|
||||
} else if (rxh->type == RX_PACKET_TYPE_ABORT) {
|
||||
} else if (type == RX_PACKET_TYPE_ABORT) {
|
||||
/*
|
||||
* Otherwise, just print out the return code
|
||||
*/
|
||||
@ -1118,7 +1126,7 @@ fs_reply_print(netdissect_options *ndo,
|
||||
|
||||
ND_PRINT((ndo, " error %s", tok2str(afs_fs_errors, "#%d", errcode)));
|
||||
} else {
|
||||
ND_PRINT((ndo, " strange fs reply of type %u", rxh->type));
|
||||
ND_PRINT((ndo, " strange fs reply of type %u", type));
|
||||
}
|
||||
|
||||
return;
|
||||
@ -1300,6 +1308,7 @@ cb_reply_print(netdissect_options *ndo,
|
||||
register const u_char *bp, u_int length, uint32_t opcode)
|
||||
{
|
||||
const struct rx_header *rxh;
|
||||
uint8_t type;
|
||||
|
||||
if (length <= sizeof(struct rx_header))
|
||||
return;
|
||||
@ -1313,13 +1322,14 @@ cb_reply_print(netdissect_options *ndo,
|
||||
|
||||
ND_PRINT((ndo, " cb reply %s", tok2str(cb_req, "op#%u", opcode)));
|
||||
|
||||
type = EXTRACT_U_1(rxh->type);
|
||||
bp += sizeof(struct rx_header);
|
||||
|
||||
/*
|
||||
* If it was a data packet, interpret the response.
|
||||
*/
|
||||
|
||||
if (rxh->type == RX_PACKET_TYPE_DATA)
|
||||
if (type == RX_PACKET_TYPE_DATA)
|
||||
switch (opcode) {
|
||||
case 213: /* InitCallBackState3 */
|
||||
AFSUUIDOUT();
|
||||
@ -1491,6 +1501,7 @@ prot_reply_print(netdissect_options *ndo,
|
||||
register const u_char *bp, u_int length, uint32_t opcode)
|
||||
{
|
||||
const struct rx_header *rxh;
|
||||
uint8_t type;
|
||||
uint32_t i;
|
||||
|
||||
if (length < sizeof(struct rx_header))
|
||||
@ -1513,13 +1524,14 @@ prot_reply_print(netdissect_options *ndo,
|
||||
|
||||
ND_PRINT((ndo, " reply %s", tok2str(pt_req, "op#%u", opcode)));
|
||||
|
||||
type = EXTRACT_U_1(rxh->type);
|
||||
bp += sizeof(struct rx_header);
|
||||
|
||||
/*
|
||||
* If it was a data packet, interpret the response
|
||||
*/
|
||||
|
||||
if (rxh->type == RX_PACKET_TYPE_DATA)
|
||||
if (type == RX_PACKET_TYPE_DATA)
|
||||
switch (opcode) {
|
||||
case 504: /* Name to ID */
|
||||
{
|
||||
@ -1695,6 +1707,7 @@ vldb_reply_print(netdissect_options *ndo,
|
||||
register const u_char *bp, u_int length, uint32_t opcode)
|
||||
{
|
||||
const struct rx_header *rxh;
|
||||
uint8_t type;
|
||||
uint32_t i;
|
||||
|
||||
if (length < sizeof(struct rx_header))
|
||||
@ -1717,13 +1730,14 @@ vldb_reply_print(netdissect_options *ndo,
|
||||
|
||||
ND_PRINT((ndo, " reply %s", tok2str(vldb_req, "op#%u", opcode)));
|
||||
|
||||
type = EXTRACT_U_1(rxh->type);
|
||||
bp += sizeof(struct rx_header);
|
||||
|
||||
/*
|
||||
* If it was a data packet, interpret the response
|
||||
*/
|
||||
|
||||
if (rxh->type == RX_PACKET_TYPE_DATA)
|
||||
if (type == RX_PACKET_TYPE_DATA)
|
||||
switch (opcode) {
|
||||
case 510: /* List entry */
|
||||
ND_PRINT((ndo, " count"));
|
||||
@ -1974,6 +1988,7 @@ kauth_reply_print(netdissect_options *ndo,
|
||||
register const u_char *bp, u_int length, uint32_t opcode)
|
||||
{
|
||||
const struct rx_header *rxh;
|
||||
uint8_t type;
|
||||
|
||||
if (length <= sizeof(struct rx_header))
|
||||
return;
|
||||
@ -1994,13 +2009,14 @@ kauth_reply_print(netdissect_options *ndo,
|
||||
|
||||
ND_PRINT((ndo, " reply %s", tok2str(kauth_req, "op#%u", opcode)));
|
||||
|
||||
type = EXTRACT_U_1(rxh->type);
|
||||
bp += sizeof(struct rx_header);
|
||||
|
||||
/*
|
||||
* If it was a data packet, interpret the response.
|
||||
*/
|
||||
|
||||
if (rxh->type == RX_PACKET_TYPE_DATA)
|
||||
if (type == RX_PACKET_TYPE_DATA)
|
||||
/* Well, no, not really. Leave this for later */
|
||||
;
|
||||
else {
|
||||
@ -2225,6 +2241,7 @@ vol_reply_print(netdissect_options *ndo,
|
||||
register const u_char *bp, u_int length, uint32_t opcode)
|
||||
{
|
||||
const struct rx_header *rxh;
|
||||
uint8_t type;
|
||||
|
||||
if (length <= sizeof(struct rx_header))
|
||||
return;
|
||||
@ -2238,13 +2255,14 @@ vol_reply_print(netdissect_options *ndo,
|
||||
|
||||
ND_PRINT((ndo, " vol reply %s", tok2str(vol_req, "op#%u", opcode)));
|
||||
|
||||
type = EXTRACT_U_1(rxh->type);
|
||||
bp += sizeof(struct rx_header);
|
||||
|
||||
/*
|
||||
* If it was a data packet, interpret the response.
|
||||
*/
|
||||
|
||||
if (rxh->type == RX_PACKET_TYPE_DATA) {
|
||||
if (type == RX_PACKET_TYPE_DATA) {
|
||||
switch (opcode) {
|
||||
case 100: /* Create volume */
|
||||
ND_PRINT((ndo, " volid"));
|
||||
@ -2449,6 +2467,7 @@ bos_reply_print(netdissect_options *ndo,
|
||||
register const u_char *bp, u_int length, uint32_t opcode)
|
||||
{
|
||||
const struct rx_header *rxh;
|
||||
uint8_t type;
|
||||
|
||||
if (length <= sizeof(struct rx_header))
|
||||
return;
|
||||
@ -2462,13 +2481,14 @@ bos_reply_print(netdissect_options *ndo,
|
||||
|
||||
ND_PRINT((ndo, " bos reply %s", tok2str(bos_req, "op#%u", opcode)));
|
||||
|
||||
type = EXTRACT_U_1(rxh->type);
|
||||
bp += sizeof(struct rx_header);
|
||||
|
||||
/*
|
||||
* If it was a data packet, interpret the response.
|
||||
*/
|
||||
|
||||
if (rxh->type == RX_PACKET_TYPE_DATA)
|
||||
if (type == RX_PACKET_TYPE_DATA)
|
||||
/* Well, no, not really. Leave this for later */
|
||||
;
|
||||
else {
|
||||
@ -2623,6 +2643,7 @@ ubik_reply_print(netdissect_options *ndo,
|
||||
register const u_char *bp, u_int length, uint32_t opcode)
|
||||
{
|
||||
const struct rx_header *rxh;
|
||||
uint8_t type;
|
||||
|
||||
if (length < sizeof(struct rx_header))
|
||||
return;
|
||||
@ -2636,13 +2657,14 @@ ubik_reply_print(netdissect_options *ndo,
|
||||
|
||||
ND_PRINT((ndo, " ubik reply %s", tok2str(ubik_req, "op#%u", opcode)));
|
||||
|
||||
type = EXTRACT_U_1(rxh->type);
|
||||
bp += sizeof(struct rx_header);
|
||||
|
||||
/*
|
||||
* If it was a data packet, print out the arguments to the Ubik calls
|
||||
*/
|
||||
|
||||
if (rxh->type == RX_PACKET_TYPE_DATA)
|
||||
if (type == RX_PACKET_TYPE_DATA)
|
||||
switch (opcode) {
|
||||
case 10000: /* Beacon */
|
||||
ND_PRINT((ndo, " vote no"));
|
||||
@ -2687,6 +2709,7 @@ rx_ack_print(netdissect_options *ndo,
|
||||
register const u_char *bp, u_int length)
|
||||
{
|
||||
const struct rx_ackPacket *rxa;
|
||||
uint8_t nAcks;
|
||||
int i, start, last;
|
||||
uint32_t firstPacket;
|
||||
|
||||
@ -2695,18 +2718,10 @@ rx_ack_print(netdissect_options *ndo,
|
||||
|
||||
bp += sizeof(struct rx_header);
|
||||
|
||||
/*
|
||||
* This may seem a little odd .... the rx_ackPacket structure
|
||||
* contains an array of individual packet acknowledgements
|
||||
* (used for selective ack/nack), but since it's variable in size,
|
||||
* we don't want to truncate based on the size of the whole
|
||||
* rx_ackPacket structure.
|
||||
*/
|
||||
|
||||
ND_TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS);
|
||||
ND_TCHECK2(bp[0], sizeof(struct rx_ackPacket));
|
||||
|
||||
rxa = (const struct rx_ackPacket *) bp;
|
||||
bp += (sizeof(struct rx_ackPacket) - RX_MAXACKS);
|
||||
bp += sizeof(struct rx_ackPacket);
|
||||
|
||||
/*
|
||||
* Print out a few useful things from the ack packet structure
|
||||
@ -2714,13 +2729,13 @@ rx_ack_print(netdissect_options *ndo,
|
||||
|
||||
if (ndo->ndo_vflag > 2)
|
||||
ND_PRINT((ndo, " bufspace %u maxskew %d",
|
||||
EXTRACT_BE_U_2(&rxa->bufferSpace),
|
||||
EXTRACT_BE_U_2(&rxa->maxSkew)));
|
||||
EXTRACT_BE_U_2(rxa->bufferSpace),
|
||||
EXTRACT_BE_U_2(rxa->maxSkew)));
|
||||
|
||||
firstPacket = EXTRACT_BE_U_4(&rxa->firstPacket);
|
||||
firstPacket = EXTRACT_BE_U_4(rxa->firstPacket);
|
||||
ND_PRINT((ndo, " first %u serial %u reason %s",
|
||||
firstPacket, EXTRACT_BE_U_4(&rxa->serial),
|
||||
tok2str(rx_ack_reasons, "#%u", rxa->reason)));
|
||||
firstPacket, EXTRACT_BE_U_4(rxa->serial),
|
||||
tok2str(rx_ack_reasons, "#%u", EXTRACT_U_1(rxa->reason))));
|
||||
|
||||
/*
|
||||
* Okay, now we print out the ack array. The way _this_ works
|
||||
@ -2741,17 +2756,18 @@ rx_ack_print(netdissect_options *ndo,
|
||||
* to bp after this, so bp ends up at the right spot. Go figure.
|
||||
*/
|
||||
|
||||
if (rxa->nAcks != 0) {
|
||||
nAcks = EXTRACT_U_1(rxa->nAcks);
|
||||
if (nAcks != 0) {
|
||||
|
||||
ND_TCHECK2(bp[0], rxa->nAcks);
|
||||
ND_TCHECK2(bp[0], nAcks);
|
||||
|
||||
/*
|
||||
* Sigh, this is gross, but it seems to work to collapse
|
||||
* ranges correctly.
|
||||
*/
|
||||
|
||||
for (i = 0, start = last = -2; i < rxa->nAcks; i++)
|
||||
if (rxa->acks[i] == RX_ACK_TYPE_ACK) {
|
||||
for (i = 0, start = last = -2; i < nAcks; i++)
|
||||
if (EXTRACT_U_1(bp + i) == RX_ACK_TYPE_ACK) {
|
||||
|
||||
/*
|
||||
* I figured this deserved _some_ explanation.
|
||||
@ -2821,8 +2837,8 @@ rx_ack_print(netdissect_options *ndo,
|
||||
* Same as above, just without comments
|
||||
*/
|
||||
|
||||
for (i = 0, start = last = -2; i < rxa->nAcks; i++)
|
||||
if (rxa->acks[i] == RX_ACK_TYPE_NACK) {
|
||||
for (i = 0, start = last = -2; i < nAcks; i++)
|
||||
if (EXTRACT_U_1(bp + i) == RX_ACK_TYPE_NACK) {
|
||||
if (last == -2) {
|
||||
ND_PRINT((ndo, " nacked %u", firstPacket + i));
|
||||
start = i;
|
||||
@ -2837,9 +2853,11 @@ rx_ack_print(netdissect_options *ndo,
|
||||
if (last == i - 1 && start != last)
|
||||
ND_PRINT((ndo, "-%u", firstPacket + i - 1));
|
||||
|
||||
bp += rxa->nAcks;
|
||||
bp += nAcks;
|
||||
}
|
||||
|
||||
/* Padding. */
|
||||
bp += 3;
|
||||
|
||||
/*
|
||||
* These are optional fields; depending on your version of AFS,
|
||||
@ -2851,19 +2869,19 @@ rx_ack_print(netdissect_options *ndo,
|
||||
if (ndo->ndo_vflag > 1) {
|
||||
TRUNCRET(4);
|
||||
ND_PRINT((ndo, " ifmtu"));
|
||||
INTOUT();
|
||||
UINTOUT();
|
||||
|
||||
TRUNCRET(4);
|
||||
ND_PRINT((ndo, " maxmtu"));
|
||||
INTOUT();
|
||||
UINTOUT();
|
||||
|
||||
TRUNCRET(4);
|
||||
ND_PRINT((ndo, " rwind"));
|
||||
INTOUT();
|
||||
UINTOUT();
|
||||
|
||||
TRUNCRET(4);
|
||||
ND_PRINT((ndo, " maxpackets"));
|
||||
INTOUT();
|
||||
UINTOUT();
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -167,7 +167,7 @@ sliplink_print(netdissect_options *ndo,
|
||||
* Get it from the link layer since sl_uncompress_tcp()
|
||||
* has restored the IP header copy to IPPROTO_TCP.
|
||||
*/
|
||||
lastconn = ((const struct ip *)(p + SLX_CHDR))->ip_p;
|
||||
lastconn = EXTRACT_U_1(((const struct ip *)(p + SLX_CHDR))->ip_p);
|
||||
ND_PRINT((ndo, "utcp %d: ", lastconn));
|
||||
if (dir == -1) {
|
||||
/* Direction is bogus, don't use it */
|
||||
|
172
print-slow.c
172
print-slow.c
@ -75,15 +75,15 @@ static const struct tok slow_oam_code_values[] = {
|
||||
};
|
||||
|
||||
struct slow_oam_info_t {
|
||||
uint8_t info_type;
|
||||
uint8_t info_length;
|
||||
uint8_t oam_version;
|
||||
uint8_t revision[2];
|
||||
uint8_t state;
|
||||
uint8_t oam_config;
|
||||
uint8_t oam_pdu_config[2];
|
||||
uint8_t oui[3];
|
||||
uint8_t vendor_private[4];
|
||||
nd_uint8_t info_type;
|
||||
nd_uint8_t info_length;
|
||||
nd_uint8_t oam_version;
|
||||
nd_uint16_t revision;
|
||||
nd_uint8_t state;
|
||||
nd_uint8_t oam_config;
|
||||
nd_uint16_t oam_pdu_config;
|
||||
nd_uint24_t oui;
|
||||
nd_uint32_t vendor_private;
|
||||
};
|
||||
|
||||
#define SLOW_OAM_INFO_TYPE_END_OF_TLV 0x00
|
||||
@ -145,29 +145,29 @@ static const struct tok slow_oam_link_event_values[] = {
|
||||
};
|
||||
|
||||
struct slow_oam_link_event_t {
|
||||
uint8_t event_type;
|
||||
uint8_t event_length;
|
||||
uint8_t time_stamp[2];
|
||||
uint8_t window[8];
|
||||
uint8_t threshold[8];
|
||||
uint8_t errors[8];
|
||||
uint8_t errors_running_total[8];
|
||||
uint8_t event_running_total[4];
|
||||
nd_uint8_t event_type;
|
||||
nd_uint8_t event_length;
|
||||
nd_uint16_t time_stamp;
|
||||
nd_uint64_t window;
|
||||
nd_uint64_t threshold;
|
||||
nd_uint64_t errors;
|
||||
nd_uint64_t errors_running_total;
|
||||
nd_uint32_t event_running_total;
|
||||
};
|
||||
|
||||
struct slow_oam_variablerequest_t {
|
||||
uint8_t branch;
|
||||
uint8_t leaf[2];
|
||||
nd_uint8_t branch;
|
||||
nd_uint16_t leaf;
|
||||
};
|
||||
|
||||
struct slow_oam_variableresponse_t {
|
||||
uint8_t branch;
|
||||
uint8_t leaf[2];
|
||||
uint8_t length;
|
||||
nd_uint8_t branch;
|
||||
nd_uint16_t leaf;
|
||||
nd_uint8_t length;
|
||||
};
|
||||
|
||||
struct slow_oam_loopbackctrl_t {
|
||||
uint8_t command;
|
||||
nd_uint8_t command;
|
||||
};
|
||||
|
||||
static const struct tok slow_oam_loopbackctrl_cmd_values[] = {
|
||||
@ -201,12 +201,12 @@ static const struct tok slow_tlv_values[] = {
|
||||
};
|
||||
|
||||
struct lacp_tlv_actor_partner_info_t {
|
||||
uint8_t sys_pri[2];
|
||||
nd_uint16_t sys_pri;
|
||||
uint8_t sys[ETHER_ADDR_LEN];
|
||||
uint8_t key[2];
|
||||
uint8_t port_pri[2];
|
||||
uint8_t port[2];
|
||||
uint8_t state;
|
||||
nd_uint16_t key;
|
||||
nd_uint16_t port_pri;
|
||||
nd_uint16_t port;
|
||||
nd_uint8_t state;
|
||||
uint8_t pad[3];
|
||||
};
|
||||
|
||||
@ -223,14 +223,14 @@ static const struct tok lacp_tlv_actor_partner_info_state_values[] = {
|
||||
};
|
||||
|
||||
struct lacp_tlv_collector_info_t {
|
||||
uint8_t max_delay[2];
|
||||
nd_uint16_t max_delay;
|
||||
uint8_t pad[12];
|
||||
};
|
||||
|
||||
struct marker_tlv_marker_info_t {
|
||||
uint8_t req_port[2];
|
||||
nd_uint16_t req_port;
|
||||
uint8_t req_sys[ETHER_ADDR_LEN];
|
||||
uint8_t req_trans_id[4];
|
||||
nd_uint32_t req_trans_id;
|
||||
uint8_t pad[2];
|
||||
};
|
||||
|
||||
@ -424,7 +424,7 @@ slow_marker_lacp_print(netdissect_options *ndo,
|
||||
EXTRACT_BE_U_2(tlv_ptr.lacp_tlv_actor_partner_info->port_pri),
|
||||
bittok2str(lacp_tlv_actor_partner_info_state_values,
|
||||
"none",
|
||||
tlv_ptr.lacp_tlv_actor_partner_info->state)));
|
||||
EXTRACT_U_1(tlv_ptr.lacp_tlv_actor_partner_info->state))));
|
||||
|
||||
break;
|
||||
|
||||
@ -490,16 +490,20 @@ static void
|
||||
slow_oam_print(netdissect_options *ndo,
|
||||
register const u_char *tptr, register u_int tlen)
|
||||
{
|
||||
uint8_t code;
|
||||
uint8_t type, length;
|
||||
uint8_t state;
|
||||
uint8_t command;
|
||||
u_int hexdump;
|
||||
|
||||
struct slow_oam_common_header_t {
|
||||
uint8_t flags[2];
|
||||
uint8_t code;
|
||||
nd_uint16_t flags;
|
||||
nd_uint8_t code;
|
||||
};
|
||||
|
||||
struct slow_oam_tlv_header_t {
|
||||
uint8_t type;
|
||||
uint8_t length;
|
||||
nd_uint8_t type;
|
||||
nd_uint8_t length;
|
||||
};
|
||||
|
||||
union {
|
||||
@ -522,26 +526,28 @@ slow_oam_print(netdissect_options *ndo,
|
||||
tptr += sizeof(struct slow_oam_common_header_t);
|
||||
tlen -= sizeof(struct slow_oam_common_header_t);
|
||||
|
||||
code = EXTRACT_U_1(ptr.slow_oam_common_header->code);
|
||||
ND_PRINT((ndo, "\n\tCode %s OAM PDU, Flags [%s]",
|
||||
tok2str(slow_oam_code_values, "Unknown (%u)", ptr.slow_oam_common_header->code),
|
||||
tok2str(slow_oam_code_values, "Unknown (%u)", code),
|
||||
bittok2str(slow_oam_flag_values,
|
||||
"none",
|
||||
EXTRACT_BE_U_2(&ptr.slow_oam_common_header->flags))));
|
||||
EXTRACT_BE_U_2(ptr.slow_oam_common_header->flags))));
|
||||
|
||||
switch (ptr.slow_oam_common_header->code) {
|
||||
switch (code) {
|
||||
case SLOW_OAM_CODE_INFO:
|
||||
while (tlen > 0) {
|
||||
ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr;
|
||||
if (tlen < sizeof(*ptr.slow_oam_tlv_header))
|
||||
goto tooshort;
|
||||
ND_TCHECK(*ptr.slow_oam_tlv_header);
|
||||
type = EXTRACT_U_1(ptr.slow_oam_tlv_header->type);
|
||||
length = EXTRACT_U_1(ptr.slow_oam_tlv_header->length);
|
||||
ND_PRINT((ndo, "\n\t %s Information Type (%u), length %u",
|
||||
tok2str(slow_oam_info_type_values, "Reserved",
|
||||
ptr.slow_oam_tlv_header->type),
|
||||
ptr.slow_oam_tlv_header->type,
|
||||
ptr.slow_oam_tlv_header->length));
|
||||
tok2str(slow_oam_info_type_values, "Reserved", type),
|
||||
type,
|
||||
length));
|
||||
|
||||
if (ptr.slow_oam_tlv_header->type == SLOW_OAM_INFO_TYPE_END_OF_TLV) {
|
||||
if (type == SLOW_OAM_INFO_TYPE_END_OF_TLV) {
|
||||
/*
|
||||
* As IEEE Std 802.3-2015 says for the End of TLV Marker,
|
||||
* "(the length and value of the Type 0x00 TLV can be ignored)".
|
||||
@ -550,23 +556,23 @@ slow_oam_print(netdissect_options *ndo,
|
||||
}
|
||||
|
||||
/* length includes the type and length fields */
|
||||
if (ptr.slow_oam_tlv_header->length < sizeof(struct slow_oam_tlv_header_t)) {
|
||||
if (length < sizeof(struct slow_oam_tlv_header_t)) {
|
||||
ND_PRINT((ndo, "\n\t ERROR: illegal length - should be >= %u",
|
||||
(u_int)sizeof(struct slow_oam_tlv_header_t)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (tlen < ptr.slow_oam_tlv_header->length)
|
||||
if (tlen < length)
|
||||
goto tooshort;
|
||||
ND_TCHECK2(*tptr, ptr.slow_oam_tlv_header->length);
|
||||
ND_TCHECK2(*tptr, length);
|
||||
|
||||
hexdump = FALSE;
|
||||
switch (ptr.slow_oam_tlv_header->type) {
|
||||
switch (type) {
|
||||
case SLOW_OAM_INFO_TYPE_LOCAL: /* identical format - fall through */
|
||||
case SLOW_OAM_INFO_TYPE_REMOTE:
|
||||
tlv.slow_oam_info = (const struct slow_oam_info_t *)tptr;
|
||||
|
||||
if (tlv.slow_oam_info->info_length !=
|
||||
if (EXTRACT_U_1(tlv.slow_oam_info->info_length) !=
|
||||
sizeof(struct slow_oam_info_t)) {
|
||||
ND_PRINT((ndo, "\n\t ERROR: illegal length - should be %lu",
|
||||
(unsigned long) sizeof(struct slow_oam_info_t)));
|
||||
@ -575,24 +581,25 @@ slow_oam_print(netdissect_options *ndo,
|
||||
}
|
||||
|
||||
ND_PRINT((ndo, "\n\t OAM-Version %u, Revision %u",
|
||||
tlv.slow_oam_info->oam_version,
|
||||
EXTRACT_BE_U_2(&tlv.slow_oam_info->revision)));
|
||||
EXTRACT_U_1(tlv.slow_oam_info->oam_version),
|
||||
EXTRACT_BE_U_2(tlv.slow_oam_info->revision)));
|
||||
|
||||
state = EXTRACT_U_1(tlv.slow_oam_info->state);
|
||||
ND_PRINT((ndo, "\n\t State-Parser-Action %s, State-MUX-Action %s",
|
||||
tok2str(slow_oam_info_type_state_parser_values, "Reserved",
|
||||
tlv.slow_oam_info->state & OAM_INFO_TYPE_PARSER_MASK),
|
||||
state & OAM_INFO_TYPE_PARSER_MASK),
|
||||
tok2str(slow_oam_info_type_state_mux_values, "Reserved",
|
||||
tlv.slow_oam_info->state & OAM_INFO_TYPE_MUX_MASK)));
|
||||
state & OAM_INFO_TYPE_MUX_MASK)));
|
||||
ND_PRINT((ndo, "\n\t OAM-Config Flags [%s], OAM-PDU-Config max-PDU size %u",
|
||||
bittok2str(slow_oam_info_type_oam_config_values, "none",
|
||||
tlv.slow_oam_info->oam_config),
|
||||
EXTRACT_BE_U_2(&tlv.slow_oam_info->oam_pdu_config) &
|
||||
EXTRACT_U_1(tlv.slow_oam_info->oam_config)),
|
||||
EXTRACT_BE_U_2(tlv.slow_oam_info->oam_pdu_config) &
|
||||
OAM_INFO_TYPE_PDU_SIZE_MASK));
|
||||
ND_PRINT((ndo, "\n\t OUI %s (0x%06x), Vendor-Private 0x%08x",
|
||||
tok2str(oui_values, "Unknown",
|
||||
EXTRACT_BE_U_3(&tlv.slow_oam_info->oui)),
|
||||
EXTRACT_BE_U_3(&tlv.slow_oam_info->oui),
|
||||
EXTRACT_BE_U_4(&tlv.slow_oam_info->vendor_private)));
|
||||
EXTRACT_BE_U_3(tlv.slow_oam_info->oui)),
|
||||
EXTRACT_BE_U_3(tlv.slow_oam_info->oui),
|
||||
EXTRACT_BE_U_4(tlv.slow_oam_info->vendor_private)));
|
||||
break;
|
||||
|
||||
case SLOW_OAM_INFO_TYPE_ORG_SPECIFIC:
|
||||
@ -608,11 +615,11 @@ slow_oam_print(netdissect_options *ndo,
|
||||
/* do we also want to see a hex dump ? */
|
||||
if (ndo->ndo_vflag > 1 || hexdump==TRUE) {
|
||||
print_unknown_data(ndo, tptr, "\n\t ",
|
||||
ptr.slow_oam_tlv_header->length);
|
||||
length);
|
||||
}
|
||||
|
||||
tlen -= ptr.slow_oam_tlv_header->length;
|
||||
tptr += ptr.slow_oam_tlv_header->length;
|
||||
tlen -= length;
|
||||
tptr += length;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -631,13 +638,15 @@ slow_oam_print(netdissect_options *ndo,
|
||||
if (tlen < sizeof(*ptr.slow_oam_tlv_header))
|
||||
goto tooshort;
|
||||
ND_TCHECK(*ptr.slow_oam_tlv_header);
|
||||
type = EXTRACT_U_1(ptr.slow_oam_tlv_header->type);
|
||||
length = EXTRACT_U_1(ptr.slow_oam_tlv_header->length);
|
||||
ND_PRINT((ndo, "\n\t %s Link Event Type (%u), length %u",
|
||||
tok2str(slow_oam_link_event_values, "Reserved",
|
||||
ptr.slow_oam_tlv_header->type),
|
||||
ptr.slow_oam_tlv_header->type,
|
||||
ptr.slow_oam_tlv_header->length));
|
||||
type),
|
||||
type,
|
||||
length));
|
||||
|
||||
if (ptr.slow_oam_tlv_header->type == SLOW_OAM_INFO_TYPE_END_OF_TLV) {
|
||||
if (type == SLOW_OAM_INFO_TYPE_END_OF_TLV) {
|
||||
/*
|
||||
* As IEEE Std 802.3-2015 says for the End of TLV Marker,
|
||||
* "(the length and value of the Type 0x00 TLV can be ignored)".
|
||||
@ -646,25 +655,25 @@ slow_oam_print(netdissect_options *ndo,
|
||||
}
|
||||
|
||||
/* length includes the type and length fields */
|
||||
if (ptr.slow_oam_tlv_header->length < sizeof(struct slow_oam_tlv_header_t)) {
|
||||
if (length < sizeof(struct slow_oam_tlv_header_t)) {
|
||||
ND_PRINT((ndo, "\n\t ERROR: illegal length - should be >= %u",
|
||||
(u_int)sizeof(struct slow_oam_tlv_header_t)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (tlen < ptr.slow_oam_tlv_header->length)
|
||||
if (tlen < length)
|
||||
goto tooshort;
|
||||
ND_TCHECK2(*tptr, ptr.slow_oam_tlv_header->length);
|
||||
ND_TCHECK2(*tptr, length);
|
||||
|
||||
hexdump = FALSE;
|
||||
switch (ptr.slow_oam_tlv_header->type) {
|
||||
switch (type) {
|
||||
case SLOW_OAM_LINK_EVENT_ERR_SYM_PER: /* identical format - fall through */
|
||||
case SLOW_OAM_LINK_EVENT_ERR_FRM:
|
||||
case SLOW_OAM_LINK_EVENT_ERR_FRM_PER:
|
||||
case SLOW_OAM_LINK_EVENT_ERR_FRM_SUMM:
|
||||
tlv.slow_oam_link_event = (const struct slow_oam_link_event_t *)tptr;
|
||||
|
||||
if (tlv.slow_oam_link_event->event_length !=
|
||||
if (EXTRACT_U_1(tlv.slow_oam_link_event->event_length) !=
|
||||
sizeof(struct slow_oam_link_event_t)) {
|
||||
ND_PRINT((ndo, "\n\t ERROR: illegal length - should be %lu",
|
||||
(unsigned long) sizeof(struct slow_oam_link_event_t)));
|
||||
@ -677,12 +686,12 @@ slow_oam_print(netdissect_options *ndo,
|
||||
"\n\t Errors %" PRIu64
|
||||
"\n\t Error Running Total %" PRIu64
|
||||
"\n\t Event Running Total %u",
|
||||
EXTRACT_BE_U_2(&tlv.slow_oam_link_event->time_stamp)*100,
|
||||
EXTRACT_BE_U_8(&tlv.slow_oam_link_event->window),
|
||||
EXTRACT_BE_U_8(&tlv.slow_oam_link_event->threshold),
|
||||
EXTRACT_BE_U_8(&tlv.slow_oam_link_event->errors),
|
||||
EXTRACT_BE_U_8(&tlv.slow_oam_link_event->errors_running_total),
|
||||
EXTRACT_BE_U_4(&tlv.slow_oam_link_event->event_running_total)));
|
||||
EXTRACT_BE_U_2(tlv.slow_oam_link_event->time_stamp)*100,
|
||||
EXTRACT_BE_U_8(tlv.slow_oam_link_event->window),
|
||||
EXTRACT_BE_U_8(tlv.slow_oam_link_event->threshold),
|
||||
EXTRACT_BE_U_8(tlv.slow_oam_link_event->errors),
|
||||
EXTRACT_BE_U_8(tlv.slow_oam_link_event->errors_running_total),
|
||||
EXTRACT_BE_U_4(tlv.slow_oam_link_event->event_running_total)));
|
||||
break;
|
||||
|
||||
case SLOW_OAM_LINK_EVENT_ORG_SPECIFIC:
|
||||
@ -698,11 +707,11 @@ slow_oam_print(netdissect_options *ndo,
|
||||
/* do we also want to see a hex dump ? */
|
||||
if (ndo->ndo_vflag > 1 || hexdump==TRUE) {
|
||||
print_unknown_data(ndo, tptr, "\n\t ",
|
||||
ptr.slow_oam_tlv_header->length);
|
||||
length);
|
||||
}
|
||||
|
||||
tlen -= ptr.slow_oam_tlv_header->length;
|
||||
tptr += ptr.slow_oam_tlv_header->length;
|
||||
tlen -= length;
|
||||
tptr += length;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -711,11 +720,12 @@ slow_oam_print(netdissect_options *ndo,
|
||||
if (tlen < sizeof(*tlv.slow_oam_loopbackctrl))
|
||||
goto tooshort;
|
||||
ND_TCHECK(*tlv.slow_oam_loopbackctrl);
|
||||
command = EXTRACT_U_1(tlv.slow_oam_loopbackctrl->command);
|
||||
ND_PRINT((ndo, "\n\t Command %s (%u)",
|
||||
tok2str(slow_oam_loopbackctrl_cmd_values,
|
||||
"Unknown",
|
||||
tlv.slow_oam_loopbackctrl->command),
|
||||
tlv.slow_oam_loopbackctrl->command));
|
||||
command),
|
||||
command));
|
||||
tptr ++;
|
||||
tlen --;
|
||||
break;
|
||||
|
@ -202,7 +202,7 @@ tcp_print(netdissect_options *ndo,
|
||||
tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
|
||||
}
|
||||
} else {
|
||||
if (ip->ip_p == IPPROTO_TCP) {
|
||||
if (EXTRACT_U_1(ip->ip_p) == IPPROTO_TCP) {
|
||||
ND_PRINT((ndo, "%s.%s > %s.%s: ",
|
||||
ipaddr_string(ndo, &ip->ip_src),
|
||||
tcpport_string(ndo, sport),
|
||||
|
@ -344,7 +344,7 @@ udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dpo
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ip->ip_p == IPPROTO_UDP) {
|
||||
if (EXTRACT_U_1(ip->ip_p) == IPPROTO_UDP) {
|
||||
if (sport == -1) {
|
||||
ND_PRINT((ndo, "%s > %s: ",
|
||||
ipaddr_string(ndo, &ip->ip_src),
|
||||
|
Loading…
Reference in New Issue
Block a user