From 5c3bc232dc9d1dd01d589fab096f67d944621fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Falgueras=20Garc=C3=ADa?= Date: Tue, 22 Mar 2016 20:46:24 +0100 Subject: udata: add TLV user data infrastructure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These functions allow to create a buffer (struct nftnl_udata_buf) of user data attributes in TLV format (struct nftnl_udata). It is inspired by libmnl/src/attr.c. It can be used to store several TLVs sequentially into an object. Example: struct nftnl_udata_buf *buf; struct nftnl_udata *attr; const char *str = "Hello World!"; buf = nftnl_udata_buf_alloc(UDATA_SIZE); if (!buf) { perror("OOM"); exit(EXIT_FAILURE); } if (!nftnl_udata_put_strz(buf, MY_TYPE, str)) { perror("Can't put attribute \"%s\"", str); exit(EXIT_FAILURE); } nftnl_udata_for_each(buf, attr) printf("%s\n", (char *)nftnl_udata_attr_value(attr)); nftnl_udata_buf_free(buf); Signed-off-by: Carlos Falgueras GarcĂ­a Signed-off-by: Pablo Neira Ayuso --- src/libnftnl.map | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/libnftnl.map') diff --git a/src/libnftnl.map b/src/libnftnl.map index 2e193b7..c38e081 100644 --- a/src/libnftnl.map +++ b/src/libnftnl.map @@ -512,4 +512,19 @@ LIBNFTNL_4.1 { nftnl_trace_get_data; nftnl_trace_nlmsg_parse; + + nftnl_udata_buf_alloc; + nftnl_udata_buf_free; + nftnl_udata_buf_len; + nftnl_udata_buf_data; + nftnl_udata_buf_put; + nftnl_udata_start; + nftnl_udata_end; + nftnl_udata_put; + nftnl_udata_put_strz; + nftnl_udata_type; + nftnl_udata_len; + nftnl_udata_get; + nftnl_udata_next; + nftnl_udata_parse; } LIBNFTNL_4; -- cgit v1.2.3