X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/ed85e20e4d6a27d5405f37366dd34b64c10a9211..1a04b92e365f5ed01ca38619b41bcc4fc9cbd63c:/print-forces.c diff --git a/print-forces.c b/print-forces.c index 45bd74f9..f6be80c2 100644 --- a/print-forces.c +++ b/print-forces.c @@ -14,21 +14,21 @@ * */ -#define NETDISSECT_REWORKED +/* \summary: Forwarding and Control Element Separation (ForCES) Protocol printer */ + +/* specification: RFC 5810 */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include +#include -#include "interface.h" +#include "netdissect.h" #include "extract.h" static const char tstr[] = "[|forces]"; -/* - * Per draft-ietf-forces-protocol-22 -*/ #define ForCES_VERS 1 #define ForCES_HDRL 24 #define ForCES_ALNL 4U @@ -66,7 +66,7 @@ struct tom_h { 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); }; @@ -153,24 +153,24 @@ static const struct tok ForCES_TPs[] = { * 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 && \ @@ -187,26 +187,28 @@ static const struct tok ForCES_LFBs[] = { {0, NULL} }; +/* this is defined in RFC5810 section A.2 */ +/* http://www.iana.org/assignments/forces/forces.xhtml#oper-tlv-types */ enum { - F_OP_RSV, - F_OP_SET, - F_OP_SETPROP, - F_OP_SETRESP, - F_OP_SETPRESP, - F_OP_DEL, - F_OP_DELRESP, - F_OP_GET, - F_OP_GETPROP, - F_OP_GETRESP, - F_OP_GETPRESP, - F_OP_REPORT, - F_OP_COMMIT, - F_OP_RCOMMIT, - F_OP_RTRCOMP, + F_OP_RSV = 0, + F_OP_SET = 1, + F_OP_SETPROP = 2, + F_OP_SETRESP = 3, + F_OP_SETPRESP = 4, + F_OP_DEL = 5, + F_OP_DELRESP = 6, + F_OP_GET = 7, + F_OP_GETPROP = 8, + F_OP_GETRESP = 9, + F_OP_GETPRESP = 10, + F_OP_REPORT = 11, + F_OP_COMMIT = 12, + F_OP_RCOMMIT = 13, + F_OP_RTRCOMP = 14, _F_OP_MAX }; - #define F_OP_MAX (_F_OP_MAX - 1) + enum { B_OP_SET = 1 << (F_OP_SET - 1), B_OP_SETPROP = 1 << (F_OP_SETPROP - 1), @@ -221,28 +223,28 @@ enum { B_OP_REPORT = 1 << (F_OP_REPORT - 1), B_OP_COMMIT = 1 << (F_OP_COMMIT - 1), B_OP_RCOMMIT = 1 << (F_OP_RCOMMIT - 1), - B_OP_RTRCOMP = 1 << (F_OP_RTRCOMP - 1), + B_OP_RTRCOMP = 1 << (F_OP_RTRCOMP - 1) }; struct optlv_h { 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 @@ -276,7 +278,7 @@ static const struct optlv_h OPTLV_msg[F_OP_MAX + 1] = { 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]; @@ -286,7 +288,7 @@ static inline const struct optlv_h *get_forces_optlv_h(uint16_t 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) { @@ -311,12 +313,10 @@ 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; @@ -374,31 +374,31 @@ static inline int ttlv_valid(uint16_t ttlv) } 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) ((struct forces_tlv *)((fhdr) + sizeof (struct forcesh))) +#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_DATA(tlvp) ((void*)(((char*)(tlvp)) + TLV_SET_LEN(0))) -#define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length)), \ - (struct forces_tlv*)(((char*)(tlv)) \ - + F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length)))) +#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_BE_U_2(&(tlv)->length)), \ + (const struct forces_tlv*)(((const char*)(tlv)) \ + + 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_DATA(ilvp) ((void*)(((char*)(ilvp)) + ILV_SET_LEN(0))) -#define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length)), \ - (struct forces_ilv *)(((char*)(ilv)) \ - + F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length)))) +#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_BE_U_4(&(ilv)->length)), \ + (const struct forces_ilv *)(((const char*)(ilv)) \ + + F_ALN_LEN(EXTRACT_BE_U_4(&(ilv)->length)))) #define INVALID_RLEN 1 #define INVALID_STLN 2 #define INVALID_LTLN 3 @@ -416,11 +416,11 @@ static inline u_int tlv_valid(const struct forces_tlv *tlv, u_int rlen) { 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; @@ -430,28 +430,28 @@ static inline int ilv_valid(const struct forces_ilv *ilv, u_int rlen) { 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) @@ -498,7 +498,7 @@ struct pdata_ops { 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); }; @@ -544,18 +544,18 @@ chk_op_type(netdissect_options *ndo, #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] = { @@ -641,13 +641,14 @@ static const struct tok ForCES_errs[] = { 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 = (struct forces_tlv *)pptr; - register const u_char *tdp = (u_char *) TLV_DATA(tlv); - struct res_val *r = (struct res_val *)tdp; + const struct forces_tlv *tlv = (const struct forces_tlv *)pptr; + const u_char *tdp = (const u_char *) TLV_DATA(tlv); + const struct res_val *r = (const struct res_val *)tdp; u_int dlen; + uint8_t result; /* * pdatacnt_print() has ensured that len (the TLV length) @@ -660,15 +661,16 @@ prestlv_print(netdissect_options *ndo, } ND_TCHECK(*r); - if (r->result >= 0x18 && r->result <= 0xFE) { - ND_PRINT((ndo, "illegal reserved result code: 0x%x!\n", r->result)); + result = EXTRACT_U_1(r->result); + if (result >= 0x18 && result <= 0xFE) { + ND_PRINT((ndo, "illegal reserved result code: 0x%x!\n", result)); return -1; } if (ndo->ndo_vflag >= 3) { char *ib = indent_pr(indent, 0); ND_PRINT((ndo, "%s Result: %s (code 0x%x)\n", ib, - tok2str(ForCES_errs, NULL, r->result), r->result)); + tok2str(ForCES_errs, NULL, result), result)); } return 0; @@ -679,12 +681,12 @@ trunc: 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 = (struct forces_tlv *)pptr; + const struct forces_tlv *tlv = (const struct forces_tlv *)pptr; u_int rlen; - register const u_char *tdp = (u_char *) TLV_DATA(tlv); + const u_char *tdp = (const u_char *) TLV_DATA(tlv); uint16_t type; /* @@ -693,7 +695,7 @@ fdatatlv_print(netdissect_options *ndo, */ 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; @@ -714,11 +716,11 @@ trunc: 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; - const struct forces_ilv *ilv = (struct forces_ilv *)pptr; + const struct forces_ilv *ilv = (const struct forces_ilv *)pptr; int invilv; if (len < ILV_HDRL) { @@ -732,7 +734,7 @@ sdatailv_print(netdissect_options *ndo, ND_PRINT((ndo, "Jamal - outstanding length <%d>\n", rlen)); #endif char *ib = indent_pr(indent, 1); - register const u_char *tdp = (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) { @@ -742,9 +744,9 @@ sdatailv_print(netdissect_options *ndo, 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); } @@ -760,12 +762,12 @@ trunc: 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 = (struct forces_tlv *)pptr; + const struct forces_tlv *tlv = (const struct forces_tlv *)pptr; u_int rlen; - register const u_char *tdp = (u_char *) TLV_DATA(tlv); + const u_char *tdp = (const u_char *) TLV_DATA(tlv); uint16_t type; /* @@ -774,7 +776,7 @@ sdatatlv_print(netdissect_options *ndo, */ 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; @@ -789,29 +791,29 @@ trunc: 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 = (struct forces_tlv *)pptr; - register const u_char *tdp = (u_char *) TLV_DATA(tlv); - register const u_char *dp = tdp + 4; - const struct forces_tlv *kdtlv = (struct forces_tlv *)dp; + const struct forces_tlv *tlv = (const struct forces_tlv *)pptr; + 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; } /* @@ -819,8 +821,8 @@ pkeyitlv_print(netdissect_options *ndo, * length is large enough but not too large (it doesn't * go past the end of the containing TLV). */ - tll = EXTRACT_16BITS(&kdtlv->length); - dp = (u_char *) TLV_DATA(kdtlv); + tll = EXTRACT_BE_U_2(&kdtlv->length); + dp = (const u_char *) TLV_DATA(kdtlv); return fdatatlv_print(ndo, dp, tll, op_msk, indent); trunc: @@ -832,7 +834,7 @@ trunc: 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; @@ -843,10 +845,10 @@ pdatacnt_print(netdissect_options *ndo, 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; @@ -866,11 +868,11 @@ pdatacnt_print(netdissect_options *ndo, 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; @@ -879,7 +881,7 @@ pdatacnt_print(netdissect_options *ndo, } if (op_msk & B_KEYIN) { - struct forces_tlv *keytlv; + const struct forces_tlv *keytlv; uint16_t tll; if (len < PTH_DESC_SIZE) { @@ -891,12 +893,12 @@ pdatacnt_print(netdissect_options *ndo, /* skip keyid */ pptr += 4; len -= 4; - keytlv = (struct forces_tlv *)pptr; + keytlv = (const struct forces_tlv *)pptr; /* skip header */ 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)); @@ -914,7 +916,7 @@ pdatacnt_print(netdissect_options *ndo, } if (len) { - const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr; + const struct forces_tlv *pdtlv = (const struct forces_tlv *)pptr; uint16_t type; uint16_t tll; int pad = 0; @@ -922,12 +924,12 @@ pdatacnt_print(netdissect_options *ndo, 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; } /* @@ -935,15 +937,15 @@ pdatacnt_print(netdissect_options *ndo, * 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)) { @@ -952,10 +954,10 @@ pdatacnt_print(netdissect_options *ndo, 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); @@ -967,9 +969,9 @@ pdatacnt_print(netdissect_options *ndo, 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")); @@ -987,10 +989,10 @@ trunc: 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 = (struct pathdata_h *)pptr; + const struct pathdata_h *pdh = (const struct pathdata_h *)pptr; char *ib = indent_pr(indent, 0); u_int minsize = 0; int more_pd = 0; @@ -1001,25 +1003,25 @@ pdata_print(netdissect_options *ndo, 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, @@ -1051,38 +1053,38 @@ trunc: 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 = (struct forces_tlv *)pptr; + const struct forces_tlv *pdtlv = (const struct forces_tlv *)pptr; uint16_t type; int tll; u_int invtlv; 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 = (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 { @@ -1097,14 +1099,14 @@ trunc: 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 = (struct forces_tlv *)pptr; + 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) { @@ -1120,15 +1122,15 @@ recpdoptlv_print(netdissect_options *ndo, * go past the end of the containing TLV). */ ib = indent_pr(indent, 0); - type = EXTRACT_16BITS(&pdtlv->type); - dp = (u_char *) TLV_DATA(pdtlv); - tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL; + type = EXTRACT_BE_U_2(&pdtlv->type); + dp = (const u_char *) TLV_DATA(pdtlv); + 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; @@ -1138,7 +1140,7 @@ recpdoptlv_print(netdissect_options *ndo, 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; } @@ -1151,7 +1153,7 @@ trunc: 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); @@ -1169,41 +1171,38 @@ otlv_print(netdissect_options *ndo, const struct forces_tlv *otlv, uint16_t op_msk _U_, int indent) { int rc = 0; - register const u_char *dp = (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))); - } - /* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */ - if (!ops->flags & ZERO_TTLV) { - if (tll != 0) /* instead of "if (tll)" - for readability .. */ - ND_PRINT((ndo, "%s: Illegal - MUST be empty\n", ops->s)); - return rc; + 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); } - rc = ops->print(ndo, dp, tll, ops->op_msk, indent + 1); + /* XXX - do anything with ops->flags? */ + if(ops->print) { + rc = ops->print(ndo, dp, tll, ops->op_msk, indent + 1); + } return rc; trunc: @@ -1215,7 +1214,7 @@ trunc: #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; @@ -1231,8 +1230,8 @@ asttlv_print(netdissect_options *ndo, 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; @@ -1273,7 +1272,7 @@ trunc: #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; @@ -1289,8 +1288,8 @@ asrtlv_print(netdissect_options *ndo, 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)); @@ -1328,7 +1327,7 @@ trunc: */ 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; @@ -1345,21 +1344,21 @@ gentltlv_print(netdissect_options *ndo, 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); /* XXX: check header length */ - const struct forces_ilv *ilv = (struct forces_ilv *)pptr; + const struct forces_ilv *ilv = (const struct forces_ilv *)pptr; /* * 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")); @@ -1373,13 +1372,13 @@ trunc: 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; char *ib = indent_pr(indent, 0); u_int rlen; - const struct forces_ilv *ilv = (struct forces_ilv *)pptr; + const struct forces_ilv *ilv = (const struct forces_ilv *)pptr; int invilv; /* @@ -1401,7 +1400,7 @@ print_metatlv(netdissect_options *ndo, * length is large enough but not too large (it doesn't * go past the end of the containing TLV). */ - print_metailv(ndo, (u_char *) ilv, 0, indent + 1); + print_metailv(ndo, (const u_char *) ilv, 0, indent + 1); ilv = GO_NXT_ILV(ilv, rlen); } @@ -1415,8 +1414,8 @@ trunc: 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); @@ -1437,10 +1436,10 @@ print_reddata(netdissect_options *ndo, 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 = (struct forces_tlv *)pptr; + const struct forces_tlv *tlv = (const struct forces_tlv *)pptr; u_int dlen; u_int rlen; u_int invtlv; @@ -1471,16 +1470,18 @@ redirect_print(netdissect_options *ndo, * 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) { - print_metatlv(ndo, (u_char *) TLV_DATA(tlv), - EXTRACT_16BITS(&tlv->length), 0, indent); - } else if ((EXTRACT_16BITS(&tlv->type) == F_TLV_REDD)) { - print_reddata(ndo, (u_char *) TLV_DATA(tlv), - EXTRACT_16BITS(&tlv->length), 0, indent); + if (EXTRACT_BE_U_2(&tlv->type) == F_TLV_METD) { + print_metatlv(ndo, (const u_char *) TLV_DATA(tlv), + 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_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); @@ -1489,8 +1490,8 @@ redirect_print(netdissect_options *ndo, 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; } @@ -1506,7 +1507,7 @@ trunc: 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; @@ -1537,12 +1538,12 @@ lfbselect_print(netdissect_options *ndo, 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 = (struct forces_tlv *)(lfbs + 1); + otlv = (const struct forces_tlv *)(lfbs + 1); indent += 1; while (rlen != 0) { @@ -1556,15 +1557,15 @@ lfbselect_print(netdissect_options *ndo, * 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))); - invoptlv_print(ndo, (u_char *)otlv, rlen, 0, indent); + 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); } @@ -1572,7 +1573,7 @@ lfbselect_print(netdissect_options *ndo, 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; } @@ -1585,8 +1586,8 @@ trunc: 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; @@ -1634,20 +1635,21 @@ forces_type_print(netdissect_options *ndo, * 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, (u_char *) TLV_DATA(tltlv), - EXTRACT_16BITS(&tltlv->length), tops->op_msk, 9); + rc = tops->print(ndo, (const u_char *) TLV_DATA(tltlv), + EXTRACT_BE_U_2(&tltlv->length), + tops->op_msk, 9); if (rc < 0) { return -1; } @@ -1662,7 +1664,7 @@ forces_type_print(netdissect_options *ndo, */ 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; } @@ -1675,26 +1677,28 @@ trunc: 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; } @@ -1706,8 +1710,8 @@ forces_print(netdissect_options *ndo, 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)); @@ -1715,7 +1719,7 @@ forces_print(netdissect_options *ndo, "\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) {