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

* must_print_eq_op() from src/expression.c
* fib_result_str() from src/fib.c
* set_policy2str() and chain_policy2str from src/rule.c

In fib.h, include linux/netfilter/nf_tables.h to make sure enum
nft_fib_result is known when including this file.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/expression.h
include/fib.h
include/rule.h
include/statement.h
src/expression.c
src/fib.c
src/rule.c
src/statement.c

index f0ba6fc1126018e57a8cd23f9b243af1369b6519..23d6bd23cff2975c23bed8b77ffea43c7aa67c7f 100644 (file)
@@ -366,6 +366,8 @@ extern struct expr *unary_expr_alloc(const struct location *loc,
 extern struct expr *binop_expr_alloc(const struct location *loc, enum ops op,
                                     struct expr *left, struct expr *right);
 
+extern bool must_print_eq_op(const struct expr *expr);
+
 extern struct expr *relational_expr_alloc(const struct location *loc, enum ops op,
                                          struct expr *left, struct expr *right);
 
index 9ce681cc1ecf35aa1421d67067af1a9d8a25e5ab..67edccfea0d572e329da2f66ce131d4755ba024e 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef NFTABLES_FIB_H
 #define NFTABLES_FIB_H
 
+#include <linux/netfilter/nf_tables.h>
+
+extern const char *fib_result_str(enum nft_fib_result result);
 extern struct expr *fib_expr_alloc(const struct location *loc,
                                   unsigned int flags,
                                   unsigned int result);
index 2c44cceab02490e19a3b61efd170ae7d7e0be4b2..cfecf7ffdd27dc6254b33d9de0da85522b997a34 100644 (file)
@@ -204,6 +204,7 @@ extern struct chain *chain_lookup(const struct table *table,
 
 extern const char *family2str(unsigned int family);
 extern const char *hooknum2str(unsigned int family, unsigned int hooknum);
+extern const char *chain_policy2str(uint32_t policy);
 extern void chain_print_plain(const struct chain *chain,
                              struct output_ctx *octx);
 
@@ -284,6 +285,7 @@ extern void set_add_hash(struct set *set, struct table *table);
 extern struct set *set_lookup(const struct table *table, const char *name);
 extern struct set *set_lookup_global(uint32_t family, const char *table,
                                     const char *name, struct nft_cache *cache);
+extern const char *set_policy2str(uint32_t policy);
 extern void set_print(const struct set *set, struct output_ctx *octx);
 extern void set_print_plain(const struct set *s, struct output_ctx *octx);
 
index 5987b18170f9469db17f09bf72e156c742676e2d..fc80dbd518b355bf46bf8cf80dab15af6bf0b054 100644 (file)
@@ -21,6 +21,7 @@ struct objref_stmt {
        struct expr             *expr;
 };
 
+const char *objref_type_name(uint32_t type);
 struct stmt *objref_stmt_alloc(const struct location *loc);
 
 struct counter_stmt {
@@ -75,6 +76,7 @@ struct log_stmt {
        uint32_t                flags;
 };
 
+extern const char *log_level(uint32_t level);
 extern struct stmt *log_stmt_alloc(const struct location *loc);
 
 
index c3b6fb22ceefecbe44de68cca2fa2d31e1e0b6f6..3c5ea0ff36a126eb7e88a5956a70f22cc5ec0506 100644 (file)
@@ -558,7 +558,7 @@ static void binop_arg_print(const struct expr *op, const struct expr *arg,
                nft_print(octx, ")");
 }
 
-static bool must_print_eq_op(const struct expr *expr)
+bool must_print_eq_op(const struct expr *expr)
 {
        return expr->left->ops->type == EXPR_BINOP;
 }
index 21bc69a9f0a38de2284efb0b0c7c7d7f1398d465..069411f0131f2d90d5d56bdc3df80f2bfdb98aa1 100644 (file)
--- a/src/fib.c
+++ b/src/fib.c
@@ -52,7 +52,7 @@ const struct datatype fib_addr_type = {
        .sym_tbl        = &addrtype_tbl,
 };
 
-static const char *fib_result_str(enum nft_fib_result result)
+const char *fib_result_str(enum nft_fib_result result)
 {
        if (result <= NFT_FIB_RESULT_MAX)
                return fib_result[result];
index 5f73bebc7531d3306e93a5daf940d09176728288..a3ed5179cfe361548089378e59cb96a9f7387cc7 100644 (file)
@@ -295,7 +295,7 @@ struct print_fmt_options {
        const char      *stmt_separator;
 };
 
-static const char *set_policy2str(uint32_t policy)
+const char *set_policy2str(uint32_t policy)
 {
        switch (policy) {
        case NFT_SET_POL_PERFORMANCE:
@@ -740,7 +740,7 @@ const char *hooknum2str(unsigned int family, unsigned int hooknum)
        return "unknown";
 }
 
-static const char *chain_policy2str(uint32_t policy)
+const char *chain_policy2str(uint32_t policy)
 {
        switch (policy) {
        case NF_DROP:
index a5ef7d7dfd2ebfde9f8ddd5c400b08e34f80fd86..6537bbbd9a20b89040cbc7be0b988316ab4e688f 100644 (file)
@@ -178,7 +178,7 @@ static const char *objref_type[NFT_OBJECT_MAX + 1] = {
        [NFT_OBJECT_LIMIT]      = "limit",
 };
 
-static const char *objref_type_name(uint32_t type)
+const char *objref_type_name(uint32_t type)
 {
        if (type > NFT_OBJECT_MAX)
                return "unknown";
@@ -225,7 +225,7 @@ static const char *syslog_level[LOG_DEBUG + 1] = {
        [LOG_DEBUG]     = "debug",
 };
 
-static const char *log_level(uint32_t level)
+const char *log_level(uint32_t level)
 {
        if (level > LOG_DEBUG)
                return "unknown";