]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-forces.c
Use more the ND_TTEST_1() macro
[tcpdump] / print-forces.c
index c5d2e0358465414788f38c7d2fc3610548abbd8e..f6be80c21243b5af6322edc1996551705e865ab5 100644 (file)
@@ -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);
 };
 
@@ -154,23 +154,23 @@ static const struct tok ForCES_TPs[] = {
  */
 struct forcesh {
        nd_uint8_t fm_vrsvd;    /* version and reserved */
-#define ForCES_V(forcesh)      ((forcesh)->fm_vrsvd >> 4)
+#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))
+#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)
+#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)
+#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_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 && \
@@ -230,15 +230,15 @@ 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
@@ -440,13 +440,13 @@ static inline int ilv_valid(const struct forces_ilv *ilv, u_int rlen)
        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 {
@@ -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);
 };
 
@@ -549,13 +549,13 @@ struct res_val {
        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 = (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)
@@ -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 = (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;
 
        /*
@@ -714,7 +716,7 @@ 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;
@@ -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 = (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) {
@@ -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 = (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;
 
        /*
@@ -789,19 +791,19 @@ 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 = (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);
+       ND_TCHECK_1(tdp);
        id = EXTRACT_BE_U_4(tdp);
        ND_PRINT((ndo, "%sKeyinfo: Key 0x%x\n", ib, id));
        ND_TCHECK(*kdtlv);
@@ -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,7 +845,7 @@ 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_BE_U_4(pptr);
@@ -987,7 +989,7 @@ 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 = (const struct pathdata_h *)pptr;
@@ -1051,7 +1053,7 @@ 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 = (const struct forces_tlv *)pptr;
@@ -1072,7 +1074,7 @@ genoptlv_print(netdissect_options *ndo,
                 * 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,
@@ -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 = (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) {
@@ -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,7 +1171,7 @@ 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 = (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);
@@ -1212,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;
@@ -1228,7 +1230,7 @@ asttlv_print(netdissect_options *ndo,
                ND_PRINT((ndo, "illegal ASTresult-TLV: %d bytes!\n", dlen));
                return -1;
        }
-       ND_TCHECK2(*pptr, 4);
+       ND_TCHECK_4(pptr);
        rescode = EXTRACT_BE_U_4(pptr);
        if (rescode > ASTMCD) {
                ND_PRINT((ndo, "illegal ASTresult result code: %d!\n", rescode));
@@ -1270,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;
@@ -1286,7 +1288,7 @@ asrtlv_print(netdissect_options *ndo,
                ND_PRINT((ndo, "illegal ASRresult-TLV: %d bytes!\n", dlen));
                return -1;
        }
-       ND_TCHECK2(*pptr, 4);
+       ND_TCHECK_4(pptr);
        rescode = EXTRACT_BE_U_4(pptr);
 
        if (rescode > ASRMCD) {
@@ -1325,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;
@@ -1342,7 +1344,7 @@ 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);
@@ -1370,7 +1372,7 @@ 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;
@@ -1412,7 +1414,7 @@ trunc:
 
 static int
 print_reddata(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;
@@ -1434,7 +1436,7 @@ 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 = (const struct forces_tlv *)pptr;
@@ -1505,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;
@@ -1584,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;
@@ -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,7 +1710,7 @@ forces_print(netdissect_options *ndo,
                goto error;
        }
 
-       ND_TCHECK2(*(pptr + 20), 4);
+       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 ",