[PATCH libnftnl 2/2] udata: support for TLV attribute nesting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds nftnl_udata_nest_start() and nftnl_udata_nest_end()
to build attribute nests.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 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




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux