]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Constify a bunch of stuff.
authorGuy Harris <[email protected]>
Wed, 27 Jan 2010 04:14:23 +0000 (20:14 -0800)
committerGuy Harris <[email protected]>
Wed, 27 Jan 2010 04:14:23 +0000 (20:14 -0800)
forces.h
print-forces.c

index 7ee4be3703283e48ce38ba0d2a2d4d5ae021dfee..092a30b1501b09d777abc46d66d4323763d6846e 100644 (file)
--- a/forces.h
+++ b/forces.h
@@ -223,7 +223,7 @@ struct forcesh {
 #define F_LFB_RSVD 0x0
 #define F_LFB_FEO 0x1
 #define F_LFB_FEPO 0x2
-struct tok ForCES_LFBs[] = {
+const struct tok ForCES_LFBs[] = {
        {F_LFB_RSVD, "Invalid TLV"},
        {F_LFB_FEO, "FEObj LFB"},
        {F_LFB_FEPO, "FEProtoObj LFB"},
@@ -231,7 +231,7 @@ struct tok ForCES_LFBs[] = {
 };
 
 int forces_type_print(register const u_char * pptr, const struct forcesh *fhdr,
-                 register u_int mlen, struct tom_h *tops);
+                 register u_int mlen, const struct tom_h *tops);
 
 enum {
        F_OP_RSV,
@@ -296,7 +296,7 @@ struct pathdata_h {
 #define B_RESTV                0x4
 #define B_KEYIN                0x8
 
-static struct optlv_h OPTLV_msg[F_OP_MAX + 1] = {
+static const struct optlv_h OPTLV_msg[F_OP_MAX + 1] = {
        /* F_OP_RSV */ {ZERO_TTLV, 0, "Invalid OPTLV", invoptlv_print},
        /* F_OP_SET */ {TTLV_T2, B_FULLD | B_SPARD, " Set", recpdoptlv_print},
        /* F_OP_SETPROP */
@@ -318,7 +318,7 @@ static struct optlv_h OPTLV_msg[F_OP_MAX + 1] = {
        /* F_OP_RTRCOMP */ {ZERO_TTLV, 0, " RTRCOMP", NULL},
 };
 
-static inline struct optlv_h *get_forces_optlv_h(u_int16_t opt)
+static inline const struct optlv_h *get_forces_optlv_h(u_int16_t opt)
 {
        if (opt > F_OP_MAX || opt <= F_OP_RSV)
                return &OPTLV_msg[F_OP_RSV];
@@ -381,7 +381,7 @@ static inline int op_valid(u_int16_t op, u_int16_t mask)
 #define F_TLV_REDD     0x0116
 #define F_TLV_VNST     0x8000
 
-static struct tok ForCES_TLV[] = {
+static const struct tok ForCES_TLV[] = {
        {F_TLV_RSVD, "Invalid TLV"},
        {F_TLV_REDR, "REDIRECT TLV"},
        {F_TLV_ASRS, "ASResult TLV"},
@@ -424,7 +424,7 @@ struct forces_tlv {
        u_int16_t length;
 };
 
-int otlv_print(struct forces_tlv *otlv, u_int16_t op_msk, int indent);
+int otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk, int indent);
 
 #define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
 #define        GET_TOP_TLV(fhdr) ((struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
@@ -447,7 +447,7 @@ int otlv_print(struct forces_tlv *otlv, u_int16_t op_msk, int indent);
 #define INVALID_LTLN -3
 #define INVALID_ALEN -4
 
-static struct tok ForCES_TLV_err[] = {
+static const struct tok ForCES_TLV_err[] = {
        {INVALID_RLEN, "Invalid total length"},
        {INVALID_STLN, "xLV too short"},
        {INVALID_LTLN, "xLV too long"},
@@ -455,7 +455,7 @@ static struct tok ForCES_TLV_err[] = {
        {0, NULL}
 };
 
-static inline int tlv_valid(struct forces_tlv *tlv, u_int rlen)
+static inline int tlv_valid(const struct forces_tlv *tlv, u_int rlen)
 {
        if (rlen < (int) sizeof(struct forces_tlv))
                return INVALID_RLEN;
@@ -469,7 +469,7 @@ static inline int tlv_valid(struct forces_tlv *tlv, u_int rlen)
        return 0;
 }
 
-static inline int ilv_valid(struct forces_ilv *ilv, u_int rlen)
+static inline int ilv_valid(const struct forces_ilv *ilv, u_int rlen)
 {
        if (rlen < sizeof(struct forces_ilv))
                return INVALID_RLEN;
@@ -495,7 +495,7 @@ struct forces_lfbsh {
 #define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP)
 #define CFG_EVN (B_OP_REPORT)
 
-static struct tom_h ForCES_msg[TOM_MAX_IND + 1] = {
+static const struct tom_h ForCES_msg[TOM_MAX_IND + 1] = {
        /* TOM_RSV_I */ {TOM_RSVD, ZERO_TTLV, 0, "Invalid message", NULL},
        /* TOM_ASS_I */ {TOM_ASSNSETUP, ZERO_MORE_TTLV | TWO_TLV, ASSNS_OPS,
                       "Association Setup", lfbselect_print},
@@ -516,11 +516,11 @@ static struct tom_h ForCES_msg[TOM_MAX_IND + 1] = {
            {TOM_QUERYREP, TTLV_T2, CFG_QYR, "Query Response", lfbselect_print},
 };
 
-static inline struct tom_h *get_forces_tom(u_int8_t tom)
+static inline const struct tom_h *get_forces_tom(u_int8_t tom)
 {
        int i;
        for (i = TOM_RSV_I; i <= TOM_MAX_IND; i++) {
-               struct tom_h *th = &ForCES_msg[i];
+               const struct tom_h *th = &ForCES_msg[i];
                if (th->v == tom)
                        return th;
        }
@@ -599,7 +599,7 @@ struct res_val {
        u_int16_t resv2;
 };
 
-static struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = {
+static const struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = {
        /* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL},
        /* PD_SEL_I */ {F_TLV_KEYI, 0, 0, "KEYINFO TLV", pkeyitlv_print},
        /* PD_FDT_I */ {F_TLV_FULD, 0, B_FULLD, "FULLDATA TLV", fdatatlv_print},
@@ -609,11 +609,11 @@ static struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = {
            {F_TLV_PDAT, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print},
 };
 
-static inline struct pdata_ops *get_forces_pd(u_int16_t pd)
+static inline const struct pdata_ops *get_forces_pd(u_int16_t pd)
 {
        int i;
        for (i = PD_RSV_I + 1; i <= PD_MAX_IND; i++) {
-               struct pdata_ops *pdo = &ForCES_pdata[i];
+               const struct pdata_ops *pdo = &ForCES_pdata[i];
                if (pdo->v == pd)
                        return pdo;
        }
@@ -649,7 +649,7 @@ enum {
        E_UNSPECIFIED_ERROR = 0XFF
 };
 
-struct tok ForCES_errs[] = {
+const struct tok ForCES_errs[] = {
        {E_SUCCESS, "SUCCESS"},
        {E_INVALID_HEADER, "INVALID HEADER"},
        {E_LENGTH_MISMATCH, "LENGTH MISMATCH"},
index ed0cf559346782b2dd4502c1417e5339c40aa235..760d3b1b7a6aa13ef2a67e34be72fcb64a92b6d6 100644 (file)
@@ -34,7 +34,7 @@ int
 prestlv_print(register const u_char * pptr, register u_int len,
              u_int16_t op_msk _U_, int indent)
 {
-       struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+       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;
        u_int dlen = len - TLV_HDRL;
@@ -66,7 +66,7 @@ int
 fdatatlv_print(register const u_char * pptr, register u_int len,
               u_int16_t op_msk _U_, int indent)
 {
-       struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+       const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
        u_int tll = len - TLV_HDRL;
        register const u_char *tdp = (u_char *) TLV_DATA(tlv);
        u_int16_t type;
@@ -96,7 +96,7 @@ sdatailv_print(register const u_char * pptr, register u_int len,
               u_int16_t op_msk _U_, int indent)
 {
        u_int tll = len - ILV_HDRL;
-       struct forces_ilv *ilv = (struct forces_ilv *)pptr;
+       const struct forces_ilv *ilv = (struct forces_ilv *)pptr;
        int invilv;
 
        indent += 1;
@@ -132,7 +132,7 @@ int
 sdatatlv_print(register const u_char * pptr, register u_int len,
               u_int16_t op_msk, int indent)
 {
-       struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+       const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
        u_int tll = len - TLV_HDRL;
        register const u_char *tdp = (u_char *) TLV_DATA(tlv);
        u_int16_t type;
@@ -155,10 +155,10 @@ int
 pkeyitlv_print(register const u_char * pptr, register u_int len,
               u_int16_t op_msk, int indent)
 {
-       struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+       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;
-       struct forces_tlv *kdtlv = (struct forces_tlv *)dp;
+       const struct forces_tlv *kdtlv = (struct forces_tlv *)dp;
        u_int32_t id;
        char *ib = indent_pr(indent, 0);
        u_int16_t type, tll;
@@ -204,7 +204,7 @@ pdatacnt_print(register const u_char * pptr, register u_int len,
                pptr += 4;
        }
        if (len) {
-               struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
+               const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
                u_int16_t type;
                u_int16_t tll;
                int pad = 0;
@@ -233,7 +233,7 @@ pdatacnt_print(register const u_char * pptr, register u_int len,
                        }
                }
                if (pd_valid(type)) {
-                       struct pdata_ops *ops = get_forces_pd(type);
+                       const struct pdata_ops *ops = get_forces_pd(type);
 
                        if (vflag >= 3 && ops->v != F_TLV_PDAT) {
                                if (pad)
@@ -277,7 +277,7 @@ int
 pdata_print(register const u_char * pptr, register u_int len,
            u_int16_t op_msk, int indent)
 {
-       struct pathdata_h *pdh = (struct pathdata_h *)pptr;
+       const struct pathdata_h *pdh = (struct pathdata_h *)pptr;
        char *ib = indent_pr(indent, 0);
        u_int minsize = 0;
 
@@ -311,7 +311,7 @@ int
 genoptlv_print(register const u_char * pptr, register u_int len,
               u_int16_t op_msk, int indent)
 {
-       struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
+       const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
        u_int16_t type;
        int tll;
        int invtlv;
@@ -351,7 +351,7 @@ int
 recpdoptlv_print(register const u_char * pptr, register u_int len,
                 u_int16_t op_msk, int indent)
 {
-       struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
+       const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
        int tll = len;
        int rc = 0;
        int invtlv;
@@ -400,6 +400,7 @@ invoptlv_print(register const u_char * pptr, register u_int len,
               u_int16_t op_msk _U_, int indent)
 {
        char *ib = indent_pr(indent, 1);
+
        if (vflag >= 3) {
                printf("%sData[", &ib[1]);
                hex_print_with_offset(ib, pptr, len, 0);
@@ -408,14 +409,14 @@ invoptlv_print(register const u_char * pptr, register u_int len,
        return -1;
 }
 
-int otlv_print(struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent)
+int otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent)
 {
        int rc = 0;
        register const u_char *dp = (u_char *) TLV_DATA(otlv);
        u_int16_t type;
        int tll;
        char *ib = indent_pr(indent, 0);
-       struct optlv_h *ops;
+       const struct optlv_h *ops;
 
        TCHECK(*otlv);
        type = EXTRACT_16BITS(&otlv->type);
@@ -455,10 +456,10 @@ int
 asttlv_print(register const u_char * pptr, register u_int len,
             u_int16_t op_msk _U_, int indent)
 {
-
        u_int32_t rescode;
        u_int dlen = len - TLV_HDRL;
        char *ib = indent_pr(indent, 0);
+
        if (dlen != ASTDLN) {
                printf("illegal ASTresult-TLV: %d bytes!\n", dlen);
                return -1;
@@ -507,7 +508,6 @@ int
 asrtlv_print(register const u_char * pptr, register u_int len,
             u_int16_t op_msk _U_, int indent)
 {
-
        u_int32_t rescode;
        u_int dlen = len - TLV_HDRL;
        char *ib = indent_pr(indent, 0);
@@ -554,6 +554,7 @@ gentltlv_print(register const u_char * pptr _U_, register u_int len,
               u_int16_t op_msk _U_, int indent _U_)
 {
        u_int dlen = len - TLV_HDRL;
+
        if (dlen < 4) {         /* at least 32 bits must exist */
                printf("truncated TLV: %d bytes missing! ", 4 - dlen);
                return -1;
@@ -570,7 +571,7 @@ print_metailv(register const u_char * pptr, register u_int len,
        int tll = dlen;
        char *ib = indent_pr(indent, 0);
        /* XXX: check header length */
-       struct forces_ilv *ilv = (struct forces_ilv *)pptr;
+       const struct forces_ilv *ilv = (struct forces_ilv *)pptr;
 
        TCHECK(*ilv);
        printf("\n%sMetaID 0x%x length %d\n", ib, EXTRACT_32BITS(&ilv->type),
@@ -590,7 +591,7 @@ print_metatlv(register const u_char * pptr, register u_int len,
        u_int dlen = len - TLV_HDRL;
        char *ib = indent_pr(indent, 0);
        u_int tll = dlen;
-       struct forces_ilv *ilv = (struct forces_ilv *)pptr;
+       const struct forces_ilv *ilv = (struct forces_ilv *)pptr;
        int invilv;
 
        printf("\n%s METADATA\n", ib);
@@ -620,7 +621,7 @@ print_reddata(register const u_char * pptr, register u_int len,
        u_int dlen = len - TLV_HDRL;
        u_int tll = dlen;
        int invtlv;
-       struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+       const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
 
        printf("\n\t\t Redirect DATA\n");
        if (dlen <= RD_MIN) {
@@ -651,7 +652,7 @@ int
 redirect_print(register const u_char * pptr, register u_int len,
               u_int16_t op_msk _U_, int indent)
 {
-       struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+       const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
        u_int dlen = len - TLV_HDRL;
        u_int tll = dlen;
        int invtlv;
@@ -702,7 +703,7 @@ lfbselect_print(register const u_char * pptr, register u_int len,
                u_int16_t op_msk, int indent)
 {
        const struct forces_lfbsh *lfbs;
-       struct forces_tlv *otlv;
+       const struct forces_tlv *otlv;
        char *ib = indent_pr(indent, 0);
        u_int dlen = len - TLV_HDRL;
        u_int tll = dlen - OP_OFF;
@@ -760,9 +761,9 @@ trunc:
 
 int
 forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
-                 register u_int mlen, struct tom_h *tops)
+                 register u_int mlen, const struct tom_h *tops)
 {
-       struct forces_tlv *tltlv;
+       const struct forces_tlv *tltlv;
        u_int tll;
        int invtlv;
        int rc = 0;
@@ -838,7 +839,7 @@ void forces_print(register const u_char * pptr, register u_int len)
        const struct forcesh *fhdr;
        u_int mlen;
        u_int32_t flg_raw;
-       struct tom_h *tops;
+       const struct tom_h *tops;
        int rc = 0;
 
        fhdr = (const struct forcesh *)pptr;