]> The Tcpdump Group git mirrors - tcpdump/commitdiff
make more array declarations static/const
authorDenis Ovsienko <[email protected]>
Thu, 19 Dec 2013 10:05:59 +0000 (14:05 +0400)
committerDenis Ovsienko <[email protected]>
Thu, 19 Dec 2013 10:25:01 +0000 (14:25 +0400)
13 files changed:
print-cdp.c
print-cip.c
print-egp.c
print-fddi.c
print-fr.c
print-isakmp.c
print-juniper.c
print-mptcp.c
print-rx.c
print-smb.c
print-snmp.c
print-wb.c
tcpdump.c

index 152b2f9878ccba1bf2652a865e653e5fe3510293..50c1d9da8db3ab7d4cb2d30d5b03bc533cc3ab60 100644 (file)
@@ -252,7 +252,7 @@ cdp_print_addr(const u_char * p, int l)
        int pt, pl, al, num;
        const u_char *endp = p + l;
 #ifdef INET6
-       static u_char prot_ipv6[] = {
+       static const u_char prot_ipv6[] = {
                0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd
        };
 #endif
index e9d672fe761b5f0bb80fe2845bae93bd2b369083..1a8d1054c63ba6bf43f17066344b4e9f031da75b 100644 (file)
@@ -43,7 +43,7 @@ static const char rcsid[] _U_ =
 
 #define RFC1483LLC_LEN 8
 
-static unsigned char rfcllc[] = {
+static const unsigned char rfcllc[] = {
        0xaa,   /* DSAP: non-ISO */
        0xaa,   /* SSAP: non-ISO */
        0x03,   /* Ctrl: Unnumbered Information Command PDU */
index 4a1d046531be37a9bcc8ac2b0426e98ce426963c..bea2996ce3e8d504de2a8a75862ee31721d1d1ee 100644 (file)
@@ -94,7 +94,7 @@ struct egp_packet {
 #define  egp_sourcenet  egp_pands.egpu_sourcenet
 };
 
-const char *egp_acquire_codes[] = {
+static const char *egp_acquire_codes[] = {
        "request",
        "confirm",
        "refuse",
@@ -102,7 +102,7 @@ const char *egp_acquire_codes[] = {
        "cease_ack"
 };
 
-const char *egp_acquire_status[] = {
+static const char *egp_acquire_status[] = {
        "unspecified",
        "active_mode",
        "passive_mode",
@@ -113,18 +113,18 @@ const char *egp_acquire_status[] = {
        "protocol_violation"
 };
 
-const char *egp_reach_codes[] = {
+static const char *egp_reach_codes[] = {
        "hello",
        "i-h-u"
 };
 
-const char *egp_status_updown[] = {
+static const char *egp_status_updown[] = {
        "indeterminate",
        "up",
        "down"
 };
 
-const char *egp_reasons[] = {
+static const char *egp_reasons[] = {
        "unspecified",
        "bad_EGP_header_format",
        "bad_EGP_data_field_format",
index 1e7d554ad7104268ef61f4276de0b5468801dc64..f34f766f85443d1e91c9c0a5d45b3ddb5a6bd5df 100644 (file)
@@ -80,7 +80,7 @@ int   fddi_bitswap = 1;
  *  - vj
  */
 
-static u_char fddi_bit_swap[] = {
+static const u_char fddi_bit_swap[] = {
        0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
        0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
        0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
index 9fb763ccf1b6aa17f67fa62e62b3f980d5fc7b79..83a477880a88c28b31bf9bb3f99759e3376e8ac7 100644 (file)
@@ -704,7 +704,7 @@ typedef int (*codeset_pr_func_t)(const struct ie_tlv_header_t  *ie_p,
     const u_char *p);
 
 /* array of 16 codepages - currently we only support codepage 1,5 */
-static codeset_pr_func_t fr_q933_print_ie_codeset[] = {
+static const codeset_pr_func_t fr_q933_print_ie_codeset[] = {
     NULL,
     fr_q933_print_ie_codeset5,
     NULL,
index c40b6e70ae73ed53291189eacef28f13657c14b9..5b212b99fe6484cd4d4b959b2f496a98eb757305 100644 (file)
@@ -691,7 +691,7 @@ static const char *ipcomp_p_map[] = {
        NULL, "oui", "deflate", "lzs",
 };
 
-const struct attrmap ipsec_t_map[] = {
+static const struct attrmap ipsec_t_map[] = {
        { NULL, 0, { NULL } },
        { "lifetype", 3, { NULL, "sec", "kb", }, },
        { "life", 0, { NULL } },
@@ -718,7 +718,7 @@ const struct attrmap ipsec_t_map[] = {
        { "privalg", 0, { NULL } },
 };
 
-const struct attrmap encr_t_map[] = {
+static const struct attrmap encr_t_map[] = {
        { NULL, 0, { NULL } },  { NULL, 0, { NULL } },  /* 0, 1 */
        { NULL, 0, { NULL } },  { NULL, 0, { NULL } },  /* 2, 3 */
        { NULL, 0, { NULL } },  { NULL, 0, { NULL } },  /* 4, 5 */
@@ -729,7 +729,7 @@ const struct attrmap encr_t_map[] = {
        { "keylen", 14, { NULL }},
 };
 
-const struct attrmap oakley_t_map[] = {
+static const struct attrmap oakley_t_map[] = {
        { NULL, 0, { NULL } },
        { "enc", 8,     { NULL, "1des", "idea", "blowfish", "rc5",
                          "3des", "cast", "aes", }, },
index 1789fb5164a61060f6fcb7a0f6a3e68efc3c01cc..feb5b9bad55f54f11f4f4b6ee809e9e4096179d5 100644 (file)
@@ -371,7 +371,7 @@ struct juniper_cookie_table_t {
     const char *s;             /* pic name */
 };
 
-static struct juniper_cookie_table_t juniper_cookie_table[] = {
+static const struct juniper_cookie_table_t juniper_cookie_table[] = {
 #ifdef DLT_JUNIPER_ATM1
     { DLT_JUNIPER_ATM1,  4, "ATM1"},
 #endif
@@ -1133,7 +1133,7 @@ juniper_read_tlv_value(const u_char *p, u_int tlv_type, u_int tlv_len) {
 static int
 juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info) {
 
-    struct juniper_cookie_table_t *lp = juniper_cookie_table;
+    const struct juniper_cookie_table_t *lp = juniper_cookie_table;
     u_int idx, jnx_ext_len, jnx_header_len = 0;
     u_int8_t tlv_type,tlv_len;
     u_int32_t control_word;
index 17be82fae0a8b938b59a6b290dd909e6b86fe9ca..5ead415a75e839de9909038a49eca0e04c952cda 100644 (file)
@@ -265,7 +265,7 @@ static int mp_fast_close_print(const u_char *opt, u_int opt_len, u_char flags _U
         return 1;
 }
 
-static struct {
+static const struct {
         const char *name;
         int (*print)(const u_char *, u_int, u_char);
 } mptcp_options[] = {
index 1b4f949fb3651c40d25b490f6cc88b800dd395c0..638efd796ccddd4834c8995232c0e3af9e0ecc82 100644 (file)
@@ -68,7 +68,7 @@ static const struct tok rx_types[] = {
        { 0,                            NULL },
 };
 
-static struct double_tok {
+static const struct double_tok {
        int flag;               /* Rx flag */
        int packetType;         /* Packet type */
        const char *s;          /* Flag string */
index 68c73659f84f0627a25f589f5ec507b578a5c7f7..cc7bd6fdc9746ca41e8921f85f0749c5271eb71d 100644 (file)
@@ -65,8 +65,8 @@ struct smbfnsint
 
 #define FLG_CHAIN      (1 << 0)
 
-static struct smbfns *
-smbfind(int id, struct smbfns *list)
+static const struct smbfns *
+smbfind(int id, const struct smbfns *list)
 {
     int sindex;
 
@@ -77,8 +77,8 @@ smbfind(int id, struct smbfns *list)
     return(&list[0]);
 }
 
-static struct smbfnsint *
-smbfindint(int id, struct smbfnsint *list)
+static const struct smbfnsint *
+smbfindint(int id, const struct smbfnsint *list)
 {
     int sindex;
 
@@ -144,7 +144,7 @@ trunc:
     return;
 }
 
-struct smbfnsint trans2_fns[] = {
+static const struct smbfnsint trans2_fns[] = {
     { 0, "TRANSACT2_OPEN", 0,
        { "Flags2=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]\nOFun=[w]\nSize=[D]\nRes=([w, w, w, w, w])\nPath=[S]",
          NULL,
@@ -173,7 +173,7 @@ static void
 print_trans2(const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf)
 {
     u_int bcc;
-    static struct smbfnsint *fn = &trans2_fns[0];
+    static const struct smbfnsint *fn = &trans2_fns[0];
     const u_char *data, *param;
     const u_char *w = words + 1;
     const char *f1 = NULL, *f2 = NULL;
@@ -520,7 +520,7 @@ trunc:
 }
 
 
-static struct smbfns smb_fns[] = {
+static const struct smbfns smb_fns[] = {
     { -1, "SMBunknown", 0, DEFDESCRIPT },
 
     { SMBtcon, "SMBtcon", 0,
@@ -799,7 +799,7 @@ print_smb(const u_char *buf, const u_char *maxbuf)
     int command;
     u_int32_t nterror;
     const u_char *words, *maxwords, *data;
-    struct smbfns *fn;
+    const struct smbfns *fn;
     const char *fmt_smbheader =
         "[P4]SMB Command   =  [B]\nError class   =  [BP1]\nError code    =  [d]\nFlags1        =  [B]\nFlags2        =  [B][P13]\nTree ID       =  [d]\nProc ID       =  [d]\nUID           =  [d]\nMID           =  [d]\nWord Count    =  [b]\n";
     int smboffset;
index 728da6beb79ebca0bdeac14455d50173676bd2fa..8500566900a382cda552caf8dcb25422ebf2bdf3 100644 (file)
@@ -83,7 +83,7 @@ static const char rcsid[] _U_ =
  * Universal ASN.1 types
  * (we only care about the tag values for those allowed in the Internet SMI)
  */
-const char *Universal[] = {
+static const char *Universal[] = {
        "U-0",
        "Boolean",
        "Integer",
@@ -106,7 +106,7 @@ const char *Universal[] = {
 /*
  * Application-wide ASN.1 types from the Internet SMI and their tags
  */
-const char *Application[] = {
+static const char *Application[] = {
        "IpAddress",
 #define IPADDR 0
        "Counter",
@@ -125,7 +125,7 @@ const char *Application[] = {
 /*
  * Context-specific ASN.1 types for the SNMP PDUs and their tags
  */
-const char *Context[] = {
+static const char *Context[] = {
        "GetRequest",
 #define GETREQ 0
        "GetNextRequest",
@@ -155,7 +155,7 @@ const char *Context[] = {
 /*
  * Context-specific ASN.1 types for the SNMP Exceptions and their tags
  */
-const char *Exceptions[] = {
+static const char *Exceptions[] = {
        "noSuchObject",
 #define NOSUCHOBJECT 0
        "noSuchInstance",
@@ -168,14 +168,14 @@ const char *Exceptions[] = {
  * Private ASN.1 types
  * The Internet SMI does not specify any
  */
-const char *Private[] = {
+static const char *Private[] = {
        "P-0"
 };
 
 /*
  * error-status values for any SNMP PDU
  */
-const char *ErrorStatus[] = {
+static const char *ErrorStatus[] = {
        "noError",
        "tooBig",
        "noSuchName",
@@ -204,7 +204,7 @@ const char *ErrorStatus[] = {
 /*
  * generic-trap values in the SNMP Trap-PDU
  */
-const char *GenericTrap[] = {
+static const char *GenericTrap[] = {
        "coldStart",
        "warmStart",
        "linkDown",
@@ -225,7 +225,7 @@ const char *GenericTrap[] = {
  * type definitions.
  */
 #define defineCLASS(x) { "x", x, sizeof(x)/sizeof(x[0]) } /* not ANSI-C */
-struct {
+static const struct {
        const char      *name;
        const char      **Id;
            int numIDs;
@@ -245,7 +245,7 @@ struct {
 /*
  * defined forms for ASN.1 types
  */
-const char *Form[] = {
+static const char *Form[] = {
        "Primitive",
 #define PRIMITIVE      0
        "Constructed",
@@ -278,7 +278,7 @@ struct obj {
  * Currently, this includes the prefixes for the Internet MIB, the
  * private enterprises tree, and the experimental tree.
  */
-struct obj_abrev {
+static const struct obj_abrev {
        const char *prefix;             /* prefix for this abrev */
        struct obj *node;               /* pointer into object table */
        const char *oid;                /* ASN.1 encoded OID */
@@ -360,7 +360,7 @@ struct be {
 /*
  * SNMP versions recognized by this module
  */
-const char *SnmpVersion[] = {
+static const char *SnmpVersion[] = {
        "SNMPv1",
 #define SNMP_VERSION_1 0
        "SNMPv2c",
@@ -684,7 +684,7 @@ asn1_print(struct be *elem)
                int o = 0, first = -1, i = asnlen;
 
                if (!sflag && !nflag && asnlen > 2) {
-                       struct obj_abrev *a = &obj_abrev_list[0];
+                       const struct obj_abrev *a = &obj_abrev_list[0];
                        size_t a_len = strlen(a->oid);
                        for (; a->node; a++) {
                                TCHECK2(*p, a_len);
@@ -879,7 +879,7 @@ struct smi2be {
     int be;
 };
 
-static struct smi2be smi2betab[] = {
+static const struct smi2be smi2betab[] = {
     { SMI_BASETYPE_INTEGER32,          BE_INT },
     { SMI_BASETYPE_OCTETSTRING,                BE_STR },
     { SMI_BASETYPE_OCTETSTRING,                BE_INETADDR },
index 3ae604ffed0b791de6eaf59824fed3ab172a261d..c478bf4c589ca7d95d7c3c4d29d273a7989fb3a0 100644 (file)
@@ -288,7 +288,7 @@ wb_prep(const struct pkt_prep *prep, u_int len)
 }
 
 
-const char *dopstr[] = {
+static const char *dopstr[] = {
        "dop-0!",
        "dop-1!",
        "RECT",
index 24289869c9d855e434b6815c0ab86b70d4586a81..eacce4687f44d94f1e4b1647a4bfa590a90a0deb 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -167,7 +167,7 @@ struct ndo_printer {
 };
 
 
-static struct printer printers[] = {
+static const struct printer printers[] = {
        { arcnet_if_print,      DLT_ARCNET },
 #ifdef DLT_ARCNET_LINUX
        { arcnet_linux_if_print, DLT_ARCNET_LINUX },
@@ -322,7 +322,7 @@ static struct printer printers[] = {
        { NULL,                 0 },
 };
 
-static struct ndo_printer ndo_printers[] = {
+static const struct ndo_printer ndo_printers[] = {
        { ether_if_print,       DLT_EN10MB },
 #ifdef DLT_IPNET
        { ipnet_if_print,       DLT_IPNET },
@@ -351,7 +351,7 @@ static struct ndo_printer ndo_printers[] = {
 if_printer
 lookup_printer(int type)
 {
-       struct printer *p;
+       const struct printer *p;
 
        for (p = printers; p->f; ++p)
                if (type == p->type)
@@ -364,7 +364,7 @@ lookup_printer(int type)
 if_ndo_printer
 lookup_ndo_printer(int type)
 {
-       struct ndo_printer *p;
+       const struct ndo_printer *p;
 
        for (p = ndo_printers; p->f; ++p)
                if (type == p->type)