]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
libnftables: Make some arrays globally accessible
authorPhil Sutter <phil@nwl.cc>
Tue, 8 May 2018 11:08:34 +0000 (13:08 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 11 May 2018 10:16:51 +0000 (12:16 +0200)
This removes static flag and adds declarations in headers for the
following arrays:

* ct_templates from src/ct.c
* mark_tbl from src/datatype.c
* meta_templates and devgroup_tbl from src/meta.c
* table_flags_name from src/rule.c
* set_stmt_op_names from src/statement.c
* tcpopthdr_protocols from src/tcpopt.c

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
14 files changed:
include/ct.h
include/datatype.h
include/meta.h
include/rt.h
include/rule.h
include/statement.h
include/tcpopt.h
src/ct.c
src/datatype.c
src/meta.c
src/rt.c
src/rule.c
src/statement.c
src/tcpopt.c

index 2c3392d36c94eabd672697debe7dfbe37189c248..dadd820f8874038582fbab4ea3208e97908b6cd5 100644 (file)
@@ -16,6 +16,8 @@ struct ct_template {
        unsigned int            len;
 };
 
+extern const struct ct_template ct_templates[__NFT_CT_MAX];
+
 #define CT_TEMPLATE(__token, __dtype, __byteorder, __len) {    \
        .token          = (__token),                            \
        .dtype          = (__dtype),                            \
index aca08decf142b679046abed88f4f2caa825ad81d..56892ddc02d3b8d4b56de0b0990fe562f0b97a1d 100644 (file)
@@ -218,6 +218,7 @@ extern struct symbol_table *rt_symbol_table_init(const char *filename);
 extern void rt_symbol_table_free(struct symbol_table *tbl);
 
 extern const struct symbol_table inet_service_tbl;
+extern struct symbol_table *mark_tbl;
 
 extern const struct datatype invalid_type;
 extern const struct datatype verdict_type;
index 6086a71cc0115923bc8b4e3ff4e58e8991788ea2..a49b4ff549702ad23d1e931a2906a4b69a8c55b2 100644 (file)
@@ -16,6 +16,8 @@ struct meta_template {
        unsigned int            len;
 };
 
+extern const struct meta_template meta_templates[];
+
 #define META_TEMPLATE(__token, __dtype, __len, __byteorder) {  \
        .token          = (__token),                            \
        .dtype          = (__dtype),                            \
@@ -40,4 +42,6 @@ extern const struct datatype devgroup_type;
 extern const struct datatype pkttype_type;
 extern const struct datatype ifname_type;
 
+extern struct symbol_table *devgroup_tbl;
+
 #endif /* NFTABLES_META_H */
index 9828e634660a12fa321e0806303e124d73c6ef82..195af94345cbcb88daa1abf90a826138d2809b78 100644 (file)
@@ -18,6 +18,8 @@ struct rt_template {
        bool                    invalid;
 };
 
+extern const struct rt_template rt_templates[];
+
 #define RT_TEMPLATE(__token, __dtype, __len, __byteorder, __invalid) { \
        .token          = (__token),                                    \
        .dtype          = (__dtype),                                    \
index a3764bda74ce2dc8c5eb25ed09eddf94dcc25875..2c44cceab02490e19a3b61efd170ae7d7e0be4b2 100644 (file)
@@ -115,6 +115,9 @@ struct symbol *symbol_get(const struct scope *scope, const char *identifier);
 enum table_flags {
        TABLE_F_DORMANT         = (1 << 0),
 };
+#define TABLE_FLAGS_MAX 1
+
+extern const char *table_flags_name[TABLE_FLAGS_MAX];
 
 /**
  * struct table - nftables table
index 7315e7aeea8bc4802ec9f2438b06730402c3ddef..5987b18170f9469db17f09bf72e156c742676e2d 100644 (file)
@@ -163,6 +163,8 @@ struct set_stmt {
        enum nft_dynset_ops     op;
 };
 
+extern const char * const set_stmt_op_names[];
+
 extern struct stmt *set_stmt_alloc(const struct location *loc);
 
 struct map_stmt {
index 9be84817e6f20813c84a5905a105f72f999ee415..ffdbcb028125c2872e29c21eb8afa5aa7b197c0e 100644 (file)
@@ -29,6 +29,7 @@ enum tcpopt_hdr_types {
        TCPOPTHDR_TIMESTAMP,
        TCPOPTHDR_ECHO,
        TCPOPTHDR_ECHO_REPLY,
+       __TCPOPTHDR_MAX
 };
 
 enum tcpopt_hdr_fields {
@@ -42,4 +43,7 @@ enum tcpopt_hdr_fields {
        TCPOPTHDR_FIELD_TSVAL,
        TCPOPTHDR_FIELD_TSECR,
 };
+
+extern const struct exthdr_desc *tcpopthdr_protocols[__TCPOPTHDR_MAX];
+
 #endif /* NFTABLES_TCPOPT_H */
index 6cb6bd5af927bca6a356e85a43ab738d9b6f8fbb..2abaa0d58144364ee41923dbf40a3be3f2597c8f 100644 (file)
--- a/src/ct.c
+++ b/src/ct.c
@@ -220,7 +220,7 @@ void ct_label_table_exit(void)
 #define NF_CT_HELPER_NAME_LEN  16
 #endif
 
-static const struct ct_template ct_templates[] = {
+const struct ct_template ct_templates[__NFT_CT_MAX] = {
        [NFT_CT_STATE]          = CT_TEMPLATE("state",      &ct_state_type,
                                              BYTEORDER_HOST_ENDIAN,
                                              4 * BITS_PER_BYTE),
index 4248f7e40c9604304e04bd06a849854133b73f8e..d5a5091e0a1c5d0988f39714254b883aed41c9c9 100644 (file)
@@ -721,7 +721,8 @@ void rt_symbol_table_free(struct symbol_table *tbl)
        xfree(tbl);
 }
 
-static struct symbol_table *mark_tbl;
+struct symbol_table *mark_tbl = NULL;
+
 void mark_table_init(void)
 {
        mark_tbl = rt_symbol_table_init("/etc/iproute2/rt_marks");
index 3012efa94e242ea2610e8006df698afd48a7a924..fb94ed406d4a5895de12ddb316c9888c3eb83a9d 100644 (file)
@@ -334,7 +334,8 @@ const struct datatype pkttype_type = {
        .sym_tbl        = &pkttype_type_tbl,
 };
 
-static struct symbol_table *devgroup_tbl;
+struct symbol_table *devgroup_tbl = NULL;
+
 void devgroup_table_init(void)
 {
        devgroup_tbl = rt_symbol_table_init("/etc/iproute2/group");
@@ -378,7 +379,7 @@ const struct datatype ifname_type = {
        .basetype       = &string_type,
 };
 
-static const struct meta_template meta_templates[] = {
+const struct meta_template meta_templates[] = {
        [NFT_META_LEN]          = META_TEMPLATE("length",    &integer_type,
                                                4 * 8, BYTEORDER_HOST_ENDIAN),
        [NFT_META_PROTOCOL]     = META_TEMPLATE("protocol",  &ethertype_type,
index 041dbc2f7d900ca21e0d613e497bda8d4c7a5c84..2530b663bb249c90f3d7072bb81b5326c10f6208 100644 (file)
--- a/src/rt.c
+++ b/src/rt.c
@@ -57,7 +57,7 @@ const struct datatype realm_type = {
        .flags          = DTYPE_F_PREFIX,
 };
 
-static const struct rt_template rt_templates[] = {
+const struct rt_template rt_templates[] = {
        [NFT_RT_CLASSID]        = RT_TEMPLATE("classid",
                                              &realm_type,
                                              4 * BITS_PER_BYTE,
index 279b741b133e4f80aab02cabea4f414bd129e8e5..5f73bebc7531d3306e93a5daf940d09176728288 100644 (file)
@@ -856,8 +856,6 @@ struct table *table_lookup(const struct handle *h,
        return NULL;
 }
 
-#define TABLE_FLAGS_MAX 1
-
 const char *table_flags_name[TABLE_FLAGS_MAX] = {
        "dormant",
 };
index 19c30cf861c815603930f892131df82ef5a97c2b..a5ef7d7dfd2ebfde9f8ddd5c400b08e34f80fd86 100644 (file)
@@ -567,7 +567,7 @@ struct stmt *nat_stmt_alloc(const struct location *loc,
        return stmt;
 }
 
-static const char * const set_stmt_op_names[] = {
+const char * const set_stmt_op_names[] = {
        [NFT_DYNSET_OP_ADD]     = "add",
        [NFT_DYNSET_OP_UPDATE]  = "update",
 };
index 7c6c2557028ab62df453f00e9bba9c177fe5fa88..66f021f94d63f72d9424f3e81324c2c167f3fdf5 100644 (file)
@@ -136,7 +136,7 @@ static unsigned int calc_offset_reverse(const struct exthdr_desc *desc,
        }
 }
 
-static const struct exthdr_desc *tcpopthdr_protocols[] = {
+const struct exthdr_desc *tcpopthdr_protocols[__TCPOPTHDR_MAX] = {
        [TCPOPTHDR_EOL]                 = &tcpopt_eol,
        [TCPOPTHDR_NOOP]                = &tcpopt_nop,
        [TCPOPTHDR_MAXSEG]              = &tcptopt_maxseg,