total_length = 0;
/* Source address length, encoded in bits */
- ND_TCHECK2(pptr[0], 1);
- addr_length = *pptr++;
+ ND_TCHECK_8BITS(pptr);
+ addr_length = EXTRACT_8BITS(pptr);
+ pptr++;
/* Source address */
ND_TCHECK2(pptr[0], (addr_length >> 3));
}
/* Group address length, encoded in bits */
- ND_TCHECK2(pptr[0], 1);
- addr_length = *pptr++;
+ ND_TCHECK_8BITS(pptr);
+ addr_length = EXTRACT_8BITS(pptr);
+ pptr++;
/* Group address */
ND_TCHECK2(pptr[0], (addr_length >> 3));
ND_TCHECK(pptr[0]);
/* if the NLRI is not predefined length, quit.*/
- if (*pptr != MDT_VPN_NLRI_LEN * 8)
+ if (EXTRACT_8BITS(pptr) != MDT_VPN_NLRI_LEN * 8)
return -1;
pptr++;
u_int offset;
ND_TCHECK2(pptr[0], 2);
- route_type = *pptr++;
- route_length = *pptr++;
+ route_type = EXTRACT_8BITS(pptr);
+ pptr++;
+ route_length = EXTRACT_8BITS(pptr);
+ pptr++;
snprintf(buf, buflen, "Route-Type: %s (%u), length: %u",
tok2str(bgp_multicast_vpn_route_type_values,
{
int plen,tlen,stringlen,tlv_type,tlv_len,ttlv_len;
- ND_TCHECK2(pptr[0], 2);
+ ND_TCHECK_16BITS(pptr);
plen=EXTRACT_BE_16BITS(pptr);
tlen=plen;
pptr+=2;
if (tlen < 3)
return -1;
ND_TCHECK2(pptr[0], 3);
- tlv_type=*pptr++;
+ tlv_type=EXTRACT_8BITS(pptr);
+ pptr++;
tlv_len=EXTRACT_BE_16BITS(pptr);
ttlv_len=tlv_len;
pptr+=2;
while (ttlv_len>0) {
ND_TCHECK(pptr[0]);
if (buflen!=0) {
- stringlen=snprintf(buf,buflen, "%02x",*pptr++);
+ stringlen=snprintf(buf,buflen, "%02x",EXTRACT_8BITS(pptr));
+ pptr++;
UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
}
ttlv_len--;
if (len != 4)
ND_PRINT((ndo, "invalid len"));
else {
- ND_TCHECK2(tptr[0], 4);
+ ND_TCHECK_32BITS(tptr);
ND_PRINT((ndo, "%u", EXTRACT_BE_32BITS(tptr)));
}
break;
}
while (tlen>0) {
uint32_t comm;
- ND_TCHECK2(tptr[0], 4);
+ ND_TCHECK_32BITS(tptr);
comm = EXTRACT_BE_32BITS(tptr);
switch (comm) {
case BGP_COMMUNITY_NO_EXPORT:
case BGPTYPE_MP_REACH_NLRI:
ND_TCHECK2(tptr[0], 3);
af = EXTRACT_BE_16BITS(tptr);
- safi = tptr[2];
+ safi = EXTRACT_8BITS(tptr + 2);
ND_PRINT((ndo, "\n\t AFI: %s (%u), %sSAFI: %s (%u)",
tok2str(af_values, "Unknown AFI", af),
while (tlen>0) {
uint16_t extd_comm;
- ND_TCHECK2(tptr[0], 2);
+ ND_TCHECK_16BITS(tptr);
extd_comm=EXTRACT_BE_16BITS(tptr);
ND_PRINT((ndo, "\n\t %s (0x%04x), Flags [%s]",
uint8_t tunnel_type, flags;
ND_TCHECK2(tptr[0], 5);
- tunnel_type = *(tptr+1);
- flags = *tptr;
+ flags = EXTRACT_8BITS(tptr);
+ tunnel_type = EXTRACT_8BITS(tptr+1);
tlen = len;
ND_PRINT((ndo, "\n\t Tunnel-type %s (%u), Flags [%s], MPLS Label %u",
ND_TCHECK2(tptr[0], 3);
- type = *tptr;
+ type = EXTRACT_8BITS(tptr);
length = EXTRACT_BE_16BITS(tptr + 1);
tptr += 3;
tlen -= 3;
break;
}
case BGPTYPE_ATTR_SET:
- ND_TCHECK2(tptr[0], 4);
+ ND_TCHECK_32BITS(tptr);
if (len < 4)
goto trunc;
ND_PRINT((ndo, "\n\t Origin AS: %s",
ND_TCHECK2(tptr[0], 2);
if (len < 2)
goto trunc;
- aflags = *tptr;
- atype = *(tptr + 1);
+ aflags = EXTRACT_8BITS(tptr);
+ atype = EXTRACT_8BITS(tptr + 1);
tptr += 2;
len -= 2;
alenlen = bgp_attr_lenlen(aflags, tptr);
length -= BGP_SIZE;
/* Unfeasible routes */
- ND_TCHECK2(p[0], 2);
+ ND_TCHECK_16BITS(p);
if (length < 2)
goto trunc;
withdrawn_routes_len = EXTRACT_BE_16BITS(p);
length -= withdrawn_routes_len;
}
- ND_TCHECK2(p[0], 2);
+ ND_TCHECK_16BITS(p);
if (length < 2)
goto trunc;
len = EXTRACT_BE_16BITS(p);
goto trunc;
if (length < 2)
goto trunc;
- aflags = *p;
- atype = *(p + 1);
+ aflags = EXTRACT_8BITS(p);
+ atype = EXTRACT_8BITS(p + 1);
p += 2;
len -= 2;
length -= 2;
bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_RESET) &&
length >= BGP_NOTIFICATION_SIZE + 1) {
tptr = dat + BGP_NOTIFICATION_SIZE;
- ND_TCHECK2(*tptr, 1);
- shutdown_comm_length = *(tptr);
+ ND_TCHECK_8BITS(tptr);
+ shutdown_comm_length = EXTRACT_8BITS(tptr);
remainder_offset = 0;
/* garbage, hexdump it all */
if (shutdown_comm_length > BGP_NOTIFY_MINOR_CEASE_ADMIN_SHUTDOWN_LEN ||
ND_PRINT((ndo, "\n\t Client-Ethernet-Address %s", etheraddr_string(ndo, bp->bp_chaddr)));
}
- ND_TCHECK2(bp->bp_sname[0], 1); /* check first char only */
- if (*bp->bp_sname) {
+ ND_TCHECK_8BITS(bp->bp_sname); /* check first char only */
+ if (EXTRACT_8BITS(bp->bp_sname)) {
ND_PRINT((ndo, "\n\t sname \""));
if (fn_printztn(ndo, bp->bp_sname, (u_int)sizeof bp->bp_sname,
ndo->ndo_snapend)) {
}
ND_PRINT((ndo, "\""));
}
- ND_TCHECK2(bp->bp_file[0], 1); /* check first char only */
- if (*bp->bp_file) {
+ ND_TCHECK_8BITS(bp->bp_file); /* check first char only */
+ if (EXTRACT_8BITS(bp->bp_file)) {
ND_PRINT((ndo, "\n\t file \""));
if (fn_printztn(ndo, bp->bp_file, (u_int)sizeof bp->bp_file,
ndo->ndo_snapend)) {
bp += sizeof(int32_t);
/* Loop while we there is a tag left in the buffer */
- while (ND_TTEST2(*bp, 1)) {
- tag = *bp++;
+ while (ND_TTEST_8BITS(bp)) {
+ tag = EXTRACT_8BITS(bp);
+ bp++;
if (tag == TAG_PAD && ndo->ndo_vflag < 3)
continue;
if (tag == TAG_END && ndo->ndo_vflag < 3)
return;
if (tag == TAG_EXTENDED_OPTION) {
- ND_TCHECK2(*(bp + 1), 2);
+ ND_TCHECK_16BITS(bp + 1);
tag = EXTRACT_BE_16BITS(bp + 1);
/* XXX we don't know yet if the IANA will
* preclude overlap of 1-byte and 2-byte spaces.
len = 0;
else {
/* Get the length; check for truncation */
- ND_TCHECK2(*bp, 1);
- len = *bp++;
+ ND_TCHECK_8BITS(bp);
+ len = EXTRACT_8BITS(bp);
+ bp++;
}
ND_PRINT((ndo, "\n\t %s Option %u, length %u%s", cp, tag, len,
if (tag == TAG_PAD && ndo->ndo_vflag > 2) {
u_int ntag = 1;
- while (ND_TTEST2(*bp, 1) && *bp == TAG_PAD) {
+ while (ND_TTEST_8BITS(bp) &&
+ EXTRACT_8BITS(bp) == TAG_PAD) {
bp++;
ntag++;
}
}
if (tag == TAG_DHCP_MESSAGE && len == 1) {
- uc = *bp++;
+ uc = EXTRACT_8BITS(bp);
+ bp++;
ND_PRINT((ndo, "%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc)));
continue;
}
if (tag == TAG_PARM_REQUEST) {
idx = 0;
while (len-- > 0) {
- uc = *bp++;
+ uc = EXTRACT_8BITS(bp);
+ bp++;
cp = tok2str(tag2str, "?Option %u", uc);
if (idx % 4 == 0)
ND_PRINT((ndo, "\n\t "));
case 'B':
/* boolean */
while (len > 0) {
+ uint8_t bool_value;
if (!first)
ND_PRINT((ndo, ","));
- switch (*bp) {
+ bool_value = EXTRACT_8BITS(bp);
+ switch (bool_value) {
case 0:
ND_PRINT((ndo, "N"));
break;
ND_PRINT((ndo, "Y"));
break;
default:
- ND_PRINT((ndo, "%u?", *bp));
+ ND_PRINT((ndo, "%u?", bool_value));
break;
}
++bp;
default:
/* Bytes */
while (len > 0) {
+ uint8_t byte_value;
if (!first)
ND_PRINT((ndo, c == 'x' ? ":" : "."));
+ byte_value = EXTRACT_8BITS(bp);
if (c == 'x')
- ND_PRINT((ndo, "%02x", *bp));
+ ND_PRINT((ndo, "%02x", byte_value));
else
- ND_PRINT((ndo, "%u", *bp));
+ ND_PRINT((ndo, "%u", byte_value));
++bp;
--len;
first = 0;
ND_PRINT((ndo, "ERROR: length < 1 bytes"));
break;
}
- tag = *bp++;
+ tag = EXTRACT_8BITS(bp);
+ ++bp;
--len;
ND_PRINT((ndo, "%s", tok2str(nbo2str, NULL, tag)));
break;
ND_PRINT((ndo, "ERROR: length < 1 bytes"));
break;
}
- tag = *bp++;
+ tag = EXTRACT_8BITS(bp);
+ ++bp;
--len;
ND_PRINT((ndo, "%s", tok2str(oo2str, NULL, tag)));
break;
len = 0;
break;
}
- if (*bp)
+ if (EXTRACT_8BITS(bp))
ND_PRINT((ndo, "[%s] ", client_fqdn_flags(EXTRACT_8BITS(bp))));
bp++;
- if (*bp || *(bp+1))
- ND_PRINT((ndo, "%u/%u ", *bp, *(bp+1)));
+ if (EXTRACT_8BITS(bp) || EXTRACT_8BITS(bp+1))
+ ND_PRINT((ndo, "%u/%u ", EXTRACT_8BITS(bp), EXTRACT_8BITS(bp+1)));
bp += 2;
ND_PRINT((ndo, "\""));
if (fn_printn(ndo, bp, len - 3, ndo->ndo_snapend)) {
ND_PRINT((ndo, "ERROR: length < 1 bytes"));
break;
}
- type = *bp++;
+ type = EXTRACT_8BITS(bp);
+ bp++;
len--;
if (type == 0) {
ND_PRINT((ndo, "\""));
while (len > 0) {
if (!first)
ND_PRINT((ndo, ":"));
- ND_PRINT((ndo, "%02x", *bp));
+ ND_PRINT((ndo, "%02x", EXTRACT_8BITS(bp)));
++bp;
--len;
first = 0;
case TAG_AGENT_CIRCUIT:
while (len >= 2) {
- subopt = *bp++;
- suboptlen = *bp++;
+ subopt = EXTRACT_8BITS(bp);
+ suboptlen = EXTRACT_8BITS(bp+1);
+ bp += 2;
len -= 2;
if (suboptlen > len) {
ND_PRINT((ndo, "\n\t %s SubOption %u, length %u: length goes past end of option",
while (len > 0) {
if (!first)
ND_PRINT((ndo, ","));
- mask_width = *bp++;
+ mask_width = EXTRACT_8BITS(bp);
+ bp++;
len--;
/* mask_width <= 32 */
if (mask_width > 32) {
for (i = 0; i < significant_octets ; i++) {
if (i > 0)
ND_PRINT((ndo, "."));
- ND_PRINT((ndo, "%d", *bp++));
+ ND_PRINT((ndo, "%d", EXTRACT_8BITS(bp)));
+ bp++;
}
for (i = significant_octets ; i < 4 ; i++)
ND_PRINT((ndo, ".0"));
break;
}
while (len > 0) {
- suboptlen = *bp++;
+ suboptlen = EXTRACT_8BITS(bp);
+ bp++;
len--;
ND_PRINT((ndo, "\n\t "));
ND_PRINT((ndo, "instance#%u: ", suboptnumber));
return hexdump;
}
/* The calling function must make any due ND_TCHECK calls. */
- network_addr_type = *tptr;
+ network_addr_type = EXTRACT_8BITS(tptr);
ND_PRINT((ndo, "\n\t Network Address Type %s (%u)",
tok2str(af_values, "Unknown", network_addr_type),
network_addr_type));
}
ND_PRINT((ndo, ", Status: %s (%u)",
tok2str(cfm_tlv_port_status_values, "Unknown", EXTRACT_8BITS(tptr)),
- *tptr));
+ EXTRACT_8BITS(tptr)));
break;
case CFM_TLV_INTERFACE_STATUS:
}
ND_PRINT((ndo, ", Status: %s (%u)",
tok2str(cfm_tlv_interface_status_values, "Unknown", EXTRACT_8BITS(tptr)),
- *tptr));
+ EXTRACT_8BITS(tptr)));
break;
case CFM_TLV_PRIVATE:
* Get the Chassis ID length and check it.
* IEEE 802.1Q-2014 Section 21.5.3.1
*/
- chassis_id_length = *tptr;
+ chassis_id_length = EXTRACT_8BITS(tptr);
tptr++;
tlen--;
cfm_tlv_len--;
ND_PRINT((ndo, "\n\t (TLV too short)"));
goto next_tlv;
}
- chassis_id_type = *tptr;
+ chassis_id_type = EXTRACT_8BITS(tptr);
cfm_tlv_len--;
ND_PRINT((ndo, "\n\t Chassis-ID Type %s (%u), Chassis-ID length %u",
tok2str(cfm_tlv_senderid_chassisid_values,
}
/* Here mgmt_addr_length stands for the management domain length. */
- mgmt_addr_length = *tptr;
+ mgmt_addr_length = EXTRACT_8BITS(tptr);
tptr++;
tlen--;
cfm_tlv_len--;
}
/* Here mgmt_addr_length stands for the management address length. */
- mgmt_addr_length = *tptr;
+ mgmt_addr_length = EXTRACT_8BITS(tptr);
tptr++;
tlen--;
cfm_tlv_len--;
uint16_t opttype;
size_t optlen;
uint8_t auth_proto;
+ uint8_t auth_alg;
+ uint8_t auth_rdm;
u_int authinfolen, authrealmlen;
int remain_len; /* Length of remaining options */
int label_len; /* Label length */
uint16_t subopt_code;
uint16_t subopt_len;
+ uint8_t dh6_reconf_type;
+ uint8_t dh6_lq_query_type;
if (cp == ep)
return;
break;
}
tp = (const u_char *)(dh6o + 1);
- ND_PRINT((ndo, " %d)", *tp));
+ ND_PRINT((ndo, " %d)", EXTRACT_8BITS(tp)));
break;
case DH6OPT_ELAPSED_TIME:
if (optlen != 2) {
break;
}
tp = (const u_char *)(dh6o + 1);
- auth_proto = *tp;
+ auth_proto = EXTRACT_8BITS(tp);
switch (auth_proto) {
case DH6OPT_AUTHPROTO_DELAYED:
ND_PRINT((ndo, " proto: delayed"));
break;
}
tp++;
- switch (*tp) {
+ auth_alg = EXTRACT_8BITS(tp);
+ switch (auth_alg) {
case DH6OPT_AUTHALG_HMACMD5:
/* XXX: may depend on the protocol */
ND_PRINT((ndo, ", alg: HMAC-MD5"));
break;
default:
- ND_PRINT((ndo, ", alg: %d", *tp));
+ ND_PRINT((ndo, ", alg: %d", auth_alg));
break;
}
tp++;
- switch (*tp) {
+ auth_rdm = EXTRACT_8BITS(tp);
+ switch (auth_rdm) {
case DH6OPT_AUTHRDM_MONOCOUNTER:
ND_PRINT((ndo, ", RDM: mono"));
break;
default:
- ND_PRINT((ndo, ", RDM: %d", *tp));
+ ND_PRINT((ndo, ", RDM: %d", auth_rdm));
break;
}
tp++;
ND_PRINT((ndo, ", realm: "));
}
for (i = 0; i < authrealmlen; i++, tp++)
- ND_PRINT((ndo, "%02x", *tp));
+ ND_PRINT((ndo, "%02x", EXTRACT_8BITS(tp)));
ND_PRINT((ndo, ", key ID: %08x", EXTRACT_BE_32BITS(tp)));
tp += 4;
ND_PRINT((ndo, ", HMAC-MD5:"));
ND_PRINT((ndo, " ??"));
break;
}
- switch (*tp++) {
+ switch (EXTRACT_8BITS(tp)) {
case DH6OPT_AUTHRECONFIG_KEY:
ND_PRINT((ndo, " reconfig-key"));
break;
ND_PRINT((ndo, " type: ??"));
break;
}
+ tp++;
ND_PRINT((ndo, " value:"));
for (i = 0; i < 4; i++, tp+= 4)
ND_PRINT((ndo, " %08x", EXTRACT_BE_32BITS(tp)));
break;
}
tp = (const u_char *)(dh6o + 1);
- switch (*tp) {
+ dh6_reconf_type = EXTRACT_8BITS(tp);
+ switch (dh6_reconf_type) {
case DH6_RENEW:
ND_PRINT((ndo, " for renew)"));
break;
ND_PRINT((ndo, " for inf-req)"));
break;
default:
- ND_PRINT((ndo, " for ?\?\?(%02x))", *tp));
+ ND_PRINT((ndo, " for ?\?\?(%02x))", dh6_reconf_type));
break;
}
break;
break;
}
tp = (const u_char *)(dh6o + 1);
- switch (*tp) {
+ dh6_lq_query_type = EXTRACT_8BITS(tp);
+ switch (dh6_lq_query_type) {
case 1:
ND_PRINT((ndo, " by-address"));
break;
ND_PRINT((ndo, " by-clientID"));
break;
default:
- ND_PRINT((ndo, " type_%d", (int)*tp));
+ ND_PRINT((ndo, " type_%d", (int)dh6_lq_query_type));
break;
}
ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[1])));
remain_len = optlen;
ND_PRINT((ndo, " "));
/* Encoding is described in section 3.1 of RFC 1035 */
- while (remain_len && *tp) {
- label_len = *tp++;
+ while (remain_len && EXTRACT_8BITS(tp)) {
+ label_len = EXTRACT_8BITS(tp);
+ tp++;
if (label_len < remain_len - 1) {
(void)fn_printn(ndo, tp, label_len, NULL);
tp += label_len;
remain_len -= (label_len + 1);
- if(*tp) ND_PRINT((ndo, "."));
+ if(EXTRACT_8BITS(tp)) ND_PRINT((ndo, "."));
} else {
ND_PRINT((ndo, " ?"));
break;
{
register u_char i;
- if (!ND_TTEST2(*cp, 1))
+ if (!ND_TTEST_8BITS(cp))
return (NULL);
- i = *cp++;
+ i = EXTRACT_8BITS(cp);
+ cp++;
while (i) {
if ((i & INDIR_MASK) == INDIR_MASK)
return (cp + 1);
if ((i & ~INDIR_MASK) != EDNS0_ELT_BITLABEL)
return(NULL); /* unknown ELT */
- if (!ND_TTEST2(*cp, 1))
+ if (!ND_TTEST_8BITS(cp))
return (NULL);
- if ((bitlen = *cp++) == 0)
+ if ((bitlen = EXTRACT_8BITS(cp)) == 0)
bitlen = 256;
+ cp++;
bytelen = (bitlen + 7) / 8;
cp += bytelen;
} else
cp += i;
- if (!ND_TTEST2(*cp, 1))
+ if (!ND_TTEST_8BITS(cp))
return (NULL);
- i = *cp++;
+ i = EXTRACT_8BITS(cp);
+ cp++;
}
return (cp);
}
const u_char *bitp, *lim;
char tc;
- if (!ND_TTEST2(*cp, 1))
+ if (!ND_TTEST_8BITS(cp))
return(NULL);
- if ((bitlen = *cp) == 0)
+ if ((bitlen = EXTRACT_8BITS(cp)) == 0)
bitlen = 256;
slen = (bitlen + 3) / 4;
lim = cp + 1 + slen;
}
if (b > 4) {
ND_TCHECK(*bitp);
- tc = *bitp++;
+ tc = EXTRACT_8BITS(bitp);
+ bitp++;
ND_PRINT((ndo, "%02x", tc & (0xff << (8 - b))));
} else if (b > 0) {
ND_TCHECK(*bitp);
- tc = *bitp++;
+ tc = EXTRACT_8BITS(bitp);
+ bitp++;
ND_PRINT((ndo, "%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b))));
}
ND_PRINT((ndo, "/%d]", bitlen));
{
register u_int i;
- if (!ND_TTEST2(*cp, 1))
+ if (!ND_TTEST_8BITS(cp))
return(-1);
- i = *cp;
+ i = EXTRACT_8BITS(cp);
if ((i & INDIR_MASK) == EDNS0_MASK) {
int bitlen, elt;
if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL) {
ND_PRINT((ndo, "<ELT %d>", elt));
return(-1);
}
- if (!ND_TTEST2(*(cp + 1), 1))
+ if (!ND_TTEST_8BITS(cp + 1))
return(-1);
- if ((bitlen = *(cp + 1)) == 0)
+ if ((bitlen = EXTRACT_8BITS(cp + 1)) == 0)
bitlen = 256;
return(((bitlen + 7) / 8) + 1);
} else
if ((l = labellen(ndo, cp)) == (u_int)-1)
return(NULL);
- if (!ND_TTEST2(*cp, 1))
+ if (!ND_TTEST_8BITS(cp))
return(NULL);
max_offset = (u_int)(cp - bp);
- if (((i = *cp++) & INDIR_MASK) != INDIR_MASK) {
+ i = EXTRACT_8BITS(cp);
+ cp++;
+ if ((i & INDIR_MASK) != INDIR_MASK) {
compress = 0;
rp = cp + l;
}
rp = cp + 1;
compress = 1;
}
- if (!ND_TTEST2(*cp, 1))
+ if (!ND_TTEST_8BITS(cp))
return(NULL);
- offset = (((i << 8) | *cp) & 0x3fff);
+ offset = (((i << 8) | EXTRACT_8BITS(cp)) & 0x3fff);
/*
* This must move backwards in the packet.
* No RFC explicitly says that, but BIND's
cp = bp + offset;
if ((l = labellen(ndo, cp)) == (u_int)-1)
return(NULL);
- if (!ND_TTEST2(*cp, 1))
+ if (!ND_TTEST_8BITS(cp))
return(NULL);
- i = *cp++;
+ i = EXTRACT_8BITS(cp);
+ cp++;
continue;
}
if ((i & INDIR_MASK) == EDNS0_MASK) {
ND_PRINT((ndo, "."));
if ((l = labellen(ndo, cp)) == (u_int)-1)
return(NULL);
- if (!ND_TTEST2(*cp, 1))
+ if (!ND_TTEST_8BITS(cp))
return(NULL);
- i = *cp++;
+ i = EXTRACT_8BITS(cp);
+ cp++;
if (!compress)
rp += l + 1;
}
{
register u_int i;
- if (!ND_TTEST2(*cp, 1))
+ if (!ND_TTEST_8BITS(cp))
return (NULL);
- i = *cp++;
+ i = EXTRACT_8BITS(cp);
+ cp++;
if (fn_printn(ndo, cp, i, ndo->ndo_snapend))
return (NULL);
return (cp + i);
int pbit, pbyte;
char ntop_buf[INET6_ADDRSTRLEN];
- if (!ND_TTEST2(*cp, 1))
+ if (!ND_TTEST_8BITS(cp))
return(NULL);
- pbit = *cp;
+ pbit = EXTRACT_8BITS(cp);
pbyte = (pbit & ~7) / 8;
if (pbit > 128) {
ND_PRINT((ndo, " %u(bad plen)", pbit));
if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
return(NULL);
cp += 6;
- if (!ND_TTEST2(*cp, 2))
+ if (!ND_TTEST_16BITS(cp))
return(NULL);
ND_PRINT((ndo, " fudge=%u", EXTRACT_BE_16BITS(cp)));
cp += 2;
- if (!ND_TTEST2(*cp, 2))
+ if (!ND_TTEST_16BITS(cp))
return(NULL);
ND_PRINT((ndo, " maclen=%u", EXTRACT_BE_16BITS(cp)));
cp += 2 + EXTRACT_BE_16BITS(cp);
- if (!ND_TTEST2(*cp, 2))
+ if (!ND_TTEST_16BITS(cp))
return(NULL);
ND_PRINT((ndo, " origid=%u", EXTRACT_BE_16BITS(cp)));
cp += 2;
- if (!ND_TTEST2(*cp, 2))
+ if (!ND_TTEST_16BITS(cp))
return(NULL);
ND_PRINT((ndo, " error=%u", EXTRACT_BE_16BITS(cp)));
cp += 2;
- if (!ND_TTEST2(*cp, 2))
+ if (!ND_TTEST_16BITS(cp))
return(NULL);
ND_PRINT((ndo, " otherlen=%u", EXTRACT_BE_16BITS(cp)));
cp += 2;
}
origin = 0;
for (i = 0; i < width; ++i) {
- ND_TCHECK(*bp);
- origin = origin << 8 | *bp++;
+ ND_TCHECK_8BITS(bp);
+ origin = origin << 8 | EXTRACT_8BITS(bp);
+ bp++;
}
for ( ; i < 4; ++i)
origin <<= 8;
- ND_TCHECK(*bp);
- metric = *bp++;
+ ND_TCHECK_8BITS(bp);
+ metric = EXTRACT_8BITS(bp);
+ bp++;
done = metric & 0x80;
metric &= 0x7f;
ND_PRINT((ndo, "\n\t %s metric %d", intoa(htonl(origin)),
ND_TCHECK2(bp[0], 7);
laddr = bp;
bp += 4;
- metric = *bp++;
- thresh = *bp++;
- ncount = *bp++;
+ metric = EXTRACT_8BITS(bp);
+ bp++;
+ thresh = EXTRACT_8BITS(bp);
+ bp++;
+ ncount = EXTRACT_8BITS(bp);
+ bp++;
len -= 7;
while (--ncount >= 0) {
ND_TCHECK2(bp[0], 4);
ND_TCHECK2(bp[0], 8);
laddr = bp;
bp += 4;
- metric = *bp++;
- thresh = *bp++;
- flags = *bp++;
- ncount = *bp++;
+ metric = EXTRACT_8BITS(bp);
+ bp++;
+ thresh = EXTRACT_8BITS(bp);
+ bp++;
+ flags = EXTRACT_8BITS(bp);
+ bp++;
+ ncount = EXTRACT_8BITS(bp);
+ bp++;
len -= 8;
while (--ncount >= 0 && (len >= 4) && (bp + 4) <= ep) {
ND_PRINT((ndo, " [%s -> ", ipaddr_string(ndo, laddr)));
const u_char *p, u_int *dlci,
u_int *addr_len, uint8_t *flags, u_int length)
{
- if (!ND_TTEST(p[0]) || length < 1)
+ if (!ND_TTEST_8BITS(p) || length < 1)
return -1;
- if ((p[0] & FR_EA_BIT))
+ if ((EXTRACT_8BITS(p) & FR_EA_BIT))
return 0;
- if (!ND_TTEST(p[1]) || length < 2)
+ if (!ND_TTEST_8BITS(p+1) || length < 2)
return -1;
*addr_len = 2;
- *dlci = ((p[0] & 0xFC) << 2) | ((p[1] & 0xF0) >> 4);
+ *dlci = ((EXTRACT_8BITS(p) & 0xFC) << 2) | ((EXTRACT_8BITS(p+1) & 0xF0) >> 4);
- flags[0] = p[0] & 0x02; /* populate the first flag fields */
- flags[1] = p[1] & 0x0c;
+ flags[0] = EXTRACT_8BITS(p) & 0x02; /* populate the first flag fields */
+ flags[1] = EXTRACT_8BITS(p+1) & 0x0c;
flags[2] = 0; /* clear the rest of the flags */
flags[3] = 0;
- if (p[1] & FR_EA_BIT)
+ if (EXTRACT_8BITS(p+1) & FR_EA_BIT)
return 1; /* 2-byte Q.922 address */
p += 2;
length -= 2;
- if (!ND_TTEST(p[0]) || length < 1)
+ if (!ND_TTEST_8BITS(p) || length < 1)
return -1;
(*addr_len)++; /* 3- or 4-byte Q.922 address */
- if ((p[0] & FR_EA_BIT) == 0) {
- *dlci = (*dlci << 7) | (p[0] >> 1);
+ if ((EXTRACT_8BITS(p) & FR_EA_BIT) == 0) {
+ *dlci = (*dlci << 7) | (EXTRACT_8BITS(p) >> 1);
(*addr_len)++; /* 4-byte Q.922 address */
p++;
length--;
}
- if (!ND_TTEST(p[0]) || length < 1)
+ if (!ND_TTEST_8BITS(p) || length < 1)
return -1;
- if ((p[0] & FR_EA_BIT) == 0)
+ if ((EXTRACT_8BITS(p) & FR_EA_BIT) == 0)
return 0; /* more than 4 bytes of Q.922 address? */
- flags[3] = p[0] & 0x02;
+ flags[3] = EXTRACT_8BITS(p) & 0x02;
- *dlci = (*dlci << 6) | (p[0] >> 2);
+ *dlci = (*dlci << 6) | (EXTRACT_8BITS(p) >> 2);
return 1;
}
return 0;
}
- ND_TCHECK(p[addr_len]);
+ ND_TCHECK_8BITS(p + addr_len);
if (length < addr_len + 1)
goto trunc;
- if (p[addr_len] != LLC_UI && dlci != 0) {
+ if (EXTRACT_8BITS(p + addr_len) != LLC_UI && dlci != 0) {
/*
* Let's figure out if we have Cisco-style encapsulation,
* with an Ethernet type (Cisco HDLC type?) following the
* address.
*/
- if (!ND_TTEST2(p[addr_len], 2) || length < addr_len + 2) {
+ if (!ND_TTEST_16BITS(p + addr_len) || length < addr_len + 2) {
/* no Ethertype */
- ND_PRINT((ndo, "UI %02x! ", p[addr_len]));
+ ND_PRINT((ndo, "UI %02x! ", EXTRACT_8BITS(p + addr_len)));
} else {
extracted_ethertype = EXTRACT_BE_16BITS(p + addr_len);
ndo->ndo_snapend-p-addr_len-ETHERTYPE_LEN,
NULL, NULL) == 0)
/* ether_type not known, probably it wasn't one */
- ND_PRINT((ndo, "UI %02x! ", p[addr_len]));
+ ND_PRINT((ndo, "UI %02x! ", EXTRACT_8BITS(p + addr_len)));
else
return addr_len + 2;
}
}
- ND_TCHECK(p[addr_len+1]);
+ ND_TCHECK_8BITS(p + addr_len + 1);
if (length < addr_len + 2)
goto trunc;
- if (p[addr_len + 1] == 0) {
+ if (EXTRACT_8BITS(p + addr_len + 1) == 0) {
/*
* Assume a pad byte after the control (UI) byte.
* A pad byte should only be used with 3-byte Q.922.
hdr_len = addr_len + 1 /* UI */ + 1 /* NLPID */;
}
- ND_TCHECK(p[hdr_len - 1]);
+ ND_TCHECK_8BITS(p + hdr_len - 1);
if (length < hdr_len)
goto trunc;
- nlpid = p[hdr_len - 1];
+ nlpid = EXTRACT_8BITS(p + hdr_len - 1);
if (ndo->ndo_eflag)
fr_hdr_print(ndo, length, addr_len, dlci, flags, nlpid);
ND_TCHECK2(*p, 4); /* minimum frame header length */
- if ((p[0] & MFR_BEC_MASK) == MFR_CTRL_FRAME && p[1] == 0) {
+ if ((EXTRACT_8BITS(p) & MFR_BEC_MASK) == MFR_CTRL_FRAME && EXTRACT_8BITS(p+1) == 0) {
ND_PRINT((ndo, "FRF.16 Control, Flags [%s], %s, length %u",
- bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)),
- tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",p[2]),
+ bittok2str(frf_flag_values,"none",(EXTRACT_8BITS(p) & MFR_BEC_MASK)),
+ tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",EXTRACT_8BITS(p+2)),
length));
tptr = p + 3;
tlen = length -3;
* +----+----+----+----+----+----+----+----+
*/
- sequence_num = (p[0]&0x1e)<<7 | p[1];
+ sequence_num = (EXTRACT_8BITS(p)&0x1e)<<7 | EXTRACT_8BITS(p+1);
/* whole packet or first fragment ? */
- if ((p[0] & MFR_BEC_MASK) == MFR_FRAG_FRAME ||
- (p[0] & MFR_BEC_MASK) == MFR_B_BIT) {
+ if ((EXTRACT_8BITS(p) & MFR_BEC_MASK) == MFR_FRAG_FRAME ||
+ (EXTRACT_8BITS(p) & MFR_BEC_MASK) == MFR_B_BIT) {
ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s], ",
sequence_num,
- bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))));
+ bittok2str(frf_flag_values,"none",(EXTRACT_8BITS(p) & MFR_BEC_MASK))));
hdr_len = 2;
fr_print(ndo, p+hdr_len,length-hdr_len);
return hdr_len;
/* must be a middle or the last fragment */
ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s]",
sequence_num,
- bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))));
+ bittok2str(frf_flag_values,"none",(EXTRACT_8BITS(p) & MFR_BEC_MASK))));
print_unknown_data(ndo, p, "\n\t", length);
return hdr_len;
goto trunc;
ND_TCHECK2(*p, 2);
- flags = p[0]&MFR_BEC_MASK;
- sequence_num = (p[0]&0x1e)<<7 | p[1];
+ flags = EXTRACT_8BITS(p)&MFR_BEC_MASK;
+ sequence_num = (EXTRACT_8BITS(p)&0x1e)<<7 | EXTRACT_8BITS(p+1);
ND_PRINT((ndo, "FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
sequence_num,
bittok2str(frf_flag_values,"none",flags),
- p[0]&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End",
+ EXTRACT_8BITS(p)&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End",
length));
/* TODO:
* Get the length of the call reference value.
*/
olen = length; /* preserve the original length for display */
- call_ref_length = (*p) & 0x0f;
+ call_ref_length = EXTRACT_8BITS(p) & 0x0f;
p++;
length--;
ND_PRINT((ndo, "length %u", olen));
goto trunc;
}
- call_ref[i] = *p;
+ call_ref[i] = EXTRACT_8BITS(p);
p++;
length--;
}
ND_PRINT((ndo, "length %u", olen));
goto trunc;
}
- msgtype = *p;
+ msgtype = EXTRACT_8BITS(p);
p++;
length--;
ND_PRINT((ndo, "length %u", olen));
goto trunc;
}
- iecode = *p;
+ iecode = EXTRACT_8BITS(p);
if (IE_IS_SHIFT(iecode)) {
/*
* It's a shift. Skip over it.
ND_PRINT((ndo, "%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset));
if (call_ref_length != 0) {
- ND_TCHECK(p[0]);
- if (call_ref_length > 1 || p[0] != 0) {
+ ND_TCHECK(EXTRACT_8BITS(p));
+ if (call_ref_length > 1 || EXTRACT_8BITS(p) != 0) {
/*
* Not a dummy call reference.
*/
}
goto trunc;
}
- iecode = *p;
+ iecode = EXTRACT_8BITS(p);
p++;
length--;
}
goto trunc;
}
- ielength = *p;
+ ielength = EXTRACT_8BITS(p);
p++;
length--;
}
if (ndo->ndo_vflag) {
ND_PRINT((ndo, "%s (%u)",
- tok2str(fr_lmi_report_type_ie_values,"unknown",p[0]),
- p[0]));
+ tok2str(fr_lmi_report_type_ie_values,"unknown",EXTRACT_8BITS(p)),
+ EXTRACT_8BITS(p)));
}
return 1;
ND_PRINT((ndo, "Invalid LINK VERIFY IE"));
return 1;
}
- ND_PRINT((ndo, "TX Seq: %3d, RX Seq: %3d", p[0], p[1]));
+ ND_PRINT((ndo, "TX Seq: %3d, RX Seq: %3d", EXTRACT_8BITS(p), EXTRACT_8BITS(p+1)));
return 1;
case FR_LMI_ANSI_PVC_STATUS_IE: /* fall through */
}
/* now parse the DLCI information element. */
if ((ielength < 3) ||
- (p[0] & 0x80) ||
- ((ielength == 3) && !(p[1] & 0x80)) ||
- ((ielength == 4) && ((p[1] & 0x80) || !(p[2] & 0x80))) ||
- ((ielength == 5) && ((p[1] & 0x80) || (p[2] & 0x80) ||
- !(p[3] & 0x80))) ||
+ (EXTRACT_8BITS(p) & 0x80) ||
+ ((ielength == 3) && !(EXTRACT_8BITS(p+1) & 0x80)) ||
+ ((ielength == 4) &&
+ ((EXTRACT_8BITS(p+1) & 0x80) || !(EXTRACT_8BITS(p+2) & 0x80))) ||
+ ((ielength == 5) &&
+ ((EXTRACT_8BITS(p+1) & 0x80) || (EXTRACT_8BITS(p+2) & 0x80) ||
+ !(EXTRACT_8BITS(p+3) & 0x80))) ||
(ielength > 5) ||
- !(p[ielength - 1] & 0x80)) {
+ !(EXTRACT_8BITS(p + ielength - 1) & 0x80)) {
ND_PRINT((ndo, "Invalid DLCI in PVC STATUS IE"));
return 1;
}
- dlci = ((p[0] & 0x3F) << 4) | ((p[1] & 0x78) >> 3);
+ dlci = ((EXTRACT_8BITS(p) & 0x3F) << 4) | ((EXTRACT_8BITS(p+1) & 0x78) >> 3);
if (ielength == 4) {
- dlci = (dlci << 6) | ((p[2] & 0x7E) >> 1);
+ dlci = (dlci << 6) | ((EXTRACT_8BITS(p+2) & 0x7E) >> 1);
}
else if (ielength == 5) {
- dlci = (dlci << 13) | (p[2] & 0x7F) | ((p[3] & 0x7E) >> 1);
+ dlci = (dlci << 13) | (EXTRACT_8BITS(p+2) & 0x7F) | ((EXTRACT_8BITS(p+3) & 0x7E) >> 1);
}
ND_PRINT((ndo, "DLCI %u: status %s%s", dlci,
- p[ielength - 1] & 0x8 ? "New, " : "",
- p[ielength - 1] & 0x2 ? "Active" : "Inactive"));
+ EXTRACT_8BITS(p + ielength - 1) & 0x8 ? "New, " : "",
+ EXTRACT_8BITS(p + ielength - 1) & 0x2 ? "Active" : "Inactive"));
return 1;
}
ND_TCHECK2(*bp, 8);
- ver_opt = *bp;
+ ver_opt = EXTRACT_8BITS(bp);
bp += 1;
len -= 1;
return;
}
- flags = *bp;
+ flags = EXTRACT_8BITS(bp);
bp += 1;
len -= 1;
bp += 3;
len -= 3;
- reserved = *bp;
+ reserved = EXTRACT_8BITS(bp);
bp += 1;
len -= 1;
if (li < sizeof(struct clnp_header_t)) {
ND_PRINT((ndo, " length indicator %u < min PDU size:", li));
- while (pptr < ndo->ndo_snapend)
- ND_PRINT((ndo, "%02X", *pptr++));
+ while (pptr < ndo->ndo_snapend) {
+ ND_PRINT((ndo, "%02X", EXTRACT_8BITS(pptr)));
+ pptr++;
+ }
return (0);
}
return (0);
}
ND_TCHECK(*pptr);
- dest_address_length = *pptr;
+ dest_address_length = EXTRACT_8BITS(pptr);
pptr += 1;
li -= 1;
if (li < dest_address_length) {
return (0);
}
ND_TCHECK(*pptr);
- source_address_length = *pptr;
+ source_address_length = EXTRACT_8BITS(pptr);
pptr += 1;
li -= 1;
if (li < source_address_length) {
return (0);
}
ND_TCHECK2(*pptr, 2);
- op = *pptr++;
- opli = *pptr++;
+ op = EXTRACT_8BITS(pptr);
+ opli = EXTRACT_8BITS(pptr + 1);
+ pptr += 2;
li -= 2;
if (opli > li) {
ND_PRINT((ndo, ", opt (%d) too long", op));
ND_PRINT((ndo, "%s %s",
tok2str(clnp_option_sr_rr_values,"Unknown",EXTRACT_8BITS(tptr)),
tok2str(clnp_option_sr_rr_string_values, "Unknown Option %u", op)));
- nsap_offset=*(tptr+1);
+ nsap_offset=EXTRACT_8BITS(tptr+1);
if (nsap_offset == 0) {
ND_PRINT((ndo, " Bad NSAP offset (0)"));
break;
tptr+=nsap_offset;
tlen-=nsap_offset;
while (tlen > 0) {
- source_address_length=*tptr;
+ source_address_length=EXTRACT_8BITS(tptr);
if (tlen < source_address_length+1) {
ND_PRINT((ndo, "\n\t NSAP address goes past end of option"));
break;
ND_PRINT((ndo, ", bad opt len"));
return (0);
}
- ND_PRINT((ndo, "0x%1x", *tptr&0x0f));
+ ND_PRINT((ndo, "0x%1x", EXTRACT_8BITS(tptr)&0x0f));
break;
case CLNP_OPTION_QOS_MAINTENANCE:
ND_PRINT((ndo, "\n\t Format Code: %s",
tok2str(clnp_option_scope_values, "Reserved", EXTRACT_8BITS(tptr) & CLNP_OPTION_SCOPE_MASK)));
- if ((*tptr&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL)
+ if ((EXTRACT_8BITS(tptr)&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL)
ND_PRINT((ndo, "\n\t QoS Flags [%s]",
bittok2str(clnp_option_qos_global_values,
"none",
- *tptr&CLNP_OPTION_OPTION_QOS_MASK)));
+ EXTRACT_8BITS(tptr)&CLNP_OPTION_OPTION_QOS_MASK)));
break;
case CLNP_OPTION_SECURITY:
return (0);
}
ND_PRINT((ndo, "\n\t Format Code: %s, Security-Level %u",
- tok2str(clnp_option_scope_values,"Reserved",EXTRACT_8BITS(tptr) & CLNP_OPTION_SCOPE_MASK),
- *(tptr+1)));
+ tok2str(clnp_option_scope_values,"Reserved",EXTRACT_8BITS(tptr)&CLNP_OPTION_SCOPE_MASK),
+ EXTRACT_8BITS(tptr+1)));
break;
case CLNP_OPTION_DISCARD_REASON:
case CLNP_PDU_ER: /* fall through */
case CLNP_PDU_ERP:
ND_TCHECK(*pptr);
- if (*(pptr) == NLPID_CLNP) {
+ if (EXTRACT_8BITS(pptr) == NLPID_CLNP) {
ND_PRINT((ndo, "\n\t-----original packet-----\n\t"));
/* FIXME recursion protection */
clnp_print(ndo, pptr, length - clnp_header->length_indicator);
if (li < sizeof(struct esis_header_t) + 2) {
ND_PRINT((ndo, " length indicator %u < min PDU size:", li));
- while (pptr < ndo->ndo_snapend)
- ND_PRINT((ndo, "%02X", *pptr++));
+ while (pptr < ndo->ndo_snapend) {
+ ND_PRINT((ndo, "%02X", EXTRACT_8BITS(pptr)));
+ pptr++;
+ }
return;
}
ND_PRINT((ndo, ", bad redirect/li"));
return;
}
- dstl = *pptr;
+ dstl = EXTRACT_8BITS(pptr);
pptr++;
li--;
ND_TCHECK2(*pptr, dstl);
ND_PRINT((ndo, ", bad redirect/li"));
return;
}
- snpal = *pptr;
+ snpal = EXTRACT_8BITS(pptr);
pptr++;
li--;
ND_TCHECK2(*pptr, snpal);
ND_PRINT((ndo, ", bad redirect/li"));
return;
}
- netal = *pptr;
+ netal = EXTRACT_8BITS(pptr);
pptr++;
ND_TCHECK2(*pptr, netal);
if (li < netal) {
ND_PRINT((ndo, ", bad esh/li"));
return;
}
- source_address_number = *pptr;
+ source_address_number = EXTRACT_8BITS(pptr);
pptr++;
li--;
ND_PRINT((ndo, ", bad esh/li"));
return;
}
- source_address_length = *pptr;
+ source_address_length = EXTRACT_8BITS(pptr);
pptr++;
li--;
ND_PRINT((ndo, ", bad ish/li"));
return;
}
- source_address_length = *pptr;
+ source_address_length = EXTRACT_8BITS(pptr);
pptr++;
li--;
ND_TCHECK2(*pptr, source_address_length);
return;
}
ND_TCHECK2(*pptr, 2);
- op = *pptr++;
- opli = *pptr++;
+ op = EXTRACT_8BITS(pptr);
+ opli = EXTRACT_8BITS(pptr + 1);
+ pptr += 2;
li -= 2;
if (opli > li) {
ND_PRINT((ndo, ", opt (%d) too long", op));
case ESIS_OPTION_PROTOCOLS:
while (opli>0) {
- ND_TCHECK(*tptr);
+ ND_TCHECK_8BITS(tptr);
ND_PRINT((ndo, "%s (0x%02x)",
tok2str(nlpid_values,
"unknown",
EXTRACT_8BITS(tptr)),
- *tptr));
+ EXTRACT_8BITS(tptr)));
if (opli>1) /* further NPLIDs ? - put comma */
ND_PRINT((ndo, ", "));
tptr++;
while (len > 2)
{
ND_TCHECK2(*tptr, 2);
- stlv_type = *(tptr++);
- stlv_len = *(tptr++);
+ stlv_type = EXTRACT_8BITS(tptr);
+ stlv_len = EXTRACT_8BITS(tptr + 1);
/* first lets see if we know the subTLVs name*/
ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u",
stlv_type,
stlv_len));
+ tptr = tptr + 2;
/*len -= TLV_TYPE_LEN_OFFSET;*/
- len = len -2;
+ len = len - 2;
/* Make sure the subTLV fits within the space left */
if (len < stlv_len)
goto trunc;
ND_PRINT((ndo, "\n\t RES: %d V: %d A: %d D: %d",
- (*(tptr) >> 5), (((*tptr)>> 4) & 0x01),
- ((*(tptr) >> 2) & 0x03), ((*tptr) & 0x03)));
+ (EXTRACT_8BITS(tptr) >> 5),
+ ((EXTRACT_8BITS(tptr) >> 4) & 0x01),
+ ((EXTRACT_8BITS(tptr) >> 2) & 0x03),
+ (EXTRACT_8BITS(tptr) & 0x03)));
tptr++;
while (len > 2)
{
ND_TCHECK2(*tptr, 2);
- stlv_type = *(tptr++);
- stlv_len = *(tptr++);
+ stlv_type = EXTRACT_8BITS(tptr);
+ stlv_len = EXTRACT_8BITS(tptr + 1);
+ tptr = tptr + 2;
+ len = len - 2;
/* first lets see if we know the subTLVs name*/
ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u",
stlv_type,
stlv_len));
- len = len - 2;
-
/* Make sure the subTLV fits within the space left */
if (len < stlv_len)
goto trunc;
ND_PRINT((ndo, ", SPSource-ID: %d",
(EXTRACT_BE_32BITS(tptr) & 0x000fffff)));
tptr = tptr+4;
- ND_PRINT((ndo, ", No of Trees: %x", *(tptr)));
+ ND_PRINT((ndo, ", No of Trees: %x", EXTRACT_8BITS(tptr)));
- tmp = *(tptr++);
+ tmp = EXTRACT_8BITS(tptr);
+ tptr++;
len = len - ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN;
stlv_len = stlv_len - ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN;
goto trunc;
ND_PRINT((ndo, "\n\t U:%d, M:%d, A:%d, RES:%d",
- *(tptr) >> 7, (*(tptr) >> 6) & 0x01,
- (*(tptr) >> 5) & 0x01, (*(tptr) & 0x1f)));
+ EXTRACT_8BITS(tptr) >> 7,
+ (EXTRACT_8BITS(tptr) >> 6) & 0x01,
+ (EXTRACT_8BITS(tptr) >> 5) & 0x01,
+ (EXTRACT_8BITS(tptr) & 0x1f)));
tptr++;
stlv_len = stlv_len - 8;
while (stlv_len >= 4) {
- ND_TCHECK2(*tptr, 4);
+ ND_TCHECK_32BITS(tptr);
ND_PRINT((ndo, "\n\t T: %d, R: %d, RES: %d, ISID: %d",
(EXTRACT_BE_32BITS(tptr) >> 31),
(EXTRACT_BE_32BITS(tptr) >> 30) & 0x01,
ND_PRINT((ndo, "%sBandwidth Constraints Model ID: %s (%u)",
ident,
tok2str(diffserv_te_bc_values, "unknown", EXTRACT_8BITS(tptr)),
- *tptr));
+ EXTRACT_8BITS(tptr)));
tptr++;
/* decode BCs until the subTLV ends */
for (te_class = 0; te_class < (subl-1)/4; te_class++) {
if (subl >= 2) {
ND_PRINT((ndo, ", %s, Priority %u",
bittok2str(gmpls_link_prot_values, "none", EXTRACT_8BITS(tptr)),
- *(tptr+1)));
+ EXTRACT_8BITS(tptr+1)));
}
break;
case ISIS_SUBTLV_SPB_METRIC:
if (subl >= 6) {
ND_PRINT((ndo, ", LM: %u", EXTRACT_BE_24BITS(tptr)));
tptr=tptr+3;
- ND_PRINT((ndo, ", P: %u", *(tptr)));
+ ND_PRINT((ndo, ", P: %u", EXTRACT_8BITS(tptr)));
tptr++;
ND_PRINT((ndo, ", P-ID: %u", EXTRACT_BE_16BITS(tptr)));
}
break;
case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
if (subl >= 36) {
- gmpls_switch_cap = *tptr;
+ gmpls_switch_cap = EXTRACT_8BITS(tptr);
ND_PRINT((ndo, "%s Interface Switching Capability:%s",
ident,
tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap)));
tptr+=NODE_ID_LEN;
if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
- if (!ND_TTEST2(*tptr, 3)) /* and is therefore skipped */
+ if (!ND_TTEST_24BITS(tptr)) /* and is therefore skipped */
return(0);
ND_PRINT((ndo, ", Metric: %d", EXTRACT_BE_24BITS(tptr)));
tptr+=3;
}
- if (!ND_TTEST2(*tptr, 1))
+ if (!ND_TTEST_8BITS(tptr))
return(0);
- subtlv_sum_len=*(tptr++); /* read out subTLV length */
+ subtlv_sum_len=EXTRACT_8BITS(tptr); /* read out subTLV length */
+ tptr++;
proc_bytes=NODE_ID_LEN+3+1;
ND_PRINT((ndo, ", %ssub-TLVs present",subtlv_sum_len ? "" : "no "));
if (subtlv_sum_len) {
while (subtlv_sum_len>0) {
if (!ND_TTEST2(*tptr,2))
return(0);
- subtlv_type=*(tptr++);
- subtlv_len=*(tptr++);
+ subtlv_type=EXTRACT_8BITS(tptr);
+ subtlv_len=EXTRACT_8BITS(tptr+1);
+ tptr+=2;
/* prepend the indent string */
snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
if (!isis_print_is_reach_subtlv(ndo, tptr, subtlv_type, subtlv_len, ident_buffer))
isis_print_mtid(netdissect_options *ndo,
const uint8_t *tptr, const char *ident)
{
- if (!ND_TTEST2(*tptr, 2))
+ if (!ND_TTEST_16BITS(tptr))
return(0);
ND_PRINT((ndo, "%s%s",
uint8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen;
- if (!ND_TTEST2(*tptr, 4))
+ if (!ND_TTEST_32BITS(tptr))
return (0);
metric = EXTRACT_BE_32BITS(tptr);
processed=4;
tptr+=4;
if (afi == AF_INET) {
- if (!ND_TTEST2(*tptr, 1)) /* fetch status byte */
+ if (!ND_TTEST_8BITS(tptr)) /* fetch status byte */
return (0);
- status_byte=*(tptr++);
+ status_byte=EXTRACT_8BITS(tptr);
+ tptr++;
bit_length = status_byte&0x3f;
if (bit_length > 32) {
ND_PRINT((ndo, "%sIPv4 prefix: bad bit length %u",
} else if (afi == AF_INET6) {
if (!ND_TTEST2(*tptr, 2)) /* fetch status & prefix_len byte */
return (0);
- status_byte=*(tptr++);
- bit_length=*(tptr++);
+ status_byte=EXTRACT_8BITS(tptr);
+ bit_length=EXTRACT_8BITS(tptr+1);
if (bit_length > 128) {
ND_PRINT((ndo, "%sIPv6 prefix: bad bit length %u",
ident,
bit_length));
return (0);
}
+ tptr+=2;
processed+=2;
} else
return (0); /* somebody is fooling us */
than one subTLV - therefore the first byte must reflect
the aggregate bytecount of the subTLVs for this prefix
*/
- if (!ND_TTEST2(*tptr, 1))
+ if (!ND_TTEST_8BITS(tptr))
return (0);
- sublen=*(tptr++);
+ sublen=EXTRACT_8BITS(tptr);
+ tptr++;
processed+=sublen+1;
ND_PRINT((ndo, " (%u)", sublen)); /* print out subTLV length */
while (sublen>0) {
if (!ND_TTEST2(*tptr,2))
return (0);
- subtlvtype=*(tptr++);
- subtlvlen=*(tptr++);
+ subtlvtype=EXTRACT_8BITS(tptr);
+ subtlvlen=EXTRACT_8BITS(tptr+1);
+ tptr+=2;
/* prepend the indent string */
snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer))
uint8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
uint8_t ext_is_len, ext_ip_len, mt_len;
+ uint8_t isis_subtlv_idrp;
const uint8_t *optr, *pptr, *tptr;
u_short packet_len,pdu_len, key_id;
u_int i,vendor_id;
ND_TCHECK2(*pptr, 2);
if (packet_len < 2)
goto trunc;
- tlv_type = *pptr++;
- tlv_len = *pptr++;
+ tlv_type = EXTRACT_8BITS(pptr);
+ tlv_len = EXTRACT_8BITS(pptr + 1);
+ pptr += 2;
+ packet_len -= 2;
tmp =tlv_len; /* copy temporary len & pointer to packet data */
tptr = pptr;
- packet_len -= 2;
/* first lets see if we know the TLVs name*/
ND_PRINT((ndo, "\n\t %s TLV #%u, length: %u",
/* now check if we have a decoder otherwise do a hexdump at the end*/
switch (tlv_type) {
case ISIS_TLV_AREA_ADDR:
- ND_TCHECK2(*tptr, 1);
- alen = *tptr++;
+ ND_TCHECK_8BITS(tptr);
+ alen = EXTRACT_8BITS(tptr);
+ tptr++;
while (tmp && alen < tmp) {
ND_TCHECK2(*tptr, alen);
ND_PRINT((ndo, "\n\t Area address (length: %u): %s",
tmp -= alen + 1;
if (tmp==0) /* if this is the last area address do not attemt a boundary check */
break;
- ND_TCHECK2(*tptr, 1);
- alen = *tptr++;
+ ND_TCHECK_8BITS(tptr);
+ alen = EXTRACT_8BITS(tptr);
+ tptr++;
}
break;
case ISIS_TLV_ISNEIGH:
break;
case ISIS_TLV_ISNEIGH_VARLEN:
- if (!ND_TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
+ if (!ND_TTEST_8BITS(tptr) || tmp < 3) /* min. TLV length */
goto trunctlv;
- lan_alen = *tptr++; /* LAN address length */
+ lan_alen = EXTRACT_8BITS(tptr); /* LAN address length */
+ tptr++;
if (lan_alen == 0) {
ND_PRINT((ndo, "\n\t LAN address length 0 bytes (invalid)"));
break;
}
break;
case ISIS_TLV_IS_REACH:
- ND_TCHECK2(*tptr,1); /* check if there is one byte left to read out the virtual flag */
+ ND_TCHECK_8BITS(tptr); /* check if there is one byte left to read out the virtual flag */
ND_PRINT((ndo, "\n\t %s",
tok2str(isis_is_reach_virtual_values,
"bogus virtual flag 0x%02x",
}
break;
case ISIS_TLV_AUTH:
- ND_TCHECK2(*tptr, 1);
+ ND_TCHECK_8BITS(tptr);
ND_PRINT((ndo, "\n\t %s: ",
tok2str(isis_subtlv_auth_values,
"unknown Authentication type 0x%02x",
EXTRACT_8BITS(tptr))));
- switch (*tptr) {
+ switch (EXTRACT_8BITS(tptr)) {
case ISIS_SUBTLV_AUTH_SIMPLE:
if (fn_printzp(ndo, tptr + 1, tlv_len - 1, ndo->ndo_snapend))
goto trunctlv;
break;
case ISIS_SUBTLV_AUTH_MD5:
for(i=1;i<tlv_len;i++) {
- ND_TCHECK2(*(tptr + i), 1);
- ND_PRINT((ndo, "%02x", *(tptr + i)));
+ ND_TCHECK_8BITS(tptr + i);
+ ND_PRINT((ndo, "%02x", EXTRACT_8BITS(tptr + i)));
}
if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
ND_PRINT((ndo, ", (invalid subTLV) "));
break;
case ISIS_SUBTLV_AUTH_GENERIC:
- ND_TCHECK2(*(tptr + 1), 2);
- key_id = EXTRACT_BE_16BITS((tptr + 1));
+ ND_TCHECK_16BITS(tptr + 1);
+ key_id = EXTRACT_BE_16BITS(tptr + 1);
ND_PRINT((ndo, "%u, password: ", key_id));
for(i=1 + sizeof(uint16_t);i<tlv_len;i++) {
- ND_TCHECK2(*(tptr + i), 1);
- ND_PRINT((ndo, "%02x", *(tptr + i)));
+ ND_TCHECK_8BITS(tptr + i);
+ ND_PRINT((ndo, "%02x", EXTRACT_8BITS(tptr + i)));
}
break;
case ISIS_SUBTLV_AUTH_PRIVATE:
case ISIS_TLV_PTP_ADJ:
tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
if(tmp>=1) {
- ND_TCHECK2(*tptr, 1);
+ ND_TCHECK_8BITS(tptr);
ND_PRINT((ndo, "\n\t Adjacency State: %s (%u)",
tok2str(isis_ptp_adjancey_values, "unknown", EXTRACT_8BITS(tptr)),
- *tptr));
+ EXTRACT_8BITS(tptr)));
tmp--;
}
if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) {
case ISIS_TLV_PROTOCOLS:
ND_PRINT((ndo, "\n\t NLPID(s): "));
while (tmp>0) {
- ND_TCHECK2(*(tptr), 1);
+ ND_TCHECK_8BITS(tptr);
ND_PRINT((ndo, "%s (0x%02x)",
tok2str(nlpid_values,
"unknown",
EXTRACT_8BITS(tptr)),
- *tptr));
+ EXTRACT_8BITS(tptr)));
if (tmp>1) /* further NPLIDs ? - put comma */
ND_PRINT((ndo, ", "));
tptr++;
case ISIS_TLV_MT_PORT_CAP:
{
- ND_TCHECK2(*(tptr), 2);
+ ND_TCHECK_16BITS(tptr);
ND_PRINT((ndo, "\n\t RES: %d, MTID(s): %d",
(EXTRACT_BE_16BITS(tptr) >> 12),
case ISIS_TLV_MT_CAPABILITY:
- ND_TCHECK2(*(tptr), 2);
+ ND_TCHECK_16BITS(tptr);
ND_PRINT((ndo, "\n\t O: %d, RES: %d, MTID(s): %d",
(EXTRACT_BE_16BITS(tptr) >> 15) & 0x01,
if (tmp < 1)
break;
- ND_TCHECK2(*tptr, 1);
+ ND_TCHECK_8BITS(tptr);
ND_PRINT((ndo, ", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(EXTRACT_8BITS(tptr)) ? "numbered" : "unnumbered"));
tptr++;
tmp--;
tmp-=sizeof(struct in_addr);
while (tmp>=4) {
- ND_TCHECK2(*tptr, 4);
+ ND_TCHECK_32BITS(tptr);
ND_PRINT((ndo, "\n\t Link-ID: 0x%08x", EXTRACT_BE_32BITS(tptr)));
tptr+=4;
tmp-=4;
tok2str(isis_subtlv_idrp_values,
"Unknown (0x%02x)",
EXTRACT_8BITS(tptr))));
- switch (*tptr++) {
+ isis_subtlv_idrp = EXTRACT_8BITS(tptr);
+ tptr++;
+ switch (isis_subtlv_idrp) {
case ISIS_SUBTLV_IDRP_ASN:
- ND_TCHECK2(*tptr, 2); /* fetch AS number */
+ ND_TCHECK_16BITS(tptr); /* fetch AS number */
ND_PRINT((ndo, "AS Number: %u", EXTRACT_BE_16BITS(tptr)));
break;
case ISIS_SUBTLV_IDRP_LOCAL:
tmp-=sizeof(struct isis_metric_block);
while(tmp>0) {
- ND_TCHECK2(*tptr, 1);
- prefix_len=*tptr++; /* read out prefix length in semioctets*/
+ ND_TCHECK_8BITS(tptr);
+ prefix_len=EXTRACT_8BITS(tptr); /* read out prefix length in semioctets*/
+ tptr++;
if (prefix_len < 2) {
ND_PRINT((ndo, "\n\t\tAddress: prefix length %u < 2", prefix_len));
break;