From e77b31f53a61a8995cd6baf91a6e557260f401bd Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 8 May 2018 13:08:36 +0200 Subject: libnftables: Introduce a few helper functions This adds a bunch of functions for conversion of different values into string (and vice-versa). * log_level_parse(): A simple helper to turn log level string representation into log level value. * nat_etype2str(): Translate nat statement type into string representation. * ct_dir2str(): Convert IP_CT_DIR_* values into string representation. * ct_label2str(): Convert ct_label values into string representation. Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- include/ct.h | 2 ++ include/statement.h | 3 +++ 2 files changed, 5 insertions(+) (limited to 'include') diff --git a/include/ct.h b/include/ct.h index dadd820f..4c5bd804 100644 --- a/include/ct.h +++ b/include/ct.h @@ -33,6 +33,8 @@ extern void ct_expr_update_type(struct proto_ctx *ctx, struct expr *expr); extern struct stmt *notrack_stmt_alloc(const struct location *loc); extern struct stmt *flow_offload_stmt_alloc(const struct location *loc, const char *table_name); +extern const char *ct_dir2str(int dir); +extern const char *ct_label2str(unsigned long value); extern const struct datatype ct_dir_type; extern const struct datatype ct_state_type; diff --git a/include/statement.h b/include/statement.h index fc80dbd5..2c6d0dfa 100644 --- a/include/statement.h +++ b/include/statement.h @@ -77,6 +77,7 @@ struct log_stmt { }; extern const char *log_level(uint32_t level); +extern int log_level_parse(const char *level); extern struct stmt *log_stmt_alloc(const struct location *loc); @@ -107,6 +108,8 @@ enum nft_nat_etypes { NFT_NAT_REDIR, }; +extern const char *nat_etype2str(enum nft_nat_etypes type); + struct nat_stmt { enum nft_nat_etypes type; struct expr *addr; -- cgit v1.2.3