path: root/include/libnftables
diff options
authorPablo Neira Ayuso <>2013-02-02 12:17:31 +0100
committerPablo Neira Ayuso <>2013-02-05 13:55:02 +0100
commitd2a0036dd3e16d40f4039a11677241827ea057c5 (patch)
tree757e14859d225f34ad5499e554957476f9647785 /include/libnftables
parentd07d9c1911739037be2db1d54a59aadf5c2d4adc (diff)
set: add support to add elements to sets
This patch includes iterators and several examples. Signed-off-by: Pablo Neira Ayuso <>
Diffstat (limited to 'include/libnftables')
1 files changed, 41 insertions, 0 deletions
diff --git a/include/libnftables/set.h b/include/libnftables/set.h
index e56fb50..53c067b 100644
--- a/include/libnftables/set.h
+++ b/include/libnftables/set.h
@@ -27,6 +27,7 @@ uint32_t nft_set_attr_get_u32(struct nft_set *s, uint16_t attr);
struct nlmsghdr *nft_set_nlmsg_build_hdr(char *buf, uint16_t cmd, uint16_t family, uint16_t type, uint32_t seq);
void nft_set_nlmsg_build_payload(struct nlmsghdr *nlh, struct nft_set *s);
int nft_set_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_set *s);
+int nft_set_elems_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_set *s);
int nft_set_snprintf(char *buf, size_t size, struct nft_set *s, uint32_t type, uint32_t flags);
@@ -42,4 +43,44 @@ struct nft_set *nft_set_list_iter_cur(struct nft_set_list_iter *iter);
struct nft_set *nft_set_list_iter_next(struct nft_set_list_iter *iter);
void nft_set_list_iter_destroy(struct nft_set_list_iter *iter);
+ * Set elements
+ */
+enum {
+struct nft_set_elem;
+struct nft_set_elem *nft_set_elem_alloc(void);
+void nft_set_elem_free(struct nft_set_elem *s);
+void nft_set_elem_add(struct nft_set *s, struct nft_set_elem *elem);
+void nft_set_elem_attr_set(struct nft_set_elem *s, uint16_t attr, const void *data, size_t data_len);
+void nft_set_elem_attr_set_u32(struct nft_set_elem *s, uint16_t attr, uint32_t val);
+void nft_set_elem_attr_set_str(struct nft_set_elem *s, uint16_t attr, char *str);
+void *nft_set_elem_attr_get(struct nft_set_elem *s, uint16_t attr, size_t *data_len);
+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);
+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);
+int nft_set_elem_nlmsg_parse(const struct nlmsghdr *nlh, struct nft_set_elem *s);
+int nft_set_elem_snprintf(char *buf, size_t size, struct nft_set_elem *s, uint32_t type, uint32_t flags);
+struct nft_set_elems_iter;
+struct nft_set_elems_iter *nft_set_elems_iter_create(struct nft_set *s);
+struct nft_set_elem *nft_set_elems_iter_cur(struct nft_set_elems_iter *iter);
+struct nft_set_elem *nft_set_elems_iter_next(struct nft_set_elems_iter *iter);
+void nft_set_elems_iter_destroy(struct nft_set_elems_iter *iter);