diff options
author | Phil Sutter <phil@nwl.cc> | 2017-10-17 15:17:41 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-10-17 15:18:37 +0200 |
commit | 3dc1c825d76b678620a13f4f446d384badad5670 (patch) | |
tree | 8832f7104c05d2afa5990b475d3f83b7bf008c91 | |
parent | 39fdce1dd8cd5e614da7668cacc9584c88e33e36 (diff) |
expr: Introduce nftnl_expr_fprintf()
Implement expression printing into a FILE pointer analogous to
nftnl_rule_fprintf().
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | include/libnftnl/expr.h | 1 | ||||
-rw-r--r-- | src/expr.c | 14 | ||||
-rw-r--r-- | src/libnftnl.map | 4 |
3 files changed, 19 insertions, 0 deletions
diff --git a/include/libnftnl/expr.h b/include/libnftnl/expr.h index 76f28fe..f37f509 100644 --- a/include/libnftnl/expr.h +++ b/include/libnftnl/expr.h @@ -39,6 +39,7 @@ const char *nftnl_expr_get_str(const struct nftnl_expr *expr, uint16_t type); bool nftnl_expr_cmp(const struct nftnl_expr *e1, const struct nftnl_expr *e2); int nftnl_expr_snprintf(char *buf, size_t buflen, const struct nftnl_expr *expr, uint32_t type, uint32_t flags); +int nftnl_expr_fprintf(FILE *fp, const struct nftnl_expr *expr, uint32_t type, uint32_t flags); enum { NFTNL_EXPR_PAYLOAD_DREG = NFTNL_EXPR_BASE, @@ -293,3 +293,17 @@ int nftnl_expr_snprintf(char *buf, size_t size, const struct nftnl_expr *expr, return offset; } EXPORT_SYMBOL(nftnl_expr_snprintf); + +static int nftnl_expr_do_snprintf(char *buf, size_t size, const void *e, + uint32_t cmd, uint32_t type, uint32_t flags) +{ + return nftnl_expr_snprintf(buf, size, e, type, flags); +} + +int nftnl_expr_fprintf(FILE *fp, const struct nftnl_expr *expr, uint32_t type, + uint32_t flags) +{ + return nftnl_fprintf(fp, expr, NFTNL_CMD_UNSPEC, type, flags, + nftnl_expr_do_snprintf); +} +EXPORT_SYMBOL(nftnl_expr_fprintf); diff --git a/src/libnftnl.map b/src/libnftnl.map index 1892c98..d59e802 100644 --- a/src/libnftnl.map +++ b/src/libnftnl.map @@ -307,3 +307,7 @@ global: local: *; }; + +LIBNFTNL_6 { + nftnl_expr_fprintf; +} LIBNFTNL_5; |