In: if (... p[n] ...) ...
15 files changed:
message = cp + 4 + i;
ND_TCHECK_1(message);
message = cp + 4 + i;
ND_TCHECK_1(message);
- if((type = message[0]) == MESSAGE_PAD1) {
+ if((type = EXTRACT_U_1(message)) == MESSAGE_PAD1) {
ND_PRINT((ndo, ndo->ndo_vflag ? "\n\tPad 1" : " pad1"));
i += 1;
continue;
ND_PRINT((ndo, ndo->ndo_vflag ? "\n\tPad 1" : " pad1"));
i += 1;
continue;
(EXTRACT_U_1(message + 3) & 0x3f) ? "/unknown" : "",
format_prefix(ndo, prefix, plen),
metric, seqno, format_interval_update(interval)));
(EXTRACT_U_1(message + 3) & 0x3f) ? "/unknown" : "",
format_prefix(ndo, prefix, plen),
metric, seqno, format_interval_update(interval)));
- if(message[3] & 0x80) {
+ if(EXTRACT_U_1(message + 3) & 0x80) {
if(message[2] == 1)
memcpy(v4_prefix, prefix, 16);
else
if(message[2] == 1)
memcpy(v4_prefix, prefix, 16);
else
/*
* If we do not find a valid segment type, our guess might be wrong.
*/
/*
* If we do not find a valid segment type, our guess might be wrong.
*/
- if (tptr[0] < BGP_AS_SEG_TYPE_MIN || tptr[0] > BGP_AS_SEG_TYPE_MAX) {
+ if (EXTRACT_U_1(tptr) < BGP_AS_SEG_TYPE_MIN || EXTRACT_U_1(tptr) > BGP_AS_SEG_TYPE_MAX) {
goto trunc;
}
ND_TCHECK(tptr[1]);
goto trunc;
}
ND_TCHECK(tptr[1]);
while (p < ep) {
if (!ND_TTEST_1(p))
break;
while (p < ep) {
if (!ND_TTEST_1(p))
break;
+ if (EXTRACT_U_1(p) != 0xff) {
ND_TCHECK_3(bp);
mask = (uint32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2];
width = 1;
ND_TCHECK_3(bp);
mask = (uint32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2];
width = 1;
+ if (EXTRACT_U_1(bp + 1))
+ if (EXTRACT_U_1(bp + 2))
width = 4;
ND_PRINT((ndo, "\n\tMask %s", intoa(htonl(mask))));
width = 4;
ND_PRINT((ndo, "\n\tMask %s", intoa(htonl(mask))));
case HNCP_DELEGATED_PREFIX: {
int l;
case HNCP_DELEGATED_PREFIX: {
int l;
- if (bodylen < 9 || bodylen < 9 + (value[8] + 7) / 8) {
+ if (bodylen < 9 || bodylen < 9 + (EXTRACT_U_1(value + 8) + 7) / 8) {
ND_PRINT((ndo, " %s", istr));
break;
}
ND_PRINT((ndo, " %s", istr));
break;
}
case HNCP_ASSIGNED_PREFIX: {
uint8_t prty;
int l;
case HNCP_ASSIGNED_PREFIX: {
uint8_t prty;
int l;
- if (bodylen < 6 || bodylen < 6 + (value[5] + 7) / 8) {
+ if (bodylen < 6 || bodylen < 6 + (EXTRACT_U_1(value + 5) + 7) / 8) {
ND_PRINT((ndo, " %s", istr));
break;
}
ND_PRINT((ndo, " %s", istr));
break;
}
if (ndo->ndo_vflag) {
ND_TCHECK(bp[25]);
if (ndo->ndo_vflag) {
ND_TCHECK(bp[25]);
+ if (EXTRACT_U_1(bp + 24) & 0x08) {
ND_PRINT((ndo," sflag"));
}
ND_PRINT((ndo," sflag"));
}
+ if (EXTRACT_U_1(bp + 24) & 0x07) {
ND_PRINT((ndo," robustness=%d", EXTRACT_U_1(bp + 24) & 0x07));
}
if (bp[25] < 128) {
ND_PRINT((ndo," robustness=%d", EXTRACT_U_1(bp + 24) & 0x07));
}
if (bp[25] < 128) {
ND_PRINT((ndo, "(rtalert: trunc)"));
goto trunc;
}
ND_PRINT((ndo, "(rtalert: trunc)"));
goto trunc;
}
- if (bp[i + 1] != IP6OPT_RTALERT_LEN - 2) {
+ if (EXTRACT_U_1(bp + i + 1) != IP6OPT_RTALERT_LEN - 2) {
ND_PRINT((ndo, "(rtalert: invalid len %d)", EXTRACT_U_1(bp + i + 1)));
goto trunc;
}
ND_PRINT((ndo, "(rtalert: invalid len %d)", EXTRACT_U_1(bp + i + 1)));
goto trunc;
}
ND_PRINT((ndo, "(jumbo: trunc)"));
goto trunc;
}
ND_PRINT((ndo, "(jumbo: trunc)"));
goto trunc;
}
- if (bp[i + 1] != IP6OPT_JUMBO_LEN - 2) {
+ if (EXTRACT_U_1(bp + i + 1) != IP6OPT_JUMBO_LEN - 2) {
ND_PRINT((ndo, "(jumbo: invalid len %d)", EXTRACT_U_1(bp + i + 1)));
goto trunc;
}
ND_PRINT((ndo, "(jumbo: invalid len %d)", EXTRACT_U_1(bp + i + 1)));
goto trunc;
}
ND_PRINT((ndo, "(homeaddr: trunc)"));
goto trunc;
}
ND_PRINT((ndo, "(homeaddr: trunc)"));
goto trunc;
}
- if (bp[i + 1] < IP6OPT_HOMEADDR_MINLEN - 2) {
+ if (EXTRACT_U_1(bp + i + 1) < IP6OPT_HOMEADDR_MINLEN - 2) {
ND_PRINT((ndo, "(homeaddr: invalid len %d)", EXTRACT_U_1(bp + i + 1)));
goto trunc;
}
ND_PRINT((ndo, "(homeaddr: %s", ip6addr_string(ndo, bp + i + 2)));
ND_PRINT((ndo, "(homeaddr: invalid len %d)", EXTRACT_U_1(bp + i + 1)));
goto trunc;
}
ND_PRINT((ndo, "(homeaddr: %s", ip6addr_string(ndo, bp + i + 2)));
- if (bp[i + 1] > IP6OPT_HOMEADDR_MINLEN - 2) {
+ if (EXTRACT_U_1(bp + i + 1) > IP6OPT_HOMEADDR_MINLEN - 2) {
ip6_sopt_print(ndo, bp + i + IP6OPT_HOMEADDR_MINLEN,
(optlen - IP6OPT_HOMEADDR_MINLEN));
}
ip6_sopt_print(ndo, bp + i + IP6OPT_HOMEADDR_MINLEN,
(optlen - IP6OPT_HOMEADDR_MINLEN));
}
const u_char *bp2)
{
ND_TCHECK(bp[0]);
const u_char *bp2)
{
ND_TCHECK(bp[0]);
- if(length == 1 && bp[0]==0xff) {
+ if(length == 1 && EXTRACT_U_1(bp)==0xff) {
ND_PRINT((ndo, "isakmp-nat-keep-alive"));
return;
}
ND_PRINT((ndo, "isakmp-nat-keep-alive"));
return;
}
/*
* see if this is an IKE packet
*/
/*
* see if this is an IKE packet
*/
- if(bp[0]==0 && bp[1]==0 && bp[2]==0 && bp[3]==0) {
+ if (EXTRACT_U_1(bp) == 0 && EXTRACT_U_1(bp + 1) == 0 &&
+ EXTRACT_U_1(bp + 2) == 0 && EXTRACT_U_1(bp + 3) == 0) {
ND_PRINT((ndo, "NONESP-encap: "));
isakmp_print(ndo, bp+4, length-4, bp2);
return;
ND_PRINT((ndo, "NONESP-encap: "));
isakmp_print(ndo, bp+4, length-4, bp2);
return;
return l2info.header_len;
}
return l2info.header_len;
}
- if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */
+ if (EXTRACT_U_1(p) == 0x03) { /* Cisco style NLPID encaps ? */
isoclns_print(ndo, p + 1, l2info.length - 1);
/* FIXME check if frame was recognized */
return l2info.header_len;
isoclns_print(ndo, p + 1, l2info.length - 1);
/* FIXME check if frame was recognized */
return l2info.header_len;
return l2info.header_len;
}
return l2info.header_len;
}
- if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */
+ if (EXTRACT_U_1(p) == 0x03) { /* Cisco style NLPID encaps ? */
isoclns_print(ndo, p + 1, l2info.length - 1);
/* FIXME check if frame was recognized */
return l2info.header_len;
isoclns_print(ndo, p + 1, l2info.length - 1);
/* FIXME check if frame was recognized */
return l2info.header_len;
#ifdef DLT_JUNIPER_MFR
/* MFR child links don't carry cookies */
if (l2info->pictype == DLT_JUNIPER_MFR &&
#ifdef DLT_JUNIPER_MFR
/* MFR child links don't carry cookies */
if (l2info->pictype == DLT_JUNIPER_MFR &&
- (p[0] & MFR_BE_MASK) == MFR_BE_MASK) {
+ (EXTRACT_U_1(p) & MFR_BE_MASK) == MFR_BE_MASK) {
l2info->cookie_len = 0;
}
#endif
l2info->cookie_len = 0;
}
#endif
ND_PRINT((ndo, " seq#=%u", EXTRACT_BE_U_2(&mh->ip6m_data16[0])));
hlen = IP6M_MINLEN;
ND_TCHECK_2(bp + hlen);
ND_PRINT((ndo, " seq#=%u", EXTRACT_BE_U_2(&mh->ip6m_data16[0])));
hlen = IP6M_MINLEN;
ND_TCHECK_2(bp + hlen);
+ if (EXTRACT_U_1(bp + hlen) & 0xf0) {
+ if (EXTRACT_U_1(bp + hlen) & 0x80)
+ if (EXTRACT_U_1(bp + hlen) & 0x40)
+ if (EXTRACT_U_1(bp + hlen) & 0x20)
+ if (EXTRACT_U_1(bp + hlen) & 0x10)
ND_PRINT((ndo, "K"));
}
/* Reserved (4bits) */
ND_PRINT((ndo, "K"));
}
/* Reserved (4bits) */
int njp;
/* If it's a single group and a single source, use 1-line output. */
int njp;
/* If it's a single group and a single source, use 1-line output. */
- if (ND_TTEST2(bp[0], 30) && bp[11] == 1 &&
+ if (ND_TTEST2(bp[0], 30) && EXTRACT_U_1(bp + 11) == 1 &&
((njoin = EXTRACT_BE_U_2(bp + 20)) + EXTRACT_BE_U_2(bp + 22)) == 1) {
int hold;
((njoin = EXTRACT_BE_U_2(bp + 20)) + EXTRACT_BE_U_2(bp + 22)) == 1) {
int hold;
break;
}
ND_TCHECK(bp[4]);
break;
}
ND_TCHECK(bp[4]);
+ if ((EXTRACT_U_1(bp + 4) >> 4) != 1)
ND_PRINT((ndo, " [v%d]", EXTRACT_U_1(bp + 4) >> 4));
return;
ND_PRINT((ndo, " [v%d]", EXTRACT_U_1(bp + 4) >> 4));
return;
case 3: ND_PRINT((ndo, " PIMv1+2"));
break;
}
case 3: ND_PRINT((ndo, " PIMv1+2"));
break;
}
+ if (EXTRACT_U_1(bp) & 0xfc)
ND_PRINT((ndo, " [rsvd=0x%02x]", EXTRACT_U_1(bp) & 0xfc));
bp += 1;
len -= 1;
ND_PRINT((ndo, " [rsvd=0x%02x]", EXTRACT_U_1(bp) & 0xfc));
bp += 1;
len -= 1;
ND_TCHECK_6(bp);
ND_PRINT((ndo, "%c%s%s/%d", s, EXTRACT_U_1(bp) & 1 ? "!" : "",
ipaddr_string(ndo, bp + 2), EXTRACT_U_1(bp + 1)));
ND_TCHECK_6(bp);
ND_PRINT((ndo, "%c%s%s/%d", s, EXTRACT_U_1(bp) & 1 ? "!" : "",
ipaddr_string(ndo, bp + 2), EXTRACT_U_1(bp + 1)));
+ if (EXTRACT_U_1(bp) & 0x02) {
ND_PRINT((ndo, " bidir"));
}
ND_PRINT((ndo, " bidir"));
}
+ if (EXTRACT_U_1(bp) & 0xfc) {
ND_PRINT((ndo, "[rsvd=0x%02x]", EXTRACT_U_1(bp) & 0xfc));
}
s = ',';
ND_PRINT((ndo, "[rsvd=0x%02x]", EXTRACT_U_1(bp) & 0xfc));
}
s = ',';
+ if (EXTRACT_U_1(bp + 1) != 0)
return -1;
hdrlen = 2;
} else {
return -1;
hdrlen = 2;
} else {
if (af == AF_INET) {
if (!silent) {
ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp + 2)));
if (af == AF_INET) {
if (!silent) {
ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp + 2)));
+ if (EXTRACT_U_1(bp + 1) != 32)
ND_PRINT((ndo, "/%u", EXTRACT_U_1(bp + 1)));
}
}
else if (af == AF_INET6) {
if (!silent) {
ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp + 2)));
ND_PRINT((ndo, "/%u", EXTRACT_U_1(bp + 1)));
}
}
else if (af == AF_INET6) {
if (!silent) {
ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp + 2)));
+ if (EXTRACT_U_1(bp + 1) != 128)
ND_PRINT((ndo, "/%u", EXTRACT_U_1(bp + 1)));
}
}
ND_PRINT((ndo, "/%u", EXTRACT_U_1(bp + 1)));
}
}
- if (bp[0] && !silent) {
+ if (EXTRACT_U_1(bp) && !silent) {
if (at == pimv2_group) {
ND_PRINT((ndo, "(0x%02x)", EXTRACT_U_1(bp)));
} else {
if (at == pimv2_group) {
ND_PRINT((ndo, "(0x%02x)", EXTRACT_U_1(bp)));
} else {
EXTRACT_U_1(bp) & 0x04 ? "S" : "",
EXTRACT_U_1(bp) & 0x02 ? "W" : "",
EXTRACT_U_1(bp) & 0x01 ? "R" : ""));
EXTRACT_U_1(bp) & 0x04 ? "S" : "",
EXTRACT_U_1(bp) & 0x02 ? "W" : "",
EXTRACT_U_1(bp) & 0x01 ? "R" : ""));
+ if (EXTRACT_U_1(bp) & 0xf8) {
ND_PRINT((ndo, "+0x%02x", EXTRACT_U_1(bp) & 0xf8));
}
ND_PRINT((ndo, ")"));
ND_PRINT((ndo, "+0x%02x", EXTRACT_U_1(bp) & 0xf8));
}
ND_PRINT((ndo, ")"));
if (len < 8)
goto trunc;
ND_TCHECK_8(bp);
if (len < 8)
goto trunc;
ND_TCHECK_8(bp);
+ if (EXTRACT_U_1(bp) & 0x80)
ND_PRINT((ndo, " RPT"));
ND_PRINT((ndo, " pref=%u", EXTRACT_BE_U_4(bp) & 0x7fffffff));
ND_PRINT((ndo, " metric=%u", EXTRACT_BE_U_4(bp + 4)));
ND_PRINT((ndo, " RPT"));
ND_PRINT((ndo, " pref=%u", EXTRACT_BE_U_4(bp) & 0x7fffffff));
ND_PRINT((ndo, " metric=%u", EXTRACT_BE_U_4(bp + 4)));
return;
}
ND_TCHECK2(data[0], length);
return;
}
ND_TCHECK2(data[0], length);
+ if (EXTRACT_U_1(data + 1) > 128)
{
ND_PRINT((ndo, "ERROR: netmask %u not in range (0..128)", EXTRACT_U_1(data + 1)));
return;
{
ND_PRINT((ndo, "ERROR: netmask %u not in range (0..128)", EXTRACT_U_1(data + 1)));
return;
ND_PRINT((ndo, "%s/%u", ip6addr_string(ndo, data2), EXTRACT_U_1(data + 1)));
ND_PRINT((ndo, "%s/%u", ip6addr_string(ndo, data2), EXTRACT_U_1(data + 1)));
- if (data[1] > 8 * (length - 2))
+ if (EXTRACT_U_1(data + 1) > 8 * (length - 2))
ND_PRINT((ndo, " (inconsistent prefix length)"));
return;
ND_PRINT((ndo, " (inconsistent prefix length)"));
return;
data = buf + EXTRACT_LE_U_2(w + 12 * 2);
fn = smbfindint(EXTRACT_LE_U_2(w + 14 * 2), trans2_fns);
} else {
data = buf + EXTRACT_LE_U_2(w + 12 * 2);
fn = smbfindint(EXTRACT_LE_U_2(w + 14 * 2), trans2_fns);
} else {
+ if (EXTRACT_U_1(words) == 0) {
ND_PRINT((ndo, "%s\n", fn->name));
ND_PRINT((ndo, "Trans2Interim\n"));
return;
ND_PRINT((ndo, "%s\n", fn->name));
ND_PRINT((ndo, "Trans2Interim\n"));
return;
if (nterror)
ND_PRINT((ndo, "NTError = %s\n", nt_errstr(nterror)));
} else {
if (nterror)
ND_PRINT((ndo, "NTError = %s\n", nt_errstr(nterror)));
} else {
+ if (EXTRACT_U_1(buf + 5))
ND_PRINT((ndo, "SMBError = %s\n", smb_errstr(EXTRACT_U_1(buf + 5),
EXTRACT_LE_U_2(buf + 7))));
}
ND_PRINT((ndo, "SMBError = %s\n", smb_errstr(EXTRACT_U_1(buf + 5),
EXTRACT_LE_U_2(buf + 7))));
}
if (p == NULL)
goto out;
ND_TCHECK(*p);
if (p == NULL)
goto out;
ND_TCHECK(*p);
+ if (EXTRACT_U_1(p) & 0x80)
ND_PRINT((ndo, "<GROUP> "));
switch (p[0] & 0x60) {
case 0x00: ND_PRINT((ndo, "B ")); break;
ND_PRINT((ndo, "<GROUP> "));
switch (p[0] & 0x60) {
case 0x00: ND_PRINT((ndo, "B ")); break;
case 0x40: ND_PRINT((ndo, "M ")); break;
case 0x60: ND_PRINT((ndo, "_ ")); break;
}
case 0x40: ND_PRINT((ndo, "M ")); break;
case 0x60: ND_PRINT((ndo, "_ ")); break;
}
+ if (EXTRACT_U_1(p) & 0x10)
ND_PRINT((ndo, "<DEREGISTERING> "));
ND_PRINT((ndo, "<DEREGISTERING> "));
+ if (EXTRACT_U_1(p) & 0x08)
ND_PRINT((ndo, "<CONFLICT> "));
ND_PRINT((ndo, "<CONFLICT> "));
+ if (EXTRACT_U_1(p) & 0x04)
ND_PRINT((ndo, "<ACTIVE> "));
ND_PRINT((ndo, "<ACTIVE> "));
+ if (EXTRACT_U_1(p) & 0x02)
ND_PRINT((ndo, "<PERMANENT> "));
ND_PRINT((ndo, "\n"));
p += 2;
ND_PRINT((ndo, "<PERMANENT> "));
ND_PRINT((ndo, "\n"));
p += 2;
p = sp;
while (length > (u_int)(p + 1 - sp)) {
ND_TCHECK_2(p);
p = sp;
while (length > (u_int)(p + 1 - sp)) {
ND_TCHECK_2(p);
- if (p[0] == IAC && p[1] == SE)
+ if (EXTRACT_U_1(p) == IAC && EXTRACT_U_1(p + 1) == SE)
#include <netdissect-stdinc.h>
#include "netdissect.h"
#include <netdissect-stdinc.h>
#include "netdissect.h"
#include "slcompress.h"
#include "ppp.h"
#include "slcompress.h"
#include "ppp.h"
if (ndo->ndo_eflag)
ND_PRINT((ndo, "(vjc type=compressed TCP) "));
for (i = 0; i < 8; i++) {
if (ndo->ndo_eflag)
ND_PRINT((ndo, "(vjc type=compressed TCP) "));
for (i = 0; i < 8; i++) {
- if (bp[1] & (0x80 >> i))
+ if (EXTRACT_U_1(bp + 1) & (0x80 >> i))
ND_PRINT((ndo, "%c", "?CI?SAWU"[i]));
}
ND_PRINT((ndo, "%c", "?CI?SAWU"[i]));
}
+ if (EXTRACT_U_1(bp + 1))
ND_PRINT((ndo, " "));
ND_PRINT((ndo, "C=0x%02x ", bp[2]));
ND_PRINT((ndo, "sum=0x%04x ", *(const u_short *)(bp + 3)));
ND_PRINT((ndo, " "));
ND_PRINT((ndo, "C=0x%02x ", bp[2]));
ND_PRINT((ndo, "sum=0x%04x ", *(const u_short *)(bp + 3)));
ND_TCHECK_2(in);
if (in + 1 >= maxbuf)
return(-1); /* name goes past the end of the buffer */
ND_TCHECK_2(in);
if (in + 1 >= maxbuf)
return(-1); /* name goes past the end of the buffer */
- if (in[0] < 'A' || in[0] > 'P' || in[1] < 'A' || in[1] > 'P') {
+ if (EXTRACT_U_1(in) < 'A' || EXTRACT_U_1(in) > 'P' ||
+ EXTRACT_U_1(in + 1) < 'A' || EXTRACT_U_1(in + 1) > 'P') {
for (;;) {
ND_TCHECK(sp[0]);
*len += 1;
for (;;) {
ND_TCHECK(sp[0]);
*len += 1;
+ if (EXTRACT_U_1(sp) == 0)
for (;;) {
ND_TCHECK_2(sp);
*len += 2;
for (;;) {
ND_TCHECK_2(sp);
*len += 2;
- if (sp[0] == 0 && sp[1] == 0)
+ if (EXTRACT_U_1(sp) == 0 && EXTRACT_U_1(sp + 1) == 0)
if (ND_ISPRINT(EXTRACT_U_1(s)))
buf[l] = s[0];
else {
if (ND_ISPRINT(EXTRACT_U_1(s)))
buf[l] = s[0];
else {
+ if (EXTRACT_U_1(s) == 0)
buf[l] = s[0];
} else {
/* It's a non-ASCII character or a non-printable ASCII character */
buf[l] = s[0];
} else {
/* It's a non-ASCII character or a non-printable ASCII character */
- if (s[0] == 0 && s[1] == 0)
+ if (EXTRACT_U_1(s) == 0 && EXTRACT_U_1(s + 1) == 0)