Skip to contentSkip to conversation

example: Parse and create netlink message using the new parsing functions.

PATCH Superseded Alvaro Neira Ayuso 1 participant 1 message Jan 26, 2015 netfilter

v2 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 4/5 example: Parse and create netlink message using the new parsing functions.

With this example, we can parse the elements in the ruleset and create the netlink message with the action associated. For example:

- Flush ruleset
- Add, delete or flush tables/chains
- Add, delete sets
- Add, delete set elements
- Add, delete, replace or prepend rules

---
[changes in v2]
* Unset the handle in rules if we want to add or insert it.

 examples/Makefile.am       |    4 +
 examples/nft-ruleset-cmd.c |  439 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 443 insertions(+)
 create mode 100644 examples/nft-ruleset-cmd.c
examples/Makefile.am +4 -0
index fafcb76..f2a2740 100644
@@ -22,6 +22,7 @@ check_PROGRAMS = nft-table-add		\
 		 nft-set-elem-get	\
 		 nft-set-elem-del	\
 		 nft-ruleset-get	\
+		 nft-ruleset-cmd	\
 		 nft-compat-get
 
 nft_table_add_SOURCES = nft-table-add.c
@@ -90,5 +91,8 @@ nft_set_elem_get_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
 nft_ruleset_get_SOURCES = nft-ruleset-get.c
 nft_ruleset_get_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
 
+nft_ruleset_cmd_SOURCES = nft-ruleset-cmd.c
+nft_ruleset_cmd_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
 nft_compat_get_SOURCES = nft-compat-get.c
 nft_compat_get_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
examples/nft-ruleset-cmd.c new file +439 -0

439 lines not on this page · raw message

Signature · 1 line
1.7.10.4