ND_TCHECK_2(message);
ICHECK(i, 2);
- len = message[1];
+ len = EXTRACT_U_1(message + 1);
ND_TCHECK2(*message, 2 + len);
ICHECK(i, 2 + len);
int parsed_len = 10;
ND_PRINT((ndo, "\n\tSS-Update"));
if(len < 10) goto invalid;
- ae = message[2];
- src_plen = message[3];
- plen = message[4];
- omitted = message[5];
+ ae = EXTRACT_U_1(message + 2);
+ src_plen = EXTRACT_U_1(message + 3);
+ plen = EXTRACT_U_1(message + 4);
+ omitted = EXTRACT_U_1(message + 5);
interval = EXTRACT_BE_U_2(message + 6);
seqno = EXTRACT_BE_U_2(message + 8);
metric = EXTRACT_BE_U_2(message + 10);
u_char ae, plen, src_plen, prefix[16], src_prefix[16];
ND_PRINT((ndo, "\n\tSS-Request "));
if(len < 3) goto invalid;
- ae = message[2];
- plen = message[3];
- src_plen = message[4];
+ ae = EXTRACT_U_1(message + 2);
+ plen = EXTRACT_U_1(message + 3);
+ src_plen = EXTRACT_U_1(message + 4);
rc = network_prefix(ae, plen, 0, message + 2 + parsed_len,
NULL, len - parsed_len, prefix);
if(rc < 0) goto invalid;
const u_char *router_id = NULL;
ND_PRINT((ndo, "\n\tSS-MH-Request "));
if(len < 14) goto invalid;
- ae = message[2];
- plen = message[3];
+ ae = EXTRACT_U_1(message + 2);
+ plen = EXTRACT_U_1(message + 3);
seqno = EXTRACT_BE_U_2(message + 4);
- hopc = message[6];
- src_plen = message[7];
+ hopc = EXTRACT_U_1(message + 6);
+ src_plen = EXTRACT_U_1(message + 7);
router_id = message + 8;
rc = network_prefix(ae, plen, 0, message + 2 + parsed_len,
NULL, len - parsed_len, prefix);
ND_TCHECK_1(pptr);
ITEMCHECK(1);
- plen = pptr[0];
+ plen = EXTRACT_U_1(pptr);
if (32 < plen)
return -1;
itemlen -= 1;
/* prefix length and label = 4 bytes */
ND_TCHECK_4(pptr);
ITEMCHECK(4);
- plen = pptr[0]; /* get prefix length */
+ plen = EXTRACT_U_1(pptr); /* get prefix length */
/* this is one of the weirdnesses of rfc3107
the label length (actually the label + COS bits)
/* NLRI "prefix length" from RFC 2858 Section 4. */
ND_TCHECK_1(pptr);
- plen = pptr[0]; /* get prefix length */
+ plen = EXTRACT_U_1(pptr); /* get prefix length */
/* NLRI "prefix" (ibid), valid lengths are { 0, 32, 33, ..., 96 } bits.
* RFC 4684 Section 4 defines the layout of "origin AS" and "route
u_int plen;
ND_TCHECK_1(pptr);
- plen = pptr[0]; /* get prefix length */
+ plen = EXTRACT_U_1(pptr); /* get prefix length */
if ((24+64) > plen)
return -1;
ND_TCHECK_1(pd);
ITEMCHECK(1);
- plen = pd[0];
+ plen = EXTRACT_U_1(pd);
if (128 < plen)
return -1;
itemlen -= 1;
/* prefix length and label = 4 bytes */
ND_TCHECK_4(pptr);
ITEMCHECK(4);
- plen = pptr[0]; /* get prefix length */
+ plen = EXTRACT_U_1(pptr); /* get prefix length */
if (24 > plen)
return -1;
u_int plen;
ND_TCHECK_1(pptr);
- plen = pptr[0]; /* get prefix length */
+ plen = EXTRACT_U_1(pptr); /* get prefix length */
if ((24+64) > plen)
return -1;
u_int plen;
ND_TCHECK_1(pptr);
- plen = pptr[0]; /* get prefix length */
+ plen = EXTRACT_U_1(pptr); /* get prefix length */
if (152 < plen)
return -1;
u_int plen;
ND_TCHECK_1(pptr);
- plen = pptr[0]; /* get prefix length */
+ plen = EXTRACT_U_1(pptr); /* get prefix length */
if ((24+64) > plen)
return -1;
tptr +=3;
ND_TCHECK_1(tptr);
- nhlen = tptr[0];
+ nhlen = EXTRACT_U_1(tptr);
tlen = nhlen;
tptr++;
tptr += tlen;
ND_TCHECK_1(tptr);
- snpa = tptr[0];
+ snpa = EXTRACT_U_1(tptr);
tptr++;
if (snpa) {
case BGPTYPE_MP_UNREACH_NLRI:
ND_TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE);
af = EXTRACT_BE_U_2(tptr);
- safi = tptr[2];
+ safi = EXTRACT_U_1(tptr + 2);
ND_PRINT((ndo, "\n\t AFI: %s (%u), %sSAFI: %s (%u)",
tok2str(af_values, "Unknown AFI", af),
while (i < caps_len) {
ND_TCHECK2(opt[i], BGP_CAP_HEADER_SIZE);
- cap_type=opt[i];
- cap_len=opt[i+1];
+ cap_type=EXTRACT_U_1(opt + i);
+ cap_len=EXTRACT_U_1(opt + i + 1);
tcap_len=cap_len;
ND_PRINT((ndo, "\n\t %s (%u), length: %u",
tok2str(bgp_capcode_values, "Unknown",
ND_TCHECK_2(bp);
if (length < 2)
goto trunc;
- srcNwref = bp[0];
- dstNwref = bp[1];
+ srcNwref = EXTRACT_U_1(bp);
+ dstNwref = EXTRACT_U_1(bp + 1);
length -= 2;
bp += 2;
ND_TCHECK_2(p);
if (p + 2 > endp)
goto trunc;
- pt = p[0]; /* type of "protocol" field */
- pl = p[1]; /* length of "protocol" field */
+ pt = EXTRACT_U_1(p); /* type of "protocol" field */
+ pl = EXTRACT_U_1(p + 1); /* length of "protocol" field */
p += 2;
ND_TCHECK_2(p + pl);
while (tlen>sizeof(struct ie_tlv_header_t)) {
ND_TCHECK2(*tptr, sizeof(struct ie_tlv_header_t));
- ie_type=tptr[0];
- ie_len=tptr[1];
+ ie_type=EXTRACT_U_1(tptr);
+ ie_len=EXTRACT_U_1(tptr + 1);
ND_PRINT((ndo, "\n\tIE %s (%u), length %u: ",
tok2str(mfr_ctrl_ie_values,"Unknown",ie_type),
const char *msg_type_str;
/* Assuming ItsDpuHeader */
- version = bp[0];
- msg_type = bp[1];
+ version = EXTRACT_U_1(bp);
+ msg_type = EXTRACT_U_1(bp + 1);
msg_type_str = tok2str(msg_type_values, "unknown (%u)", msg_type);
ND_PRINT((ndo, "; ItsPduHeader v:%d t:%d-%s", version, msg_type, msg_type_str));
hdr_type = bp[1] >> 4;
hdr_subtype = bp[1] & 0x0f;
payload_length = EXTRACT_BE_U_2(bp + 4);
- hop_limit = bp[7];
+ hop_limit = EXTRACT_U_1(bp + 7);
switch (next_hdr) {
case 0: next_hdr_txt = "Any"; break;
{
u_int length = 0;
while (length < max_length) {
- u_int lab_length = cp[length++];
+ u_int lab_length = EXTRACT_U_1(cp + length);
+ length++;
if (lab_length == 0)
return (int)length;
if (length > 1 && print)
if (i + 2 > length)
return -1;
tlv = cp + i;
- type = tlv[0];
- optlen = tlv[1];
+ type = EXTRACT_U_1(tlv);
+ optlen = EXTRACT_U_1(tlv + 1);
value = tlv + 2;
ND_PRINT((ndo, "\n"));
ND_PRINT((ndo, " %s", istr));
break;
}
- policy = value[0];
+ policy = EXTRACT_U_1(value);
ND_PRINT((ndo, " type: "));
if (policy == 0) {
if (bodylen != 1) {
ND_PRINT((ndo, " %s", istr));
break;
}
- l = value[16];
+ l = EXTRACT_U_1(value + 16);
if (bodylen < 17 + l) {
ND_PRINT((ndo, " %s", istr));
break;
ND_PRINT((ndo," robustness=%d", EXTRACT_U_1(bp + 24) & 0x07));
}
if (EXTRACT_U_1(bp + 25) < 128) {
- qqi = bp[25];
+ qqi = EXTRACT_U_1(bp + 25);
} else {
qqi = ((bp[25] & 0x0f) | 0x10) << (((bp[25] & 0x70) >> 4) + 3);
}
len = 1;
else {
ND_TCHECK_1(cp + 1);
- len = cp[1];
+ len = EXTRACT_U_1(cp + 1);
if (len < 2)
break;
}
else {
ND_TCHECK_1(cp + 1);
- option_len = cp[1];
+ option_len = EXTRACT_U_1(cp + 1);
if (option_len < 2) {
ND_PRINT((ndo, " [bad length %u]", option_len));
return;
ND_PRINT((ndo,"type=#%d ", t));
if (EXTRACT_U_1(p) & 0x80) {
ND_PRINT((ndo,"value="));
- t = p[2];
+ t = EXTRACT_U_1(p + 2);
if (!rawprint(ndo, (const uint8_t *)(p + 2), 2)) {
ND_PRINT((ndo,")"));
goto trunc;
l2info->length = h->len;
l2info->caplen = h->caplen;
ND_TCHECK_4(p);
- l2info->flags = p[3];
+ l2info->flags = EXTRACT_U_1(p + 3);
l2info->direction = p[3]&JUNIPER_BPF_PKT_IN;
if (EXTRACT_BE_U_3(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */
if (ndo->ndo_eflag)
ND_PRINT((ndo, ", cookie 0x"));
for (idx = 0; idx < l2info->cookie_len; idx++) {
- l2info->cookie[idx] = p[idx]; /* copy cookie data */
+ l2info->cookie[idx] = EXTRACT_U_1(p + idx); /* copy cookie data */
if (ndo->ndo_eflag) ND_PRINT((ndo, "%02x", EXTRACT_U_1(p + idx)));
}
}
if (len < 4)
goto trunc;
ND_TCHECK_4(bp);
- ngroups = bp[3];
+ ngroups = EXTRACT_U_1(bp + 3);
bp += 4;
len -= 4;
while (ngroups--) {
register u_char type;
ND_TCHECK_1(bp + 1);
- type = bp[1];
+ type = EXTRACT_U_1(bp + 1);
ND_PRINT((ndo, " %s", tok2str(pimv1_type_str, "[type %u]", type)));
switch (type) {
goto trunc;
ND_TCHECK_1(bp);
ND_PRINT((ndo, " auto-rp "));
- type = bp[0];
+ type = EXTRACT_U_1(bp);
switch (type) {
case 0x11:
ND_PRINT((ndo, "candidate-advert"));
}
ND_TCHECK_1(bp + 1);
- numrps = bp[1];
+ numrps = EXTRACT_U_1(bp + 1);
ND_TCHECK_2(bp + 2);
ND_PRINT((ndo, " Hold "));
if (len < 1)
goto trunc;
ND_TCHECK_1(bp);
- nentries = bp[0];
+ nentries = EXTRACT_U_1(bp);
bp += 1;
len -= 1;
s = ' ';
if (len < 4)
goto trunc;
ND_TCHECK_4(bp);
- ngroup = bp[1];
+ ngroup = EXTRACT_U_1(bp + 1);
holdtime = EXTRACT_BE_U_2(bp + 2);
ND_PRINT((ndo, "\n\t %u group(s)", ngroup));
if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
goto trunc;
ND_TCHECK_1(bp);
ND_PRINT((ndo, " prefix-cnt=%d", EXTRACT_U_1(bp)));
- pfxcnt = bp[0];
+ pfxcnt = EXTRACT_U_1(bp);
if (len < 2)
goto trunc;
ND_TCHECK_1(bp + 1);
ND_TCHECK2(*pppoe_packet, PPPOE_HDRLEN);
pppoe_ver = (pppoe_packet[0] & 0xF0) >> 4;
pppoe_type = (pppoe_packet[0] & 0x0F);
- pppoe_code = pppoe_packet[1];
+ pppoe_code = EXTRACT_U_1(pppoe_packet + 1);
pppoe_sessionid = EXTRACT_BE_U_2(pppoe_packet + 2);
pppoe_length = EXTRACT_BE_U_2(pppoe_packet + 4);
pppoe_payload = pppoe_packet + PPPOE_HDRLEN;
int dir;
u_int hlen;
- dir = p[SLX_DIR];
+ dir = EXTRACT_U_1(p + SLX_DIR);
switch (dir) {
case SLIPDIR_IN:
int command;
ND_TCHECK_1(data);
- command = data[0];
+ command = EXTRACT_U_1(data);
smb_fdata(ndo, param, "BROWSE PACKET\n|Param ", param+paramlen, unicodestr);
const char *f1 = NULL, *f2 = NULL;
ND_TCHECK_1(words);
- wct = words[0];
+ wct = EXTRACT_U_1(words);
if (request)
f2 = "*|Dialect=[Y]\n";
else {
const char *f1 = NULL, *f2 = NULL;
ND_TCHECK_1(words);
- wct = words[0];
+ wct = EXTRACT_U_1(words);
if (request) {
if (wct == 10)
f1 = "Com2=[w]\nOff2=[d]\nBufSize=[d]\nMpxMax=[d]\nVcNum=[d]\nSessionKey=[W]\nPassLen=[d]\nCryptLen=[d]\nCryptOff=[d]\nPass&Name=\n";
const char *f1 = NULL, *f2 = NULL;
ND_TCHECK_1(words);
- wct = words[0];
+ wct = EXTRACT_U_1(words);
if (request) {
f1 = "Com2=[w]\nOff2=[d]\nHandle=[d]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[d]\nLockCount=[d]\n";
ND_TCHECK_1(words + 7);
request = (buf[9] & 0x80) ? 0 : 1;
startbuf = buf;
- command = buf[4];
+ command = EXTRACT_U_1(buf + 4);
fn = smbfind(command, smb_fns);
words = buf + smboffset;
ND_TCHECK_1(words);
- wct = words[0];
+ wct = EXTRACT_U_1(words);
data = words + 1 + wct * 2;
maxwords = min(data, maxbuf);
if (wct == 0)
break;
ND_TCHECK_1(words + 1);
- command = words[1];
+ command = EXTRACT_U_1(words + 1);
if (command == 0xFF)
break;
ND_TCHECK_2(words + 3);
if (caplen < 4)
goto trunc;
maxbuf = data + caplen;
- type = data[0];
+ type = EXTRACT_U_1(data);
nbt_len = EXTRACT_BE_U_2(data + 2);
length -= 4;
caplen -= 4;
goto trunc;
if (caplen < 4)
goto trunc;
- ecode = data[4];
+ ecode = EXTRACT_U_1(data + 4);
ND_PRINT((ndo, "Session Reject, "));
switch (ecode) {
if (data == NULL)
break;
if (nbt_len >= 1 && caplen >= 1) {
- ecode = origdata[4];
+ ecode = EXTRACT_U_1(origdata + 4);
switch (ecode) {
case 0x80:
ND_PRINT((ndo, "Not listening on called name\n"));
int numnames;
ND_TCHECK_1(p);
- numnames = p[0];
+ numnames = EXTRACT_U_1(p);
p = smb_fdata(ndo, p, "NumNames=[B]\n", p + 1, 0);
if (p == NULL)
goto out;
maxbuf = ndo->ndo_snapend;
ND_TCHECK_1(data + 4);
len = EXTRACT_LE_U_2(data);
- command = data[4];
+ command = EXTRACT_U_1(data + 4);
data2 = data + len;
if (data2 >= maxbuf) {
data2 = maxbuf;
ND_PRINT((ndo, "[msgFlags size %d]", elem.asnlen));
return;
}
- flags = elem.data.str[0];
+ flags = EXTRACT_U_1(elem.data.str);
if (flags != 0x00 && flags != 0x01 && flags != 0x03
&& flags != 0x04 && flags != 0x05 && flags != 0x07) {
ND_PRINT((ndo, "[msgFlags=0x%02X]", flags));
}
vci = EXTRACT_BE_U_2(p + VCI_POS);
- vpi = p[VPI_POS];
+ vpi = EXTRACT_U_1(p + VPI_POS);
p += PKT_BEGIN_POS;
caplen -= PKT_BEGIN_POS;
ND_TCHECK_1(bp + 5);
if (version == 2) {
- auth_type = bp[4];
+ auth_type = EXTRACT_U_1(bp + 4);
ND_PRINT((ndo, ", authtype %s", tok2str(auth2str, NULL, auth_type)));
ND_PRINT((ndo, ", intvl %us, length %u", EXTRACT_U_1(bp + 5), len));
} else { /* version == 3 */
}
if (ndo->ndo_vflag) {
- int naddrs = bp[3];
+ int naddrs = EXTRACT_U_1(bp + 3);
int i;
char c;
if (EXTRACT_U_1(cp) != 0xFF) {
header_len = 1; /* length */
- body_len_declared = cp[0];
+ body_len_declared = EXTRACT_U_1(cp);
ND_PRINT((ndo, " frame flags+body (8-bit) length %" PRIu64, body_len_declared));
} else {
header_len = 1 + 8; /* 0xFF, length */
if (body_len_declared == 0)
return cp + header_len; /* skip to the next frame */
ND_TCHECK2(*cp, header_len + 1); /* ..., flags */
- flags = cp[header_len];
+ flags = EXTRACT_U_1(cp + header_len);
body_len_captured = ep - cp - header_len;
if (body_len_declared > body_len_captured)
if (l >= MAX_UNISTR_SIZE)
break;
if (ND_ISPRINT(EXTRACT_U_1(s)))
- buf[l] = s[0];
+ buf[l] = EXTRACT_U_1(s);
else {
if (EXTRACT_U_1(s) == 0)
break;
break;
if (EXTRACT_U_1(s + 1) == 0 && ND_ISPRINT(EXTRACT_U_1(s))) {
/* It's a printable ASCII character */
- buf[l] = s[0];
+ buf[l] = EXTRACT_U_1(s);
} else {
/* It's a non-ASCII character or a non-printable ASCII character */
if (EXTRACT_U_1(s) == 0 && EXTRACT_U_1(s + 1) == 0)
{
unsigned int x;
ND_TCHECK_1(buf);
- x = buf[0];
+ x = EXTRACT_U_1(buf);
ND_PRINT((ndo, "%u (0x%x)", x, x));
buf += 1;
fmt++;
{
unsigned int x;
ND_TCHECK_1(buf);
- x = buf[0];
+ x = EXTRACT_U_1(buf);
ND_PRINT((ndo, "0x%X", x));
buf += 1;
fmt++;
case 'b':
ND_TCHECK_1(buf);
- stringlen = buf[0];
+ stringlen = EXTRACT_U_1(buf);
ND_PRINT((ndo, "%u", stringlen));
buf += 1;
break;
break;
case 2:
ND_TCHECK_1(buf + 15);
- name_type = buf[15];
+ name_type = EXTRACT_U_1(buf + 15);
ND_PRINT((ndo, "%-15.15s NameType=0x%02X (%s)", buf, name_type,
name_type_str(name_type)));
buf += 16;