*
*/
+/* \summary: Forwarding and Control Element Separation (ForCES) Protocol printer */
+
+/* specification: RFC 5810 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
static const char tstr[] = "[|forces]";
-/*
- * RFC5810: Forwarding and Control Element Separation (ForCES) Protocol
- */
#define ForCES_VERS 1
#define ForCES_HDRL 24
#define ForCES_ALNL 4U
uint16_t flags;
uint16_t op_msk;
const char *s;
- int (*print) (netdissect_options *ndo, register const u_char * pptr, register u_int len,
+ int (*print) (netdissect_options *ndo, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
};
* Structure of forces header, naked of TLVs.
*/
struct forcesh {
- uint8_t fm_vrsvd; /* version and reserved */
-#define ForCES_V(forcesh) ((forcesh)->fm_vrsvd >> 4)
- uint8_t fm_tom; /* type of message */
- uint16_t fm_len; /* total length * 4 bytes */
-#define ForCES_BLN(forcesh) ((uint32_t)(EXTRACT_16BITS(&(forcesh)->fm_len) << 2))
- uint32_t fm_sid; /* Source ID */
-#define ForCES_SID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_sid)
- uint32_t fm_did; /* Destination ID */
-#define ForCES_DID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_did)
- uint8_t fm_cor[8]; /* correlator */
- uint32_t fm_flags; /* flags */
-#define ForCES_ACK(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0xC0000000) >> 30)
-#define ForCES_PRI(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x38000000) >> 27)
-#define ForCES_RS1(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x07000000) >> 24)
-#define ForCES_EM(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00C00000) >> 22)
-#define ForCES_AT(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00200000) >> 21)
-#define ForCES_TP(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00180000) >> 19)
-#define ForCES_RS2(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x0007FFFF) >> 0)
+ nd_uint8_t fm_vrsvd; /* version and reserved */
+#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))
+ nd_uint32_t fm_sid; /* Source ID */
+#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)
+ 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_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \
uint16_t flags;
uint16_t op_msk;
const char *s;
- int (*print) (netdissect_options *ndo, register const u_char * pptr, register u_int len,
+ int (*print) (netdissect_options *ndo, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
};
-static int genoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+static int genoptlv_print(netdissect_options *, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
-static int recpdoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+static int recpdoptlv_print(netdissect_options *, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
-static int invoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+static int invoptlv_print(netdissect_options *, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
#define OP_MIN_SIZ 8
struct pathdata_h {
- uint16_t pflags;
- uint16_t pIDcnt;
+ nd_uint16_t pflags;
+ nd_uint16_t pIDcnt;
};
#define B_FULLD 0x1
static inline const struct optlv_h *get_forces_optlv_h(uint16_t opt)
{
- if (opt > F_OP_MAX || opt <= F_OP_RSV)
+ if (opt > F_OP_MAX || opt == F_OP_RSV)
return &OPTLV_msg[F_OP_RSV];
return &OPTLV_msg[opt];
#define IND_CHR ' '
#define IND_PREF '\n'
#define IND_SUF 0x0
-char ind_buf[IND_SIZE];
+static char ind_buf[IND_SIZE];
static inline char *indent_pr(int indent, int nlpref)
{
static inline int op_valid(uint16_t op, uint16_t mask)
{
- int opb = 1 << (op - 1);
-
if (op == 0)
return 0;
- if (opb & mask)
- return 1;
+ if (op <= F_OP_MAX)
+ return (1 << (op - 1)) & mask; /* works only for 0x0001 through 0x0010 */
/* I guess we should allow vendor operations? */
if (op >= 0x8000)
return 1;
}
struct forces_ilv {
- uint32_t type;
- uint32_t length;
+ nd_uint32_t type;
+ nd_uint32_t length;
};
struct forces_tlv {
- uint16_t type;
- uint16_t length;
+ nd_uint16_t type;
+ nd_uint16_t length;
};
#define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
#define GET_TOP_TLV(fhdr) ((const struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
#define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len))
#define TLV_ALN_LEN(len) F_ALN_LEN(TLV_SET_LEN(len))
-#define TLV_RDAT_LEN(tlv) ((int)(EXTRACT_16BITS(&(tlv)->length) - TLV_SET_LEN(0))
+#define TLV_RDAT_LEN(tlv) (EXTRACT_BE_U_2(&(tlv)->length) - TLV_SET_LEN(0)
#define TLV_DATA(tlvp) ((const void*)(((const char*)(tlvp)) + TLV_SET_LEN(0)))
-#define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length)), \
+#define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_BE_U_2(&(tlv)->length)), \
(const struct forces_tlv*)(((const char*)(tlv)) \
- + F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length))))
+ + F_ALN_LEN(EXTRACT_BE_U_2(&(tlv)->length))))
#define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len))
#define ILV_ALN_LEN(len) F_ALN_LEN(ILV_SET_LEN(len))
-#define ILV_RDAT_LEN(ilv) ((int)(EXTRACT_32BITS(&(ilv)->length)) - ILV_SET_LEN(0))
+#define ILV_RDAT_LEN(ilv) (EXTRACT_BE_U_4(&(ilv)->length)) - ILV_SET_LEN(0)
#define ILV_DATA(ilvp) ((const void*)(((const char*)(ilvp)) + ILV_SET_LEN(0)))
-#define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length)), \
+#define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_BE_U_4(&(ilv)->length)), \
(const struct forces_ilv *)(((const char*)(ilv)) \
- + F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length))))
+ + F_ALN_LEN(EXTRACT_BE_U_4(&(ilv)->length))))
#define INVALID_RLEN 1
#define INVALID_STLN 2
#define INVALID_LTLN 3
{
if (rlen < TLV_HDRL)
return INVALID_RLEN;
- if (EXTRACT_16BITS(&tlv->length) < TLV_HDRL)
+ if (EXTRACT_BE_U_2(&tlv->length) < TLV_HDRL)
return INVALID_STLN;
- if (EXTRACT_16BITS(&tlv->length) > rlen)
+ if (EXTRACT_BE_U_2(&tlv->length) > rlen)
return INVALID_LTLN;
- if (rlen < F_ALN_LEN(EXTRACT_16BITS(&tlv->length)))
+ if (rlen < F_ALN_LEN(EXTRACT_BE_U_2(&tlv->length)))
return INVALID_ALEN;
return 0;
{
if (rlen < ILV_HDRL)
return INVALID_RLEN;
- if (EXTRACT_32BITS(&ilv->length) < ILV_HDRL)
+ if (EXTRACT_BE_U_4(&ilv->length) < ILV_HDRL)
return INVALID_STLN;
- if (EXTRACT_32BITS(&ilv->length) > rlen)
+ if (EXTRACT_BE_U_4(&ilv->length) > rlen)
return INVALID_LTLN;
- if (rlen < F_ALN_LEN(EXTRACT_32BITS(&ilv->length)))
+ if (rlen < F_ALN_LEN(EXTRACT_BE_U_4(&ilv->length)))
return INVALID_ALEN;
return 0;
}
-static int lfbselect_print(netdissect_options *, register const u_char * pptr, register u_int len,
+static int lfbselect_print(netdissect_options *, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
-static int redirect_print(netdissect_options *, register const u_char * pptr, register u_int len,
+static int redirect_print(netdissect_options *, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
-static int asrtlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+static int asrtlv_print(netdissect_options *, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
-static int asttlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+static int asttlv_print(netdissect_options *, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
struct forces_lfbsh {
- uint32_t class;
- uint32_t instance;
+ nd_uint32_t class;
+ nd_uint32_t instance;
};
#define ASSNS_OPS (B_OP_REPORT)
uint16_t flags;
uint16_t op_msk;
const char *s;
- int (*print) (netdissect_options *, register const u_char * pptr, register u_int len,
+ int (*print) (netdissect_options *, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
};
#define F_TABAPPEND 4
struct res_val {
- uint8_t result;
- uint8_t resv1;
- uint16_t resv2;
+ nd_uint8_t result;
+ nd_uint8_t resv1;
+ nd_uint16_t resv2;
};
-static int prestlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+static int prestlv_print(netdissect_options *, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
-static int pkeyitlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+static int pkeyitlv_print(netdissect_options *, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
-static int fdatatlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+static int fdatatlv_print(netdissect_options *, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
-static int sdatatlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+static int sdatatlv_print(netdissect_options *, const u_char * pptr, u_int len,
uint16_t op_msk, int indent);
static const struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = {
static int
prestlv_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk _U_, int indent)
{
const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
- register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
+ 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)
}
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;
static int
fdatatlv_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk _U_, int indent)
{
const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
u_int rlen;
- register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
+ const u_char *tdp = (const u_char *) TLV_DATA(tlv);
uint16_t type;
/*
*/
rlen = len - TLV_HDRL;
ND_TCHECK(*tlv);
- type = EXTRACT_16BITS(&tlv->type);
+ type = EXTRACT_BE_U_2(&tlv->type);
if (type != F_TLV_FULD) {
ND_PRINT((ndo, "Error: expecting FULLDATA!\n"));
return -1;
static int
sdatailv_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk _U_, int indent)
{
u_int rlen;
ND_PRINT((ndo, "Jamal - outstanding length <%d>\n", rlen));
#endif
char *ib = indent_pr(indent, 1);
- register const u_char *tdp = (const u_char *) ILV_DATA(ilv);
+ const u_char *tdp = (const u_char *) ILV_DATA(ilv);
ND_TCHECK(*ilv);
invilv = ilv_valid(ilv, rlen);
if (invilv) {
return -1;
}
if (ndo->ndo_vflag >= 3) {
- int ilvl = EXTRACT_32BITS(&ilv->length);
+ int ilvl = EXTRACT_BE_U_4(&ilv->length);
ND_PRINT((ndo, "\n%s ILV: type %x length %d\n", &ib[1],
- EXTRACT_32BITS(&ilv->type), ilvl));
+ EXTRACT_BE_U_4(&ilv->type), ilvl));
hex_print_with_offset(ndo, "\t\t[", tdp, ilvl-ILV_HDRL, 0);
}
static int
sdatatlv_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk, int indent)
{
const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
u_int rlen;
- register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
+ const u_char *tdp = (const u_char *) TLV_DATA(tlv);
uint16_t type;
/*
*/
rlen = len - TLV_HDRL;
ND_TCHECK(*tlv);
- type = EXTRACT_16BITS(&tlv->type);
+ type = EXTRACT_BE_U_2(&tlv->type);
if (type != F_TLV_SPAD) {
ND_PRINT((ndo, "Error: expecting SPARSEDATA!\n"));
return -1;
static int
pkeyitlv_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk, int indent)
{
const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
- register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
- register const u_char *dp = tdp + 4;
+ const u_char *tdp = (const u_char *) TLV_DATA(tlv);
+ const u_char *dp = tdp + 4;
const struct forces_tlv *kdtlv = (const struct forces_tlv *)dp;
uint32_t id;
char *ib = indent_pr(indent, 0);
uint16_t type, tll;
u_int invtlv;
- ND_TCHECK(*tdp);
- id = EXTRACT_32BITS(tdp);
+ ND_TCHECK_1(tdp);
+ id = EXTRACT_BE_U_4(tdp);
ND_PRINT((ndo, "%sKeyinfo: Key 0x%x\n", ib, id));
ND_TCHECK(*kdtlv);
- type = EXTRACT_16BITS(&kdtlv->type);
+ type = EXTRACT_BE_U_2(&kdtlv->type);
invtlv = tlv_valid(kdtlv, len);
if (invtlv) {
ND_PRINT((ndo, "%s TLV type 0x%x len %d\n",
tok2str(ForCES_TLV_err, NULL, invtlv), type,
- EXTRACT_16BITS(&kdtlv->length)));
+ EXTRACT_BE_U_2(&kdtlv->length)));
return -1;
}
/*
* length is large enough but not too large (it doesn't
* go past the end of the containing TLV).
*/
- tll = EXTRACT_16BITS(&kdtlv->length);
+ tll = EXTRACT_BE_U_2(&kdtlv->length);
dp = (const u_char *) TLV_DATA(kdtlv);
return fdatatlv_print(ndo, dp, tll, op_msk, indent);
static int
pdatacnt_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t IDcnt, uint16_t op_msk, int indent)
{
u_int i;
ND_PRINT((ndo, "%sTABLE APPEND\n", ib));
}
for (i = 0; i < IDcnt; i++) {
- ND_TCHECK2(*pptr, 4);
+ ND_TCHECK_4(pptr);
if (len < 4)
goto trunc;
- id = EXTRACT_32BITS(pptr);
+ id = EXTRACT_BE_U_4(pptr);
if (ndo->ndo_vflag >= 3)
ND_PRINT((ndo, "%sID#%02u: %d\n", ib, i + 1, id));
len -= 4;
pptr += sizeof(struct forces_tlv);
len -= sizeof(struct forces_tlv);
- starti = EXTRACT_32BITS(pptr);
+ starti = EXTRACT_BE_U_4(pptr);
pptr += 4;
len -= 4;
- endi = EXTRACT_32BITS(pptr);
+ endi = EXTRACT_BE_U_4(pptr);
pptr += 4;
len -= 4;
pptr += sizeof(struct forces_tlv);
len -= sizeof(struct forces_tlv);
/* skip key content */
- tll = EXTRACT_16BITS(&keytlv->length);
+ tll = EXTRACT_BE_U_2(&keytlv->length);
if (tll < TLV_HDRL) {
ND_PRINT((ndo, "key content length %u < %u\n",
tll, TLV_HDRL));
u_int invtlv;
ND_TCHECK(*pdtlv);
- type = EXTRACT_16BITS(&pdtlv->type);
+ type = EXTRACT_BE_U_2(&pdtlv->type);
invtlv = tlv_valid(pdtlv, len);
if (invtlv) {
ND_PRINT((ndo, "%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
tok2str(ForCES_TLV_err, NULL, invtlv), len, type,
- EXTRACT_16BITS(&pdtlv->length)));
+ EXTRACT_BE_U_2(&pdtlv->length)));
goto pd_err;
}
/*
* length is large enough but not too large (it doesn't
* go past the end of the containing TLV).
*/
- tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
- aln = F_ALN_LEN(EXTRACT_16BITS(&pdtlv->length));
- if (aln > EXTRACT_16BITS(&pdtlv->length)) {
+ tll = EXTRACT_BE_U_2(&pdtlv->length) - TLV_HDRL;
+ aln = F_ALN_LEN(EXTRACT_BE_U_2(&pdtlv->length));
+ if (aln > EXTRACT_BE_U_2(&pdtlv->length)) {
if (aln > len) {
ND_PRINT((ndo,
"Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
- type, EXTRACT_16BITS(&pdtlv->length), aln - len));
+ type, EXTRACT_BE_U_2(&pdtlv->length), aln - len));
} else {
- pad = aln - EXTRACT_16BITS(&pdtlv->length);
+ pad = aln - EXTRACT_BE_U_2(&pdtlv->length);
}
}
if (pd_valid(type)) {
if (ndo->ndo_vflag >= 3 && ops->v != F_TLV_PDAT) {
if (pad)
ND_PRINT((ndo, "%s %s (Length %d DataLen %d pad %d Bytes)\n",
- ib, ops->s, EXTRACT_16BITS(&pdtlv->length), tll, pad));
+ ib, ops->s, EXTRACT_BE_U_2(&pdtlv->length), tll, pad));
else
ND_PRINT((ndo, "%s %s (Length %d DataLen %d Bytes)\n",
- ib, ops->s, EXTRACT_16BITS(&pdtlv->length), tll));
+ ib, ops->s, EXTRACT_BE_U_2(&pdtlv->length), tll));
}
chk_op_type(ndo, type, op_msk, ops->op_msk);
len -= (TLV_HDRL + pad + tll);
} else {
ND_PRINT((ndo, "Invalid path data content type 0x%x len %d\n",
- type, EXTRACT_16BITS(&pdtlv->length)));
+ type, EXTRACT_BE_U_2(&pdtlv->length)));
pd_err:
- if (EXTRACT_16BITS(&pdtlv->length)) {
+ if (EXTRACT_BE_U_2(&pdtlv->length)) {
hex_print_with_offset(ndo, "Bad Data val\n\t [",
pptr, len, 0);
ND_PRINT((ndo, "]\n"));
static int
pdata_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk, int indent)
{
const struct pathdata_h *pdh = (const struct pathdata_h *)pptr;
goto trunc;
if (ndo->ndo_vflag >= 3) {
ND_PRINT((ndo, "\n%sPathdata: Flags 0x%x ID count %d\n",
- ib, EXTRACT_16BITS(&pdh->pflags), EXTRACT_16BITS(&pdh->pIDcnt)));
+ ib, EXTRACT_BE_U_2(&pdh->pflags), EXTRACT_BE_U_2(&pdh->pIDcnt)));
}
- if (EXTRACT_16BITS(&pdh->pflags) & F_SELKEY) {
+ if (EXTRACT_BE_U_2(&pdh->pflags) & F_SELKEY) {
op_msk |= B_KEYIN;
}
/* Table GET Range operation */
- if (EXTRACT_16BITS(&pdh->pflags) & F_SELTABRANGE) {
+ if (EXTRACT_BE_U_2(&pdh->pflags) & F_SELTABRANGE) {
op_msk |= B_TRNG;
}
/* Table SET append operation */
- if (EXTRACT_16BITS(&pdh->pflags) & F_TABAPPEND) {
+ if (EXTRACT_BE_U_2(&pdh->pflags) & F_TABAPPEND) {
op_msk |= B_APPND;
}
pptr += sizeof(struct pathdata_h);
len -= sizeof(struct pathdata_h);
- idcnt = EXTRACT_16BITS(&pdh->pIDcnt);
+ idcnt = EXTRACT_BE_U_2(&pdh->pIDcnt);
minsize = idcnt * 4;
if (len < minsize) {
ND_PRINT((ndo, "\t\t\ttruncated IDs expected %uB got %uB\n", minsize,
static int
genoptlv_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk, int indent)
{
const struct forces_tlv *pdtlv = (const struct forces_tlv *)pptr;
char *ib = indent_pr(indent, 0);
ND_TCHECK(*pdtlv);
- type = EXTRACT_16BITS(&pdtlv->type);
- tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
+ type = EXTRACT_BE_U_2(&pdtlv->type);
+ tll = EXTRACT_BE_U_2(&pdtlv->length) - TLV_HDRL;
invtlv = tlv_valid(pdtlv, len);
ND_PRINT((ndo, "genoptlvprint - %s TLV type 0x%x len %d\n",
- tok2str(ForCES_TLV, NULL, type), type, EXTRACT_16BITS(&pdtlv->length)));
+ tok2str(ForCES_TLV, NULL, type), type, EXTRACT_BE_U_2(&pdtlv->length)));
if (!invtlv) {
/*
* At this point, tlv_valid() has ensured that the TLV
* length is large enough but not too large (it doesn't
* go past the end of the containing TLV).
*/
- register const u_char *dp = (const u_char *) TLV_DATA(pdtlv);
+ const u_char *dp = (const u_char *) TLV_DATA(pdtlv);
if (!ttlv_valid(type)) {
ND_PRINT((ndo, "%s TLV type 0x%x len %d\n",
tok2str(ForCES_TLV_err, NULL, invtlv), type,
- EXTRACT_16BITS(&pdtlv->length)));
+ EXTRACT_BE_U_2(&pdtlv->length)));
return -1;
}
if (ndo->ndo_vflag >= 3)
ND_PRINT((ndo, "%s%s, length %d (data length %d Bytes)",
ib, tok2str(ForCES_TLV, NULL, type),
- EXTRACT_16BITS(&pdtlv->length), tll));
+ EXTRACT_BE_U_2(&pdtlv->length), tll));
return pdata_print(ndo, dp, tll, op_msk, indent + 1);
} else {
static int
recpdoptlv_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk, int indent)
{
const struct forces_tlv *pdtlv = (const struct forces_tlv *)pptr;
int tll;
u_int invtlv;
uint16_t type;
- register const u_char *dp;
+ const u_char *dp;
char *ib;
while (len != 0) {
* go past the end of the containing TLV).
*/
ib = indent_pr(indent, 0);
- type = EXTRACT_16BITS(&pdtlv->type);
+ type = EXTRACT_BE_U_2(&pdtlv->type);
dp = (const u_char *) TLV_DATA(pdtlv);
- tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
+ tll = EXTRACT_BE_U_2(&pdtlv->length) - TLV_HDRL;
if (ndo->ndo_vflag >= 3)
ND_PRINT((ndo, "%s%s, length %d (data encapsulated %d Bytes)",
ib, tok2str(ForCES_TLV, NULL, type),
- EXTRACT_16BITS(&pdtlv->length),
- EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL));
+ EXTRACT_BE_U_2(&pdtlv->length),
+ EXTRACT_BE_U_2(&pdtlv->length) - TLV_HDRL));
if (pdata_print(ndo, dp, tll, op_msk, indent + 1) == -1)
return -1;
if (len) {
ND_PRINT((ndo,
"\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
- EXTRACT_16BITS(&pdtlv->type), len - EXTRACT_16BITS(&pdtlv->length)));
+ EXTRACT_BE_U_2(&pdtlv->type), len - EXTRACT_BE_U_2(&pdtlv->length)));
return -1;
}
static int
invoptlv_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk _U_, int indent)
{
char *ib = indent_pr(indent, 1);
const struct forces_tlv *otlv, uint16_t op_msk _U_, int indent)
{
int rc = 0;
- register const u_char *dp = (const u_char *) TLV_DATA(otlv);
+ const u_char *dp = (const u_char *) TLV_DATA(otlv);
uint16_t type;
int tll;
char *ib = indent_pr(indent, 0);
const struct optlv_h *ops;
/*
- * lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
+ * lfbselect_print() has ensured that EXTRACT_BE_U_2(&otlv->length)
* >= TLV_HDRL.
*/
ND_TCHECK(*otlv);
- type = EXTRACT_16BITS(&otlv->type);
- tll = EXTRACT_16BITS(&otlv->length) - TLV_HDRL;
+ type = EXTRACT_BE_U_2(&otlv->type);
+ tll = EXTRACT_BE_U_2(&otlv->length) - TLV_HDRL;
ops = get_forces_optlv_h(type);
if (ndo->ndo_vflag >= 3) {
ND_PRINT((ndo, "%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type,
- EXTRACT_16BITS(&otlv->length)));
+ EXTRACT_BE_U_2(&otlv->length)));
}
/* rest of ops must at least have 12B {pathinfo} */
if (tll < OP_MIN_SIZ) {
ND_PRINT((ndo, "\t\tOper TLV %s(0x%x) length %d\n", ops->s, type,
- EXTRACT_16BITS(&otlv->length)));
+ EXTRACT_BE_U_2(&otlv->length)));
ND_PRINT((ndo, "\t\tTruncated data size %d minimum required %d\n", tll,
OP_MIN_SIZ));
return invoptlv_print(ndo, dp, tll, ops->op_msk, indent);
#define ASTMCD 255
static int
asttlv_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk _U_, int indent)
{
uint32_t rescode;
ND_PRINT((ndo, "illegal ASTresult-TLV: %d bytes!\n", dlen));
return -1;
}
- ND_TCHECK2(*pptr, 4);
- rescode = EXTRACT_32BITS(pptr);
+ ND_TCHECK_4(pptr);
+ rescode = EXTRACT_BE_U_4(pptr);
if (rescode > ASTMCD) {
ND_PRINT((ndo, "illegal ASTresult result code: %d!\n", rescode));
return -1;
#define ASRMCD 3
static int
asrtlv_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk _U_, int indent)
{
uint32_t rescode;
ND_PRINT((ndo, "illegal ASRresult-TLV: %d bytes!\n", dlen));
return -1;
}
- ND_TCHECK2(*pptr, 4);
- rescode = EXTRACT_32BITS(pptr);
+ ND_TCHECK_4(pptr);
+ rescode = EXTRACT_BE_U_4(pptr);
if (rescode > ASRMCD) {
ND_PRINT((ndo, "illegal ASRresult result code: %d!\n", rescode));
*/
static int
gentltlv_print(netdissect_options *ndo,
- register const u_char * pptr _U_, register u_int len,
+ const u_char * pptr _U_, u_int len,
uint16_t op_msk _U_, int indent _U_)
{
u_int dlen = len - TLV_HDRL;
static int
print_metailv(netdissect_options *ndo,
- register const u_char * pptr, uint16_t op_msk _U_, int indent)
+ const u_char * pptr, uint16_t op_msk _U_, int indent)
{
u_int rlen;
char *ib = indent_pr(indent, 0);
* print_metatlv() has ensured that len (what remains in the
* ILV) >= ILV_HDRL.
*/
- rlen = EXTRACT_32BITS(&ilv->length) - ILV_HDRL;
+ rlen = EXTRACT_BE_U_4(&ilv->length) - ILV_HDRL;
ND_TCHECK(*ilv);
- ND_PRINT((ndo, "%sMetaID 0x%x length %d\n", ib, EXTRACT_32BITS(&ilv->type),
- EXTRACT_32BITS(&ilv->length)));
+ ND_PRINT((ndo, "%sMetaID 0x%x length %d\n", ib, EXTRACT_BE_U_4(&ilv->type),
+ EXTRACT_BE_U_4(&ilv->length)));
if (ndo->ndo_vflag >= 3) {
hex_print_with_offset(ndo, "\t\t[", ILV_DATA(ilv), rlen, 0);
ND_PRINT((ndo, " ]\n"));
static int
print_metatlv(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk _U_, int indent)
{
u_int dlen;
static int
print_reddata(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
- uint16_t op_msk _U_, int indent _U_)
+ const u_char * pptr, u_int len,
+ uint16_t op_msk _U_, int indent)
{
u_int dlen;
char *ib = indent_pr(indent, 0);
static int
redirect_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk _U_, int indent)
{
const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
* length is large enough but not too large (it doesn't
* go past the end of the containing TLV).
*/
- if (EXTRACT_16BITS(&tlv->type) == F_TLV_METD) {
+ if (EXTRACT_BE_U_2(&tlv->type) == F_TLV_METD) {
print_metatlv(ndo, (const u_char *) TLV_DATA(tlv),
- EXTRACT_16BITS(&tlv->length), 0, indent);
- } else if ((EXTRACT_16BITS(&tlv->type) == F_TLV_REDD)) {
+ EXTRACT_BE_U_2(&tlv->length), 0,
+ indent);
+ } else if ((EXTRACT_BE_U_2(&tlv->type) == F_TLV_REDD)) {
print_reddata(ndo, (const u_char *) TLV_DATA(tlv),
- EXTRACT_16BITS(&tlv->length), 0, indent);
+ EXTRACT_BE_U_2(&tlv->length), 0,
+ indent);
} else {
ND_PRINT((ndo, "Unknown REDIRECT TLV 0x%x len %d\n",
- EXTRACT_16BITS(&tlv->type),
- EXTRACT_16BITS(&tlv->length)));
+ EXTRACT_BE_U_2(&tlv->type),
+ EXTRACT_BE_U_2(&tlv->length)));
}
tlv = GO_NXT_TLV(tlv, rlen);
if (rlen) {
ND_PRINT((ndo,
"\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
- EXTRACT_16BITS(&tlv->type),
- rlen - EXTRACT_16BITS(&tlv->length)));
+ EXTRACT_BE_U_2(&tlv->type),
+ rlen - EXTRACT_BE_U_2(&tlv->length)));
return -1;
}
static int
lfbselect_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len,
+ const u_char * pptr, u_int len,
uint16_t op_msk, int indent)
{
const struct forces_lfbsh *lfbs;
ND_TCHECK(*lfbs);
if (ndo->ndo_vflag >= 3) {
ND_PRINT((ndo, "\n%s%s(Classid %x) instance %x\n",
- ib, tok2str(ForCES_LFBs, NULL, EXTRACT_32BITS(&lfbs->class)),
- EXTRACT_32BITS(&lfbs->class),
- EXTRACT_32BITS(&lfbs->instance)));
+ ib, tok2str(ForCES_LFBs, NULL, EXTRACT_BE_U_4(&lfbs->class)),
+ EXTRACT_BE_U_4(&lfbs->class),
+ EXTRACT_BE_U_4(&lfbs->instance)));
}
otlv = (const struct forces_tlv *)(lfbs + 1);
* length is large enough but not too large (it doesn't
* go past the end of the containing TLV).
*/
- if (op_valid(EXTRACT_16BITS(&otlv->type), op_msk)) {
+ if (op_valid(EXTRACT_BE_U_2(&otlv->type), op_msk)) {
otlv_print(ndo, otlv, 0, indent);
} else {
if (ndo->ndo_vflag < 3)
ND_PRINT((ndo, "\n"));
ND_PRINT((ndo,
"\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
- EXTRACT_16BITS(&otlv->type), EXTRACT_16BITS(&otlv->length)));
+ EXTRACT_BE_U_2(&otlv->type), EXTRACT_BE_U_2(&otlv->length)));
invoptlv_print(ndo, (const u_char *)otlv, rlen, 0, indent);
}
otlv = GO_NXT_TLV(otlv, rlen);
if (rlen) {
ND_PRINT((ndo,
"\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
- EXTRACT_16BITS(&otlv->type), rlen - EXTRACT_16BITS(&otlv->length)));
+ EXTRACT_BE_U_2(&otlv->type), rlen - EXTRACT_BE_U_2(&otlv->length)));
return -1;
}
static int
forces_type_print(netdissect_options *ndo,
- register const u_char * pptr, const struct forcesh *fhdr _U_,
- register u_int mlen, const struct tom_h *tops)
+ const u_char * pptr, const struct forcesh *fhdr _U_,
+ u_int mlen, const struct tom_h *tops)
{
const struct forces_tlv *tltlv;
u_int rlen;
* length is large enough but not too large (it doesn't
* go past the end of the packet).
*/
- if (!ttlv_valid(EXTRACT_16BITS(&tltlv->type))) {
+ if (!ttlv_valid(EXTRACT_BE_U_2(&tltlv->type))) {
ND_PRINT((ndo, "\n\tInvalid ForCES Top TLV type=0x%x",
- EXTRACT_16BITS(&tltlv->type)));
+ EXTRACT_BE_U_2(&tltlv->type)));
return -1;
}
if (ndo->ndo_vflag >= 3)
ND_PRINT((ndo, "\t%s, length %d (data length %d Bytes)",
- tok2str(ForCES_TLV, NULL, EXTRACT_16BITS(&tltlv->type)),
- EXTRACT_16BITS(&tltlv->length),
- EXTRACT_16BITS(&tltlv->length) - TLV_HDRL));
+ tok2str(ForCES_TLV, NULL, EXTRACT_BE_U_2(&tltlv->type)),
+ EXTRACT_BE_U_2(&tltlv->length),
+ EXTRACT_BE_U_2(&tltlv->length) - TLV_HDRL));
rc = tops->print(ndo, (const u_char *) TLV_DATA(tltlv),
- EXTRACT_16BITS(&tltlv->length), tops->op_msk, 9);
+ EXTRACT_BE_U_2(&tltlv->length),
+ tops->op_msk, 9);
if (rc < 0) {
return -1;
}
*/
if (rlen) {
ND_PRINT((ndo, "\tMess TopTLV header: min %u, total %d advertised %d ",
- TLV_HDRL, rlen, EXTRACT_16BITS(&tltlv->length)));
+ TLV_HDRL, rlen, EXTRACT_BE_U_2(&tltlv->length)));
return -1;
}
void
forces_print(netdissect_options *ndo,
- register const u_char * pptr, register u_int len)
+ const u_char * pptr, u_int len)
{
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;
}
goto error;
}
- ND_TCHECK2(*(pptr + 20), 4);
- flg_raw = EXTRACT_32BITS(pptr + 20);
+ ND_TCHECK_4(pptr + 20);
+ flg_raw = EXTRACT_BE_U_4(pptr + 20);
if (ndo->ndo_vflag >= 1) {
ND_PRINT((ndo, "\n\tForCES Version %d len %uB flags 0x%08x ",
ForCES_V(fhdr), mlen, flg_raw));
"\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64,
ForCES_SID(fhdr), ForCES_node(ForCES_SID(fhdr)),
ForCES_DID(fhdr), ForCES_node(ForCES_DID(fhdr)),
- EXTRACT_64BITS(fhdr->fm_cor)));
+ EXTRACT_BE_U_8(fhdr->fm_cor)));
}
if (ndo->ndo_vflag >= 2) {