summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorVarsha Rao <rvarsha016@gmail.com>2017-06-16 14:54:06 +0530
committerPablo Neira Ayuso <pablo@netfilter.org>2017-06-18 11:23:00 +0200
commit35f6cd327c2ec46296adf464f981cd6cddfec27b (patch)
tree7341c05e6f7499fa3da18a4e50dd9db0ca36339b /include
parent509671dfa03365bba727b8be5e522b737da93a6f (diff)
src: Pass stateless, numeric, ip2name and handle variables as structure members.
libnftables library will be created soon. So declare numeric_output, stateless_output, ip2name_output and handle_output as members of structure output_ctx, instead of global variables. Rename these variables as following, numeric_output -> numeric stateless_output -> stateless ip2name_output -> ip2name handle_output -> handle Also add struct output_ctx *octx as member of struct netlink_ctx. Signed-off-by: Varsha Rao <rvarsha016@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include')
-rw-r--r--include/cli.h4
-rw-r--r--include/datatype.h8
-rw-r--r--include/expression.h5
-rw-r--r--include/netlink.h2
-rw-r--r--include/nftables.h14
-rw-r--r--include/rule.h10
-rw-r--r--include/statement.h5
7 files changed, 29 insertions, 19 deletions
diff --git a/include/cli.h b/include/cli.h
index 89cb9761..1ae12376 100644
--- a/include/cli.h
+++ b/include/cli.h
@@ -5,9 +5,9 @@
struct parser_state;
#ifdef HAVE_LIBREADLINE
-extern int cli_init(struct parser_state *state);
+extern int cli_init(struct parser_state *state, struct output_ctx *octx);
#else
-static inline int cli_init(struct parser_state *state)
+static inline int cli_init(struct parser_state *state, struct output_ctx *octx)
{
return -1;
}
diff --git a/include/datatype.h b/include/datatype.h
index 04b7d880..58c4d3e0 100644
--- a/include/datatype.h
+++ b/include/datatype.h
@@ -145,7 +145,8 @@ struct datatype {
const char *desc;
const struct datatype *basetype;
const char *basefmt;
- void (*print)(const struct expr *expr);
+ void (*print)(const struct expr *expr,
+ struct output_ctx *octx);
struct error_record *(*parse)(const struct expr *sym,
struct expr **res);
const struct symbol_table *sym_tbl;
@@ -157,7 +158,7 @@ extern const struct datatype *datatype_lookup_byname(const char *name);
extern struct error_record *symbol_parse(const struct expr *sym,
struct expr **res);
-extern void datatype_print(const struct expr *expr);
+extern void datatype_print(const struct expr *expr, struct output_ctx *octx);
static inline bool datatype_equal(const struct datatype *d1,
const struct datatype *d2)
@@ -205,7 +206,8 @@ extern struct error_record *symbolic_constant_parse(const struct expr *sym,
const struct symbol_table *tbl,
struct expr **res);
extern void symbolic_constant_print(const struct symbol_table *tbl,
- const struct expr *expr, bool quotes);
+ const struct expr *expr, bool quotes,
+ struct output_ctx *octx);
extern void symbol_table_print(const struct symbol_table *tbl,
const struct datatype *dtype,
enum byteorder byteorder);
diff --git a/include/expression.h b/include/expression.h
index 9ba87e82..3e67938a 100644
--- a/include/expression.h
+++ b/include/expression.h
@@ -157,7 +157,8 @@ struct expr_ops {
void (*set_type)(const struct expr *expr,
const struct datatype *dtype,
enum byteorder byteorder);
- void (*print)(const struct expr *expr);
+ void (*print)(const struct expr *expr,
+ struct output_ctx *octx);
bool (*cmp)(const struct expr *e1,
const struct expr *e2);
void (*pctx_update)(struct proto_ctx *ctx,
@@ -330,7 +331,7 @@ extern struct expr *expr_alloc(const struct location *loc,
extern struct expr *expr_clone(const struct expr *expr);
extern struct expr *expr_get(struct expr *expr);
extern void expr_free(struct expr *expr);
-extern void expr_print(const struct expr *expr);
+extern void expr_print(const struct expr *expr, struct output_ctx *octx);
extern bool expr_cmp(const struct expr *e1, const struct expr *e2);
extern void expr_describe(const struct expr *expr);
diff --git a/include/netlink.h b/include/netlink.h
index 81538fff..bb25ad48 100644
--- a/include/netlink.h
+++ b/include/netlink.h
@@ -38,6 +38,7 @@ extern const struct location netlink_location;
* @set: current set
* @data: pointer to pass data to callback
* @seqnum: sequence number
+ * @octx: output context
*/
struct netlink_ctx {
struct list_head *msgs;
@@ -47,6 +48,7 @@ struct netlink_ctx {
uint32_t seqnum;
struct nftnl_batch *batch;
bool batch_supported;
+ struct output_ctx *octx;
};
extern struct nftnl_table *alloc_nftnl_table(const struct handle *h);
diff --git a/include/nftables.h b/include/nftables.h
index 6f541557..9e10be07 100644
--- a/include/nftables.h
+++ b/include/nftables.h
@@ -24,11 +24,14 @@ enum debug_level {
#define INCLUDE_PATHS_MAX 16
+struct output_ctx {
+ unsigned int numeric;
+ unsigned int stateless;
+ unsigned int ip2name;
+ unsigned int handle;
+};
+
extern unsigned int max_errors;
-extern unsigned int numeric_output;
-extern unsigned int stateless_output;
-extern unsigned int ip2name_output;
-extern unsigned int handle_output;
extern unsigned int debug_level;
extern const char *include_paths[INCLUDE_PATHS_MAX];
@@ -107,6 +110,7 @@ struct input_descriptor {
struct parser_state;
-int nft_run(void *scanner, struct parser_state *state, struct list_head *msgs);
+int nft_run(void *scanner, struct parser_state *state, struct list_head *msgs,
+ struct output_ctx *octx);
#endif /* NFTABLES_NFTABLES_H */
diff --git a/include/rule.h b/include/rule.h
index 3178a978..7424b21c 100644
--- a/include/rule.h
+++ b/include/rule.h
@@ -198,7 +198,7 @@ extern struct rule *rule_alloc(const struct location *loc,
const struct handle *h);
extern struct rule *rule_get(struct rule *rule);
extern void rule_free(struct rule *rule);
-extern void rule_print(const struct rule *rule);
+extern void rule_print(const struct rule *rule, struct output_ctx *octx);
extern struct rule *rule_lookup(const struct chain *chain, uint64_t handle);
/**
@@ -247,8 +247,8 @@ 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);
-extern void set_print(const struct set *set);
-extern void set_print_plain(const struct set *s);
+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);
#include <statement.h>
@@ -297,8 +297,8 @@ void obj_free(struct obj *obj);
void obj_add_hash(struct obj *obj, struct table *table);
struct obj *obj_lookup(const struct table *table, const char *name,
uint32_t type);
-void obj_print(const struct obj *n);
-void obj_print_plain(const struct obj *obj);
+void obj_print(const struct obj *n, struct output_ctx *octx);
+void obj_print_plain(const struct obj *obj, struct output_ctx *octx);
const char *obj_type_name(uint32_t type);
uint32_t obj_type_to_cmd(uint32_t type);
diff --git a/include/statement.h b/include/statement.h
index 317d53e2..49fb1091 100644
--- a/include/statement.h
+++ b/include/statement.h
@@ -261,7 +261,8 @@ struct stmt_ops {
enum stmt_types type;
const char *name;
void (*destroy)(struct stmt *stmt);
- void (*print)(const struct stmt *stmt);
+ void (*print)(const struct stmt *stmt,
+ struct output_ctx *octx);
};
enum stmt_flags {
@@ -312,7 +313,7 @@ extern struct stmt *stmt_alloc(const struct location *loc,
int stmt_evaluate(struct eval_ctx *ctx, struct stmt *stmt);
extern void stmt_free(struct stmt *stmt);
extern void stmt_list_free(struct list_head *list);
-extern void stmt_print(const struct stmt *stmt);
+extern void stmt_print(const struct stmt *stmt, struct output_ctx *octx);
const char *get_rate(uint64_t byte_rate, uint64_t *rate);