Changeset d112679 in rtems-libbsd


Ignore:
Timestamp:
Jul 6, 2016, 7:50:51 AM (3 years ago)
Author:
Christian Mauderer <Christian.Mauderer@…>
Branches:
4.11
Children:
85dd332
Parents:
bf8e51b
git-author:
Christian Mauderer <Christian.Mauderer@…> (07/06/16 07:50:51)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/03/16 12:13:18)
Message:

pfctl: Add const and move static variables.

Note: This should be upstreamed into BSD.

Make everything constant that can be constant and move static variables
out of their functions.

Location:
freebsd/contrib/pf/pfctl
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • freebsd/contrib/pf/pfctl/pfctl.c

    rbf8e51b rd112679  
    109109                struct pf_ruleset *, int, int);
    110110int      pfctl_load_rule(struct pfctl *, char *, struct pf_rule *, int);
     111#ifndef __rtems__
    111112const char      *pfctl_lookup_option(char *, const char **);
     113#else /* __rtems__ */
     114const char      *pfctl_lookup_option(char *, const char * const *);
     115#endif /* __rtems__ */
    112116
    113117struct pf_anchor_global  pf_anchors;
     
    120124char            *anchoropt;
    121125const char      *optiopt = NULL;
     126#ifndef __rtems__
    122127char            *pf_device = "/dev/pf";
     128#else /* __rtems__ */
     129const char      *pf_device = "/dev/pf";
     130#endif /* __rtems__ */
    123131char            *ifaceopt;
    124132char            *tableopt;
     
    213221};
    214222
     223#ifndef __rtems__
    215224static const char *clearopt_list[] = {
     225#else /* __rtems__ */
     226static const char * const clearopt_list[] = {
     227#endif /* __rtems__ */
    216228        "nat", "queue", "rules", "Sources",
    217229        "states", "info", "Tables", "osfp", "all", NULL
    218230};
    219231
     232#ifndef __rtems__
    220233static const char *showopt_list[] = {
     234#else /* __rtems__ */
     235static const char * const showopt_list[] = {
     236#endif /* __rtems__ */
    221237        "nat", "queue", "rules", "Anchors", "Sources", "states", "info",
    222238        "Interfaces", "labels", "timeouts", "memory", "Tables", "osfp",
     
    224240};
    225241
     242#ifndef __rtems__
    226243static const char *tblcmdopt_list[] = {
     244#else /* __rtems__ */
     245static const char * const tblcmdopt_list[] = {
     246#endif /* __rtems__ */
    227247        "kill", "flush", "add", "delete", "load", "replace", "show",
    228248        "test", "zero", "expire", NULL
    229249};
    230250
     251#ifndef __rtems__
    231252static const char *debugopt_list[] = {
     253#else /* __rtems__ */
     254static const char * const debugopt_list[] = {
     255#endif /* __rtems__ */
    232256        "none", "urgent", "misc", "loud", NULL
    233257};
    234258
     259#ifndef __rtems__
    235260static const char *optiopt_list[] = {
     261#else /* __rtems__ */
     262static const char * const optiopt_list[] = {
     263#endif /* __rtems__ */
    236264        "none", "basic", "profile", NULL
    237265};
     266#ifdef __rtems__
     267
     268static const int nattype[3] = { PF_NAT, PF_RDR, PF_BINAT };
     269#endif /* __rtems__ */
    238270
    239271void
     
    9791011        struct pfioc_rule pr;
    9801012        u_int32_t mnr, nr;
     1013#ifndef __rtems__
    9811014        static int nattype[3] = { PF_NAT, PF_RDR, PF_BINAT };
     1015#endif /* __rtems__ */
    9821016        int i, dotitle = opts & PF_OPT_SHOWALL;
    9831017
     
    20022036
    20032037const char *
     2038#ifndef __rtems__
    20042039pfctl_lookup_option(char *cmd, const char **list)
     2040#else /* __rtems__ */
     2041pfctl_lookup_option(char *cmd, const char * const *list)
     2042#endif /* __rtems__ */
    20052043{
    20062044        if (cmd != NULL && *cmd)
  • freebsd/contrib/pf/pfctl/pfctl_altq.c

    rbf8e51b rd112679  
    10741074#define RATESTR_MAX     16
    10751075
     1076#ifdef __rtems__
     1077static char      r2sbuf[R2S_BUFS][RATESTR_MAX];  /* ring bufer */
     1078static int       r2sidx = 0;
     1079
     1080#endif /* __rtems__ */
    10761081char *
    10771082rate2str(double rate)
    10781083{
    10791084        char            *buf;
     1085#ifndef __rtems__
    10801086        static char      r2sbuf[R2S_BUFS][RATESTR_MAX];  /* ring bufer */
    10811087        static int       idx = 0;
     1088#endif /* __rtems__ */
    10821089        int              i;
    10831090        static const char unit[] = " KMG";
    10841091
     1092#ifndef __rtems__
    10851093        buf = r2sbuf[idx++];
    10861094        if (idx == R2S_BUFS)
    10871095                idx = 0;
     1096#else /* __rtems__ */
     1097        buf = r2sbuf[r2sidx++];
     1098        if (r2sidx == R2S_BUFS)
     1099                r2sidx = 0;
     1100#endif /* __rtems__ */
    10881101
    10891102        for (i = 0; rate >= 1000 && i <= 3; i++)
  • freebsd/contrib/pf/pfctl/pfctl_optimize.c

    rbf8e51b rd112679  
    207207    PF_RULE_FIELD(set_tos,              NEVER),
    208208};
     209#ifdef __rtems__
     210static int pf_opt_create_table_num;
     211static int add_opt_table_num = 0;
     212#endif /* __rtems__ */
    209213
    210214
     
    12291233        char buf[128];
    12301234#endif /* OPT_DEBUG */
     1235#ifndef __rtems__
    12311236        static int tablenum = 0;
     1237#endif /* __rtems__ */
    12321238        struct node_host node_host;
    12331239
     
    12421248                /* This is just a temporary table name */
    12431249                snprintf((*tbl)->pt_name, sizeof((*tbl)->pt_name), "%s%d",
     1250#ifndef __rtems__
    12441251                    PF_OPT_TABLE_PREFIX, tablenum++);
     1252#else /* __rtems__ */
     1253                    PF_OPT_TABLE_PREFIX, add_opt_table_num++);
     1254#endif /* __rtems__ */
    12451255                DEBUG("creating table <%s>", (*tbl)->pt_name);
    12461256        }
     
    12781288}
    12791289
    1280 
    12811290/*
    12821291 * Do the dirty work of choosing an unused table name and creating it.
     
    12861295pf_opt_create_table(struct pfctl *pf, struct pf_opt_tbl *tbl)
    12871296{
     1297#ifndef __rtems__
    12881298        static int tablenum;
     1299#endif /* __rtems__ */
    12891300        struct pfr_table *t;
    12901301
     
    13091320again:
    13101321        DEBUG("translating temporary table <%s> to <%s%x_%d>", tbl->pt_name,
     1322#ifndef __rtems__
    13111323            PF_OPT_TABLE_PREFIX, table_identifier, tablenum);
     1324#else /* __rtems__ */
     1325            PF_OPT_TABLE_PREFIX, table_identifier, pf_opt_create_table_num);
     1326#endif /* __rtems__ */
    13121327        snprintf(tbl->pt_name, sizeof(tbl->pt_name), "%s%x_%d",
     1328#ifndef __rtems__
    13131329            PF_OPT_TABLE_PREFIX, table_identifier, tablenum);
     1330#else /* __rtems__ */
     1331            PF_OPT_TABLE_PREFIX, table_identifier, pf_opt_create_table_num);
     1332#endif /* __rtems__ */
    13141333        PFRB_FOREACH(t, &table_buffer) {
    13151334                if (strcasecmp(t->pfrt_name, tbl->pt_name) == 0) {
     
    13211340                }
    13221341        }
     1342#ifndef __rtems__
    13231343        tablenum++;
     1344#else /* __rtems__ */
     1345        pf_opt_create_table_num++;
     1346#endif /* __rtems__ */
    13241347
    13251348
  • freebsd/contrib/pf/pfctl/pfctl_osfp.c

    rbf8e51b rd112679  
    10111011print_ioctl(struct pf_osfp_ioctl *fp)
    10121012{
     1013#ifndef __rtems__
    10131014        static char buf[1024];
     1015#else /* __rtems__ */
     1016        /* Note on RTEMS port:
     1017         * This buffer is static. So normally it would have to be initialized to
     1018         * zero every time the program starts. But in this special case it is
     1019         * set to zero inside the function. Therefore it is not necessary to
     1020         * move it. If it would be moved out of the function, the name would
     1021         * have to be changed. This would be a lot of change in this function!
     1022         */
     1023        static char buf[1024];
     1024#endif /* __rtems__ */
    10141025        char tmp[32];
    10151026        int i, opt;
  • freebsd/contrib/pf/pfctl/pfctl_parser.c

    rbf8e51b rd112679  
    7979struct node_host        *host_dns(const char *, int, int);
    8080
     81#ifndef __rtems__
    8182const char *tcpflags = "FSRPAUEW";
     83#else /* __rtems__ */
     84const char * const tcpflags = "FSRPAUEW";
     85#endif /* __rtems__ */
    8286
    8387static const struct icmptypeent icmp_type[] = {
     
    484488}
    485489
     490#ifndef __rtems__
    486491const char      *pf_reasons[PFRES_MAX+1] = PFRES_NAMES;
    487492const char      *pf_lcounters[LCNT_MAX+1] = LCNT_NAMES;
    488493const char      *pf_fcounters[FCNT_MAX+1] = FCNT_NAMES;
    489494const char      *pf_scounters[FCNT_MAX+1] = FCNT_NAMES;
     495#else /* __rtems__ */
     496const char      * const pf_reasons[PFRES_MAX+1] = PFRES_NAMES;
     497const char      * const pf_lcounters[LCNT_MAX+1] = LCNT_NAMES;
     498const char      * const pf_fcounters[FCNT_MAX+1] = FCNT_NAMES;
     499const char      * const pf_scounters[FCNT_MAX+1] = FCNT_NAMES;
     500#endif /* __rtems__ */
    490501
    491502void
  • freebsd/contrib/pf/pfctl/pfctl_qstats.c

    rbf8e51b rd112679  
    7070};
    7171
     72#ifdef __rtems__
     73static  u_int32_t        last_ticket;
     74
     75#endif /* __rtems__ */
    7276int                      pfctl_update_qstats(int, struct pf_altq_node **);
    7377void                     pfctl_insert_altq_node(struct pf_altq_node **,
     
    140144        u_int32_t                mnr, nr;
    141145        struct queue_stats       qstats;
     146#ifndef __rtems__
    142147        static  u_int32_t        last_ticket;
     148#endif /* __rtems__ */
    143149
    144150        memset(&pa, 0, sizeof(pa));
  • freebsd/contrib/pf/pfctl/pfctl_radix.c

    rbf8e51b rd112679  
    404404/* buffer management code */
    405405
     406#ifndef __rtems__
    406407size_t buf_esize[PFRB_MAX] = { 0,
     408#else /* __rtems__ */
     409const size_t buf_esize[PFRB_MAX] = { 0,
     410#endif /* __rtems__ */
    407411        sizeof(struct pfr_table), sizeof(struct pfr_tstats),
    408412        sizeof(struct pfr_addr), sizeof(struct pfr_astats),
     
    537541}
    538542
     543#ifdef __rtems__
     544static char     next_ch = ' ';
     545#endif /* __rtems__ */
    539546int
    540547pfr_next_token(char buf[BUF_SIZE], FILE *fp)
    541548{
     549#ifndef __rtems__
    542550        static char     next_ch = ' ';
     551#endif /* __rtems__ */
    543552        int             i = 0;
    544553
Note: See TracChangeset for help on using the changeset viewer.