From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [libnftnl PATCH v3] expr: Introduce nftnl_expr_fprintf()
Date: Tue, 17 Oct 2017 15:17:41 +0200 [thread overview]
Message-ID: <20171017131741.2026-1-phil@nwl.cc> (raw)
In-Reply-To: <20171017121145.GA18793@salvia>
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(+)
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;
--
2.13.1
next prev parent reply other threads:[~2017-10-17 13:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 21:36 [libnftnl PATCH] expr: Introduce nftnl_expr_fprintf() Phil Sutter
2017-10-17 11:05 ` Pablo Neira Ayuso
2017-10-17 11:22 ` [libnftnl PATCH v2] " Phil Sutter
2017-10-17 11:31 ` Pablo Neira Ayuso
2017-10-17 11:54 ` Phil Sutter
2017-10-17 12:02 ` Phil Sutter
2017-10-17 12:11 ` Pablo Neira Ayuso
2017-10-17 13:17 ` Phil Sutter [this message]
2017-10-17 13:19 ` [libnftnl PATCH v3] " Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171017131741.2026-1-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).