]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
udata: add nftnl_udata_put_u32() and nftnl_udata_get_u32()
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 6 Mar 2017 13:27:24 +0000 (14:27 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 6 Mar 2017 17:27:10 +0000 (18:27 +0100)
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
src/libnftnl.map
src/udata.c

index d36cef73feb5a2de07d5af52b17900e7358f30cd..e6f80f98b012856ee0baa07cdf65fc140dbae7f0 100644 (file)
@@ -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);
index 4282367db5b8f1e8f142e7be1ebf77bfa9a379ce..4c082102aa297a4e0b27626684c9f36d83533ca5 100644 (file)
@@ -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;
 
index 60c2f34fa3f5a8bac47b8a06a00f9e932f0a9002..d679dd053d111952eb54d53b26233ef632ed8f06 100644 (file)
@@ -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];