diff mbox series

[libnftnl,v3] expr: Introduce nftnl_expr_fprintf()

Message ID 20171017131741.2026-1-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
Series [libnftnl,v3] expr: Introduce nftnl_expr_fprintf() | expand

Commit Message

Phil Sutter Oct. 17, 2017, 1:17 p.m. UTC
Implement expression printing into a FILE pointer analogous to
nftnl_rule_fprintf().

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
Changes since v2:
- Fix src/libnftnl.map update.

Changes since v1:
- Update src/libnftnl.map.
---
 include/libnftnl/expr.h |  1 +
 src/expr.c              | 14 ++++++++++++++
 src/libnftnl.map        |  4 ++++
 3 files changed, 19 insertions(+)

Comments

Pablo Neira Ayuso Oct. 17, 2017, 1:19 p.m. UTC | #1
On Tue, Oct 17, 2017 at 03:17:41PM +0200, Phil Sutter wrote:
> Implement expression printing into a FILE pointer analogous to
> nftnl_rule_fprintf().

Applied, thanks Phil!
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/include/libnftnl/expr.h b/include/libnftnl/expr.h
index 76f28fee7b5f7..f37f50963d6c3 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,
diff --git a/src/expr.c b/src/expr.c
index c5fcf06492ae2..1eae70787209d 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -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 1892c983eb504..d59e80269604c 100644
--- a/src/libnftnl.map
+++ b/src/libnftnl.map
@@ -307,3 +307,7 @@  global:
 
 local: *;
 };
+
+LIBNFTNL_6 {
+  nftnl_expr_fprintf;
+} LIBNFTNL_5;