From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH libnftnl] udata: add nftnl_udata_put_u32() and nftnl_udata_get_u32()
Date: Mon, 6 Mar 2017 17:47:54 +0100 [thread overview]
Message-ID: <1488818874-4089-1-git-send-email-pablo@netfilter.org> (raw)
Add new helper function to put and to fetch tlv that comes with u32
payload.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/libnftnl/udata.h | 3 +++
src/libnftnl.map | 2 ++
src/udata.c | 15 +++++++++++++++
3 files changed, 20 insertions(+)
diff --git a/include/libnftnl/udata.h b/include/libnftnl/udata.h
index d36cef73feb5..e6f80f98b012 100644
--- a/include/libnftnl/udata.h
+++ b/include/libnftnl/udata.h
@@ -24,6 +24,8 @@ struct nftnl_udata *nftnl_udata_end(const struct nftnl_udata_buf *buf);
/* putters */
bool nftnl_udata_put(struct nftnl_udata_buf *buf, uint8_t type, uint32_t len,
const void *value);
+bool nftnl_udata_put_u32(struct nftnl_udata_buf *buf, uint8_t type,
+ uint32_t data);
bool nftnl_udata_put_strz(struct nftnl_udata_buf *buf, uint8_t type,
const char *strz);
@@ -31,6 +33,7 @@ bool nftnl_udata_put_strz(struct nftnl_udata_buf *buf, uint8_t type,
uint8_t nftnl_udata_type(const struct nftnl_udata *attr);
uint8_t nftnl_udata_len(const struct nftnl_udata *attr);
void *nftnl_udata_get(const struct nftnl_udata *attr);
+uint32_t nftnl_udata_get_u32(const struct nftnl_udata *attr);
/* iterator */
struct nftnl_udata *nftnl_udata_next(const struct nftnl_udata *attr);
diff --git a/src/libnftnl.map b/src/libnftnl.map
index 4282367db5b8..4c082102aa29 100644
--- a/src/libnftnl.map
+++ b/src/libnftnl.map
@@ -261,9 +261,11 @@ global:
nftnl_udata_end;
nftnl_udata_put;
nftnl_udata_put_strz;
+ nftnl_udata_put_u32;
nftnl_udata_type;
nftnl_udata_len;
nftnl_udata_get;
+ nftnl_udata_get_u32;
nftnl_udata_next;
nftnl_udata_parse;
diff --git a/src/udata.c b/src/udata.c
index 60c2f34fa3f5..d679dd053d11 100644
--- a/src/udata.c
+++ b/src/udata.c
@@ -94,6 +94,13 @@ bool nftnl_udata_put_strz(struct nftnl_udata_buf *buf, uint8_t type,
}
EXPORT_SYMBOL(nftnl_udata_put_strz);
+bool nftnl_udata_put_u32(struct nftnl_udata_buf *buf, uint8_t type,
+ uint32_t data)
+{
+ return nftnl_udata_put(buf, type, sizeof(data), &data);
+}
+EXPORT_SYMBOL(nftnl_udata_put_u32);
+
uint8_t nftnl_udata_type(const struct nftnl_udata *attr)
{
return attr->type;
@@ -112,6 +119,14 @@ void *nftnl_udata_get(const struct nftnl_udata *attr)
}
EXPORT_SYMBOL(nftnl_udata_get);
+uint32_t nftnl_udata_get_u32(const struct nftnl_udata *attr)
+{
+ uint32_t *data = (uint32_t *)attr->value;
+
+ return *data;
+}
+EXPORT_SYMBOL(nftnl_udata_get_u32);
+
struct nftnl_udata *nftnl_udata_next(const struct nftnl_udata *attr)
{
return (struct nftnl_udata *)&attr->value[attr->len];
--
2.1.4
reply other threads:[~2017-03-06 16:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1488818874-4089-1-git-send-email-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;
as well as URLs for NNTP newsgroup(s).