From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH libnftnl 2/2] udata: support for TLV attribute nesting
Date: Mon, 16 Dec 2019 13:46:59 +0100 [thread overview]
Message-ID: <20191216124659.357458-2-pablo@netfilter.org> (raw)
In-Reply-To: <20191216124659.357458-1-pablo@netfilter.org>
This patch adds nftnl_udata_nest_start() and nftnl_udata_nest_end()
to build attribute nests.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/libnftnl/udata.h | 5 +++++
src/libnftnl.map | 5 +++++
src/udata.c | 17 +++++++++++++++++
3 files changed, 27 insertions(+)
diff --git a/include/libnftnl/udata.h b/include/libnftnl/udata.h
index 591fa77aa5e7..8044041189b1 100644
--- a/include/libnftnl/udata.h
+++ b/include/libnftnl/udata.h
@@ -75,6 +75,11 @@ bool nftnl_udata_put_u32(struct nftnl_udata_buf *buf, uint8_t type,
bool nftnl_udata_put_strz(struct nftnl_udata_buf *buf, uint8_t type,
const char *strz);
+/* nest */
+struct nftnl_udata *nftnl_udata_nest_start(struct nftnl_udata_buf *buf,
+ uint8_t type);
+void nftnl_udata_nest_end(struct nftnl_udata_buf *buf, struct nftnl_udata *ud);
+
/* nftnl_udata_attr */
uint8_t nftnl_udata_type(const struct nftnl_udata *attr);
uint8_t nftnl_udata_len(const struct nftnl_udata *attr);
diff --git a/src/libnftnl.map b/src/libnftnl.map
index 8230d1519e8e..5ba8d995440e 100644
--- a/src/libnftnl.map
+++ b/src/libnftnl.map
@@ -359,3 +359,8 @@ LIBNFTNL_13 {
nftnl_obj_set_data;
nftnl_flowtable_set_data;
} LIBNFTNL_12;
+
+LIBNFTNL_14 {
+ nftnl_udata_nest_start;
+ nftnl_udata_nest_end;
+} LIBNFTNL_13;
diff --git a/src/udata.c b/src/udata.c
index 9f17395833b8..a47f9239abf8 100644
--- a/src/udata.c
+++ b/src/udata.c
@@ -150,3 +150,20 @@ int nftnl_udata_parse(const void *data, uint32_t data_len, nftnl_udata_cb_t cb,
return ret;
}
+
+EXPORT_SYMBOL(nftnl_udata_nest_start);
+struct nftnl_udata *nftnl_udata_nest_start(struct nftnl_udata_buf *buf,
+ uint8_t type)
+{
+ struct nftnl_udata *ud = nftnl_udata_end(buf);
+
+ nftnl_udata_put(buf, type, 0, NULL);
+
+ return ud;
+}
+
+EXPORT_SYMBOL(nftnl_udata_nest_end);
+void nftnl_udata_nest_end(struct nftnl_udata_buf *buf, struct nftnl_udata *ud)
+{
+ ud->len = buf->end - (char *)ud;
+}
--
2.11.0
prev parent reply other threads:[~2019-12-16 12:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-16 12:46 [PATCH libnftnl 1/2] udata: add NFTNL_UDATA_SET_*TYPEOF* definitions Pablo Neira Ayuso
2019-12-16 12:46 ` Pablo Neira Ayuso [this message]
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=20191216124659.357458-2-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.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