src: add string API support
Pablo Neira Ayuso
maintainerRFC PATCH 1/3 src: add string API support
This patch adds strset object that represent a "string set" object. There is also str object that represent a list of patterns to be added/deleted to the "string set".
This patch provides 6 example files to create "string set" and populate them with patterns:
examples/nft-str-add.c
examples/nft-str-del.c
examples/nft-str-get.c
examples/nft-strset-add.c
examples/nft-strset-del.c
examples/nft-strset-get.c
--- examples/Makefile.am | 26 +- examples/nft-str-add.c | 134 +++++++++ examples/nft-str-del.c | 133 +++++++++ examples/nft-str-get.c | 122 ++++++++ examples/nft-strset-add.c | 131 ++++++++ examples/nft-strset-del.c | 111 +++++++ examples/nft-strset-get.c | 122 ++++++++ include/libnftnl/str.h | 56 ++++ include/linux/netfilter/nf_tables.h | 45 ++- include/str.h | 26 ++ src/Makefile.am | 1 + src/libnftnl.map | 21 ++ src/str.c | 443 ++++++++++++++++++++++++++++ 13 files changed, 1368 insertions(+), 3 deletions(-) create mode 100644 examples/nft-str-add.c create mode 100644 examples/nft-str-del.c create mode 100644 examples/nft-str-get.c create mode 100644 examples/nft-strset-add.c create mode 100644 examples/nft-strset-del.c create mode 100644 examples/nft-strset-get.c create mode 100644 include/libnftnl/str.h create mode 100644 include/str.h create mode 100644 src/str.c
examples/Makefile.am +25 -1
@@ -37,7 +37,13 @@ check_PROGRAMS = nft-table-add \ nft-ct-helper-del \ nft-rule-ct-helper-add \ nft-rule-ct-expectation-add \ - nft-rule-ct-timeout-add + nft-rule-ct-timeout-add \ + nft-strset-add \ + nft-strset-del \ + nft-strset-get \ + nft-str-add \ + nft-str-del \ + nft-str-get nft_table_add_SOURCES = nft-table-add.c nft_table_add_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
@@ -152,3 +158,21 @@ nft_rule_ct_expectation_add_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_rule_ct_timeout_add_SOURCES = nft-rule-ct-timeout-add.c nft_rule_ct_timeout_add_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} + +nft_strset_add_SOURCES = nft-strset-add.c +nft_strset_add_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} + +nft_strset_del_SOURCES = nft-strset-del.c +nft_strset_del_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} + +nft_strset_get_SOURCES = nft-strset-get.c +nft_strset_get_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} + +nft_str_add_SOURCES = nft-str-add.c +nft_str_add_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} + +nft_str_del_SOURCES = nft-str-del.c +nft_str_del_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} + +nft_str_get_SOURCES = nft-str-get.c +nft_str_get_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
examples/nft-str-add.c new file +134 -0
134 lines not on this page · raw message
examples/nft-str-del.c new file +133 -0
133 lines not on this page · raw message
examples/nft-str-get.c new file +122 -0
122 lines not on this page · raw message
examples/nft-strset-add.c new file +131 -0
131 lines not on this page · raw message
examples/nft-strset-del.c new file +111 -0
111 lines not on this page · raw message
examples/nft-strset-get.c new file +122 -0
122 lines not on this page · raw message
include/libnftnl/str.h new file +56 -0
56 lines not on this page · raw message
include/linux/netfilter/nf_tables.h +43 -2
75 lines not on this page · raw message
include/str.h new file +26 -0
@@ -0,0 +1,26 @@ +#ifndef _LIBNFTNL_STRING_INTERNAL_H_ +#define _LIBNFTNL_STRING_INTERNAL_H_ + +#include <linux/netfilter/nf_tables.h> + +struct nftnl_string { +struct list_head head; + +uint32_t family; +const char *table; +const char *name; +uint64_t handle; + +uint32_t flags; + +struct list_head string_list; +}; + +struct nftnl_string_list ; + +struct nftnl_str { +struct list_head head; +const char *value; +}; + +#endif
src/Makefile.am +1 -0
@@ -17,6 +17,7 @@ libnftnl_la_SOURCES = utils.c \ rule.c \ set.c \ set_elem.c \ + str.c \ ruleset.c \ udata.c \ expr.c \
src/libnftnl.map +21 -0
@@ -387,3 +387,24 @@ LIBNFTNL_16 { LIBNFTNL_17 { nftnl_set_elem_nlmsg_build; } LIBNFTNL_16; + +LIBNFTNL_18 { + nftnl_string_alloc; + nftnl_string_free; + nftnl_string_is_set; + nftnl_string_unset; + nftnl_string_set_data; + nftnl_string_set_u32; + nftnl_string_set_u64; + nftnl_string_set_str; + nftnl_string_get_data; + nftnl_string_get; + nftnl_string_get_str; + nftnl_string_get_u32; + nftnl_string_get_u64; + nftnl_string_nlmsg_build_payload; + nftnl_string_add; + nftnl_string_nlmsg_parse; + nftnl_string_snprintf; + nftnl_string_foreach; +} LIBNFTNL_17;
src/str.c new file +443 -0
443 lines not on this page · raw message
Signature · 1 line
2.30.2