summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libnftables/chain.h2
-rw-r--r--include/libnftables/expr.h1
-rw-r--r--include/libnftables/rule.h2
-rw-r--r--include/libnftables/set.h6
-rw-r--r--include/libnftables/table.h2
-rw-r--r--src/chain.c6
-rw-r--r--src/expr.c6
-rw-r--r--src/libnftables.map6
-rw-r--r--src/rule.c6
-rw-r--r--src/set.c6
-rw-r--r--src/set_elem.c6
-rw-r--r--src/table.c6
12 files changed, 55 insertions, 0 deletions
diff --git a/include/libnftables/chain.h b/include/libnftables/chain.h
index 313c26a..29f7bc7 100644
--- a/include/libnftables/chain.h
+++ b/include/libnftables/chain.h
@@ -2,6 +2,7 @@
#define _CHAIN_H_
#include <stdint.h>
+#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
@@ -26,6 +27,7 @@ enum {
NFT_CHAIN_ATTR_TYPE,
};
+bool nft_chain_attr_is_set(struct nft_chain *c, uint16_t attr);
void nft_chain_attr_unset(struct nft_chain *c, uint16_t attr);
void nft_chain_attr_set(struct nft_chain *t, uint16_t attr, const void *data);
void nft_chain_attr_set_u32(struct nft_chain *t, uint16_t attr, uint32_t data);
diff --git a/include/libnftables/expr.h b/include/libnftables/expr.h
index bd3fd6e..1ab5590 100644
--- a/include/libnftables/expr.h
+++ b/include/libnftables/expr.h
@@ -15,6 +15,7 @@ enum {
struct nft_rule_expr *nft_rule_expr_alloc(const char *name);
void nft_rule_expr_free(struct nft_rule_expr *expr);
+bool nft_rule_expr_is_set(const struct nft_rule_expr *expr, uint16_t type);
void nft_rule_expr_set(struct nft_rule_expr *expr, uint16_t type, const void *data, size_t data_len);
void nft_rule_expr_set_u8(struct nft_rule_expr *expr, uint16_t type, uint8_t data);
void nft_rule_expr_set_u32(struct nft_rule_expr *expr, uint16_t type, uint32_t data);
diff --git a/include/libnftables/rule.h b/include/libnftables/rule.h
index ce8bd1f..242ea07 100644
--- a/include/libnftables/rule.h
+++ b/include/libnftables/rule.h
@@ -2,6 +2,7 @@
#define _RULE_H_
#include <stdint.h>
+#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
@@ -24,6 +25,7 @@ enum {
};
void nft_rule_attr_unset(struct nft_rule *r, uint16_t attr);
+bool nft_rule_attr_is_set(struct nft_rule *r, uint16_t attr);
void nft_rule_attr_set(struct nft_rule *r, uint16_t attr, const void *data);
void nft_rule_attr_set_u32(struct nft_rule *r, uint16_t attr, uint32_t val);
void nft_rule_attr_set_u64(struct nft_rule *r, uint16_t attr, uint64_t val);
diff --git a/include/libnftables/set.h b/include/libnftables/set.h
index f337f60..bcd4db7 100644
--- a/include/libnftables/set.h
+++ b/include/libnftables/set.h
@@ -1,6 +1,9 @@
#ifndef _NFT_SET_H_
#define _NFT_SET_H_
+#include <stdint.h>
+#include <stdbool.h>
+
enum {
NFT_SET_ATTR_TABLE,
NFT_SET_ATTR_NAME,
@@ -16,6 +19,7 @@ struct nft_set;
struct nft_set *nft_set_alloc(void);
void nft_set_free(struct nft_set *s);
+bool nft_set_attr_is_set(struct nft_set *s, uint16_t attr);
void nft_set_attr_unset(struct nft_set *s, uint16_t attr);
void nft_set_attr_set(struct nft_set *s, uint16_t attr, const void *data);
void nft_set_attr_set_u32(struct nft_set *s, uint16_t attr, uint32_t val);
@@ -73,6 +77,8 @@ void *nft_set_elem_attr_get(struct nft_set_elem *s, uint16_t attr, size_t *data_
const char *nft_set_elem_attr_get_str(struct nft_set_elem *s, uint16_t attr);
uint32_t nft_set_elem_attr_get_u32(struct nft_set_elem *s, uint16_t attr);
+bool nft_set_elem_attr_is_set(struct nft_set_elem *s, uint16_t attr);
+
struct nlmsghdr *nft_set_elem_nlmsg_build_hdr(char *buf, uint16_t cmd, uint16_t family, uint16_t type, uint32_t seq);
void nft_set_elems_nlmsg_build_payload(struct nlmsghdr *nlh, struct nft_set *s);
void nft_set_elem_nlmsg_build_payload(struct nlmsghdr *nlh, struct nft_set_elem *e);
diff --git a/include/libnftables/table.h b/include/libnftables/table.h
index 8a4778f..9445879 100644
--- a/include/libnftables/table.h
+++ b/include/libnftables/table.h
@@ -2,6 +2,7 @@
#define _TABLE_H_
#include <stdint.h>
+#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
@@ -18,6 +19,7 @@ enum {
NFT_TABLE_ATTR_FLAGS,
};
+bool nft_table_attr_is_set(struct nft_table *t, uint16_t attr);
void nft_table_attr_unset(struct nft_table *t, uint16_t attr);
void nft_table_attr_set(struct nft_table *t, uint16_t attr, const void *data);
const void *nft_table_attr_get(struct nft_table *t, uint16_t attr);
diff --git a/src/chain.c b/src/chain.c
index 62a6ddd..4f85606 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -59,6 +59,12 @@ void nft_chain_free(struct nft_chain *c)
}
EXPORT_SYMBOL(nft_chain_free);
+bool nft_chain_attr_is_set(struct nft_chain *c, uint16_t attr)
+{
+ return c->flags & (1 << attr);
+}
+EXPORT_SYMBOL(nft_chain_attr_is_set);
+
void nft_chain_attr_unset(struct nft_chain *c, uint16_t attr)
{
switch (attr) {
diff --git a/src/expr.c b/src/expr.c
index 3a66986..0ee2c4b 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -53,6 +53,12 @@ void nft_rule_expr_free(struct nft_rule_expr *expr)
}
EXPORT_SYMBOL(nft_rule_expr_free);
+bool nft_rule_expr_is_set(const struct nft_rule_expr *expr, uint16_t type)
+{
+ return expr->flags & (1 << type);
+}
+EXPORT_SYMBOL(nft_rule_expr_is_set);
+
void
nft_rule_expr_set(struct nft_rule_expr *expr, uint16_t type,
const void *data, size_t data_len)
diff --git a/src/libnftables.map b/src/libnftables.map
index 6ee7a36..7be6588 100644
--- a/src/libnftables.map
+++ b/src/libnftables.map
@@ -2,6 +2,7 @@ LIBNFTABLES_1.0 {
global:
nft_table_alloc;
nft_table_free;
+ nft_table_attr_is_set;
nft_table_attr_unset;
nft_table_attr_set;
nft_table_attr_get;
@@ -24,6 +25,7 @@ global:
nft_chain_alloc;
nft_chain_free;
+ nft_chain_attr_is_set;
nft_chain_attr_unset;
nft_chain_attr_set;
nft_chain_attr_set_u32;
@@ -51,6 +53,7 @@ global:
nft_rule_alloc;
nft_rule_free;
+ nft_rule_attr_is_set;
nft_rule_attr_unset;
nft_rule_attr_set;
nft_rule_attr_set_u32;
@@ -74,6 +77,7 @@ global:
nft_rule_expr_iter_destroy;
nft_rule_expr_alloc;
+ nft_rule_expr_is_set;
nft_rule_expr_set;
nft_rule_expr_set_u8;
nft_rule_expr_set_u32;
@@ -99,6 +103,7 @@ global:
nft_set_alloc;
nft_set_free;
nft_set_attr_unset;
+ nft_set_attr_is_set;
nft_set_attr_set;
nft_set_attr_set_u32;
nft_set_attr_set_str;
@@ -124,6 +129,7 @@ global:
nft_set_elem_free;
nft_set_elem_add;
nft_set_elem_foreach;
+ nft_set_elem_attr_is_set;
nft_set_elem_attr_unset;
nft_set_elem_attr_set;
nft_set_elem_attr_set_u32;
diff --git a/src/rule.c b/src/rule.c
index 13b5a11..67062cf 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -71,6 +71,12 @@ void nft_rule_free(struct nft_rule *r)
}
EXPORT_SYMBOL(nft_rule_free);
+bool nft_rule_attr_is_set(struct nft_rule *r, uint16_t attr)
+{
+ return r->flags & (1 << attr);
+}
+EXPORT_SYMBOL(nft_rule_attr_is_set);
+
void nft_rule_attr_unset(struct nft_rule *r, uint16_t attr)
{
switch (attr) {
diff --git a/src/set.c b/src/set.c
index 4d16062..61a0c2e 100644
--- a/src/set.c
+++ b/src/set.c
@@ -56,6 +56,12 @@ void nft_set_free(struct nft_set *s)
}
EXPORT_SYMBOL(nft_set_free);
+bool nft_set_attr_is_set(struct nft_set *s, uint16_t attr)
+{
+ return s->flags & (1 << attr);
+}
+EXPORT_SYMBOL(nft_set_attr_is_set);
+
void nft_set_attr_unset(struct nft_set *s, uint16_t attr)
{
switch (attr) {
diff --git a/src/set_elem.c b/src/set_elem.c
index 209227f..eb9cb7a 100644
--- a/src/set_elem.c
+++ b/src/set_elem.c
@@ -44,6 +44,12 @@ void nft_set_elem_free(struct nft_set_elem *s)
}
EXPORT_SYMBOL(nft_set_elem_free);
+bool nft_set_elem_attr_is_set(struct nft_set_elem *s, uint16_t attr)
+{
+ return s->flags & (1 << attr);
+}
+EXPORT_SYMBOL(nft_set_elem_attr_is_set);
+
void nft_set_elem_attr_unset(struct nft_set_elem *s, uint16_t attr)
{
switch (attr) {
diff --git a/src/table.c b/src/table.c
index 3e8d4c9..c33f01c 100644
--- a/src/table.c
+++ b/src/table.c
@@ -49,6 +49,12 @@ void nft_table_free(struct nft_table *t)
}
EXPORT_SYMBOL(nft_table_free);
+bool nft_table_attr_is_set(struct nft_table *t, uint16_t attr)
+{
+ return t->flags & (1 << attr);
+}
+EXPORT_SYMBOL(nft_table_attr_is_set);
+
void nft_table_attr_unset(struct nft_table *t, uint16_t attr)
{
switch (attr) {