summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mauderer <Christian.Mauderer@embedded-brains.de>2016-07-29 16:04:42 +0200
committerChristian Mauderer <Christian.Mauderer@embedded-brains.de>2016-08-02 10:21:52 +0200
commit686583cba4f2701185077eab58800741398c3ac2 (patch)
tree153b47659898def269b7f932131b3f77c244968d
parentpfctl: Add const and move static variables. (diff)
downloadrtems-libbsd-686583cba4f2701185077eab58800741398c3ac2.tar.bz2
pfctl: Use static where possible.
-rw-r--r--freebsd/contrib/pf/pfctl/parse.y52
-rw-r--r--freebsd/contrib/pf/pfctl/pfctl.c29
-rw-r--r--freebsd/contrib/pf/pfctl/pfctl_altq.c5
-rw-r--r--freebsd/contrib/pf/pfctl/pfctl_optimize.c15
-rw-r--r--freebsd/contrib/pf/pfctl/pfctl_osfp.c6
-rw-r--r--freebsd/contrib/pf/pfctl/pfctl_parser.c4
6 files changed, 107 insertions, 4 deletions
diff --git a/freebsd/contrib/pf/pfctl/parse.y b/freebsd/contrib/pf/pfctl/parse.y
index 1448177c..30bf3616 100644
--- a/freebsd/contrib/pf/pfctl/parse.y
+++ b/freebsd/contrib/pf/pfctl/parse.y
@@ -84,7 +84,11 @@ static int blockpolicy = PFRULE_DROP;
static int require_order = 1;
static int default_statelock;
+#ifndef __rtems__
TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files);
+#else /* __rtems__ */
+static TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files);
+#endif /* __rtems__ */
static struct file {
TAILQ_ENTRY(file) entry;
FILE *stream;
@@ -104,7 +108,11 @@ int lgetc(int);
int lungetc(int);
int findeol(void);
+#ifndef __rtems__
TAILQ_HEAD(symhead, sym) symhead = TAILQ_HEAD_INITIALIZER(symhead);
+#else /* __rtems__ */
+static TAILQ_HEAD(symhead, sym) symhead = TAILQ_HEAD_INITIALIZER(symhead);
+#endif /* __rtems__ */
struct sym {
TAILQ_ENTRY(sym) entry;
int used;
@@ -201,7 +209,11 @@ struct peer {
struct node_port *port;
};
+#ifndef __rtems__
struct node_queue {
+#else /* __rtems__ */
+static struct node_queue {
+#endif /* __rtems__ */
char queue[PF_QNAME_SIZE];
char parent[PF_QNAME_SIZE];
char ifname[IFNAMSIZ];
@@ -215,7 +227,11 @@ struct node_qassign {
char *pqname;
};
+#ifndef __rtems__
struct filter_opts {
+#else /* __rtems__ */
+static struct filter_opts {
+#endif /* __rtems__ */
int marker;
#define FOM_FLAGS 0x01
#define FOM_ICMP 0x02
@@ -251,12 +267,20 @@ struct filter_opts {
} divert;
} filter_opts;
+#ifndef __rtems__
struct antispoof_opts {
+#else /* __rtems__ */
+static struct antispoof_opts {
+#endif /* __rtems__ */
char *label;
u_int rtableid;
} antispoof_opts;
+#ifndef __rtems__
struct scrub_opts {
+#else /* __rtems__ */
+static struct scrub_opts {
+#endif /* __rtems__ */
int marker;
#define SOM_MINTTL 0x01
#define SOM_MAXMSS 0x02
@@ -274,7 +298,11 @@ struct scrub_opts {
u_int rtableid;
} scrub_opts;
+#ifndef __rtems__
struct queue_opts {
+#else /* __rtems__ */
+static struct queue_opts {
+#endif /* __rtems__ */
int marker;
#define QOM_BWSPEC 0x01
#define QOM_SCHEDULER 0x02
@@ -288,13 +316,21 @@ struct queue_opts {
int qlimit;
} queue_opts;
+#ifndef __rtems__
struct table_opts {
+#else /* __rtems__ */
+static struct table_opts {
+#endif /* __rtems__ */
int flags;
int init_addr;
struct node_tinithead init_nodes;
} table_opts;
+#ifndef __rtems__
struct pool_opts {
+#else /* __rtems__ */
+static struct pool_opts {
+#endif /* __rtems__ */
int marker;
#define POM_TYPE 0x01
#define POM_STICKYADDRESS 0x02
@@ -306,8 +342,13 @@ struct pool_opts {
} pool_opts;
+#ifndef __rtems__
struct node_hfsc_opts hfsc_opts;
struct node_state_opt *keep_state_defaults = NULL;
+#else /* __rtems__ */
+static struct node_hfsc_opts hfsc_opts;
+static struct node_state_opt *keep_state_defaults = NULL;
+#endif /* __rtems__ */
int disallow_table(struct node_host *, const char *);
int disallow_urpf_failed(struct node_host *, const char *);
@@ -352,7 +393,11 @@ void remove_invalid_hosts(struct node_host **, sa_family_t *);
int invalid_redirect(struct node_host *, sa_family_t);
u_int16_t parseicmpspec(char *, sa_family_t);
+#ifndef __rtems__
TAILQ_HEAD(loadanchorshead, loadanchors)
+#else /* __rtems__ */
+static TAILQ_HEAD(loadanchorshead, loadanchors)
+#endif /* __rtems__ */
loadanchorshead = TAILQ_HEAD_INITIALIZER(loadanchorshead);
struct loadanchors {
@@ -5396,10 +5441,17 @@ lookup(char *s)
#define MAXPUSHBACK 128
+#ifndef __rtems__
char *parsebuf;
int parseindex;
char pushback_buffer[MAXPUSHBACK];
int pushback_index = 0;
+#else /* __rtems__ */
+static char *parsebuf;
+static int parseindex;
+static char pushback_buffer[MAXPUSHBACK];
+static int pushback_index = 0;
+#endif /* __rtems__ */
int
lgetc(int quotec)
diff --git a/freebsd/contrib/pf/pfctl/pfctl.c b/freebsd/contrib/pf/pfctl/pfctl.c
index e7597e32..42adc69d 100644
--- a/freebsd/contrib/pf/pfctl/pfctl.c
+++ b/freebsd/contrib/pf/pfctl/pfctl.c
@@ -114,6 +114,7 @@ const char *pfctl_lookup_option(char *, const char **);
const char *pfctl_lookup_option(char *, const char * const *);
#endif /* __rtems__ */
+#ifndef __rtems__
struct pf_anchor_global pf_anchors;
struct pf_anchor pf_main_anchor;
@@ -123,11 +124,7 @@ const char *showopt;
const char *debugopt;
char *anchoropt;
const char *optiopt = NULL;
-#ifndef __rtems__
char *pf_device = "/dev/pf";
-#else /* __rtems__ */
-const char *pf_device = "/dev/pf";
-#endif /* __rtems__ */
char *ifaceopt;
char *tableopt;
const char *tblcmdopt;
@@ -135,12 +132,36 @@ int src_node_killers;
char *src_node_kill[2];
int state_killers;
char *state_kill[2];
+#else /* __rtems__ */
+static struct pf_anchor_global pf_anchors;
+static struct pf_anchor pf_main_anchor;
+
+static const char *clearopt;
+static char *rulesopt;
+static const char *showopt;
+static const char *debugopt;
+static char *anchoropt;
+static const char *optiopt = NULL;
+static const char *pf_device = "/dev/pf";
+static char *ifaceopt;
+static char *tableopt;
+static const char *tblcmdopt;
+static int src_node_killers;
+static char *src_node_kill[2];
+static int state_killers;
+static char *state_kill[2];
+#endif /* __rtems__ */
int loadopt;
int altqsupport;
int dev = -1;
+#ifndef __rtems__
int first_title = 1;
int labels = 0;
+#else /* __rtems__ */
+static int first_title = 1;
+static int labels = 0;
+#endif /* __rtems__ */
#define INDENT(d, o) do { \
if (o) { \
diff --git a/freebsd/contrib/pf/pfctl/pfctl_altq.c b/freebsd/contrib/pf/pfctl/pfctl_altq.c
index 71632770..2dc1b035 100644
--- a/freebsd/contrib/pf/pfctl/pfctl_altq.c
+++ b/freebsd/contrib/pf/pfctl/pfctl_altq.c
@@ -50,8 +50,13 @@ __FBSDID("$FreeBSD$");
#define is_sc_null(sc) (((sc) == NULL) || ((sc)->m1 == 0 && (sc)->m2 == 0))
+#ifndef __rtems__
TAILQ_HEAD(altqs, pf_altq) altqs = TAILQ_HEAD_INITIALIZER(altqs);
LIST_HEAD(gen_sc, segment) rtsc, lssc;
+#else /* __rtems__ */
+static TAILQ_HEAD(altqs, pf_altq) altqs = TAILQ_HEAD_INITIALIZER(altqs);
+static LIST_HEAD(gen_sc, segment) rtsc, lssc;
+#endif /* __rtems__ */
struct pf_altq *qname_to_pfaltq(const char *, const char *);
u_int32_t qname_to_qid(const char *);
diff --git a/freebsd/contrib/pf/pfctl/pfctl_optimize.c b/freebsd/contrib/pf/pfctl/pfctl_optimize.c
index f7b78652..bc7bf91a 100644
--- a/freebsd/contrib/pf/pfctl/pfctl_optimize.c
+++ b/freebsd/contrib/pf/pfctl/pfctl_optimize.c
@@ -92,7 +92,11 @@ enum {
COMBINED, /* the field may itself be combined with other rules */
DC, /* we just don't care about the field */
NEVER}; /* we should never see this field set?!? */
+#ifndef __rtems__
struct pf_rule_field {
+#else /* __rtems__ */
+static struct pf_rule_field {
+#endif /* __rtems__ */
const char *prf_name;
int prf_type;
size_t prf_offset;
@@ -248,8 +252,14 @@ int superblock_inclusive(struct superblock *, struct pf_opt_rule *);
void superblock_free(struct pfctl *, struct superblock *);
+#ifndef __rtems__
int (*skip_comparitors[PF_SKIP_COUNT])(struct pf_rule *, struct pf_rule *);
const char *skip_comparitors_names[PF_SKIP_COUNT];
+#else /* __rtems__ */
+static int (*skip_comparitors[PF_SKIP_COUNT])(struct pf_rule *,
+ struct pf_rule *);
+static const char *skip_comparitors_names[PF_SKIP_COUNT];
+#endif /* __rtems__ */
#define PF_SKIP_COMPARITORS { \
{ "ifp", PF_SKIP_IFP, skip_cmp_ifp }, \
{ "dir", PF_SKIP_DIR, skip_cmp_dir }, \
@@ -261,8 +271,13 @@ const char *skip_comparitors_names[PF_SKIP_COUNT];
{ "dport", PF_SKIP_DST_PORT, skip_cmp_dst_port } \
}
+#ifndef __rtems__
struct pfr_buffer table_buffer;
int table_identifier;
+#else /* __rtems__ */
+static struct pfr_buffer table_buffer;
+static int table_identifier;
+#endif /* __rtems__ */
int
diff --git a/freebsd/contrib/pf/pfctl/pfctl_osfp.c b/freebsd/contrib/pf/pfctl/pfctl_osfp.c
index b4ac0e01..0f8679a1 100644
--- a/freebsd/contrib/pf/pfctl/pfctl_osfp.c
+++ b/freebsd/contrib/pf/pfctl/pfctl_osfp.c
@@ -66,9 +66,15 @@ struct name_entry {
struct name_list nm_sublist;
int nm_sublist_num;
};
+#ifndef __rtems__
struct name_list classes = LIST_HEAD_INITIALIZER(&classes);
int class_count;
int fingerprint_count;
+#else /* __rtems__ */
+static struct name_list classes = LIST_HEAD_INITIALIZER(&classes);
+static int class_count;
+static int fingerprint_count;
+#endif /* __rtems__ */
void add_fingerprint(int, int, struct pf_osfp_ioctl *);
struct name_entry *fingerprint_name_entry(struct name_list *, char *);
diff --git a/freebsd/contrib/pf/pfctl/pfctl_parser.c b/freebsd/contrib/pf/pfctl/pfctl_parser.c
index 49035de6..519fa3fd 100644
--- a/freebsd/contrib/pf/pfctl/pfctl_parser.c
+++ b/freebsd/contrib/pf/pfctl/pfctl_parser.c
@@ -1164,7 +1164,11 @@ check_netmask(struct node_host *h, sa_family_t af)
/* interface lookup routines */
+#ifndef __rtems__
struct node_host *iftab;
+#else /* __rtems__ */
+static struct node_host *iftab;
+#endif /* __rtems__ */
void
ifa_load(void)