]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
expr: Introduce nftnl_expr_fprintf()
authorPhil Sutter <phil@nwl.cc>
Tue, 17 Oct 2017 13:17:41 +0000 (15:17 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 17 Oct 2017 13:18:37 +0000 (15:18 +0200)
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>
include/libnftnl/expr.h
src/expr.c
src/libnftnl.map

index 76f28fee7b5f7550dce742dd2f4797b603b870be..f37f50963d6c394cb8ccbaeaeecf61ebd198b33e 100644 (file)
@@ -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,
index c5fcf06492ae2bf8c3c189078ee516380ea0628a..1eae70787209db05cc733e0f8843969ec53235d9 100644 (file)
@@ -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);
index 1892c983eb504f30f47ea6fbe95ab6c1a3ed3adc..d59e80269604cc28c6b2765b8bbd6fdddb0eb839 100644 (file)
@@ -307,3 +307,7 @@ global:
 
 local: *;
 };
+
+LIBNFTNL_6 {
+  nftnl_expr_fprintf;
+} LIBNFTNL_5;