summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am132
-rw-r--r--tests/Makefile.in1707
-rw-r--r--tests/nft-chain-test.c109
-rw-r--r--tests/nft-expr_bitwise-test.c285
-rw-r--r--tests/nft-expr_byteorder-test.c107
-rw-r--r--tests/nft-expr_cmp-test.c102
-rw-r--r--tests/nft-expr_counter-test.c93
-rw-r--r--tests/nft-expr_ct-test.c97
-rw-r--r--tests/nft-expr_dup-test.c94
-rw-r--r--tests/nft-expr_exthdr-test.c101
-rw-r--r--tests/nft-expr_fwd-test.c90
-rw-r--r--tests/nft-expr_hash-test.c110
-rw-r--r--tests/nft-expr_immediate-test.c135
-rw-r--r--tests/nft-expr_limit-test.c108
-rw-r--r--tests/nft-expr_log-test.c101
-rw-r--r--tests/nft-expr_lookup-test.c111
-rw-r--r--tests/nft-expr_masq-test.c97
-rw-r--r--tests/nft-expr_match-test.c108
-rw-r--r--tests/nft-expr_meta-test.c94
-rw-r--r--tests/nft-expr_nat-test.c116
-rw-r--r--tests/nft-expr_numgen-test.c102
-rw-r--r--tests/nft-expr_objref-test.c96
-rw-r--r--tests/nft-expr_payload-test.c103
-rw-r--r--tests/nft-expr_queue-test.c102
-rw-r--r--tests/nft-expr_quota-test.c92
-rw-r--r--tests/nft-expr_range-test.c109
-rw-r--r--tests/nft-expr_redir-test.c97
-rw-r--r--tests/nft-expr_reject-test.c96
-rw-r--r--tests/nft-expr_target-test.c108
-rw-r--r--tests/nft-flowtable-test.c87
-rw-r--r--tests/nft-object-test.c78
-rw-r--r--tests/nft-rule-test.c116
-rw-r--r--tests/nft-set-test.c92
-rw-r--r--tests/nft-table-test.c73
34 files changed, 5248 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..c7d77ed
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,132 @@
+include $(top_srcdir)/Make_global.am
+
+check_PROGRAMS = nft-table-test \
+ nft-chain-test \
+ nft-object-test \
+ nft-rule-test \
+ nft-set-test \
+ nft-flowtable-test \
+ nft-expr_bitwise-test \
+ nft-expr_byteorder-test \
+ nft-expr_counter-test \
+ nft-expr_cmp-test \
+ nft-expr_ct-test \
+ nft-expr_dup-test \
+ nft-expr_fwd-test \
+ nft-expr_exthdr-test \
+ nft-expr_immediate-test \
+ nft-expr_limit-test \
+ nft-expr_lookup-test \
+ nft-expr_log-test \
+ nft-expr_match-test \
+ nft-expr_masq-test \
+ nft-expr_meta-test \
+ nft-expr_numgen-test \
+ nft-expr_nat-test \
+ nft-expr_objref-test \
+ nft-expr_payload-test \
+ nft-expr_queue-test \
+ nft-expr_range-test \
+ nft-expr_quota-test \
+ nft-expr_redir-test \
+ nft-expr_reject-test \
+ nft-expr_target-test \
+ nft-expr_hash-test
+
+TESTS = $(check_PROGRAMS)
+
+nft_table_test_SOURCES = nft-table-test.c
+nft_table_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_chain_test_SOURCES = nft-chain-test.c
+nft_chain_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_object_test_SOURCES = nft-object-test.c
+nft_object_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_rule_test_SOURCES = nft-rule-test.c
+nft_rule_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_set_test_SOURCES = nft-set-test.c
+nft_set_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_flowtable_test_SOURCES = nft-flowtable-test.c
+nft_flowtable_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_bitwise_test_SOURCES = nft-expr_bitwise-test.c
+nft_expr_bitwise_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_byteorder_test_SOURCES = nft-expr_byteorder-test.c
+nft_expr_byteorder_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_cmp_test_SOURCES = nft-expr_cmp-test.c
+nft_expr_cmp_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_counter_test_SOURCES = nft-expr_counter-test.c
+nft_expr_counter_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_exthdr_test_SOURCES = nft-expr_exthdr-test.c
+nft_expr_exthdr_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_ct_test_SOURCES = nft-expr_ct-test.c
+nft_expr_ct_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_dup_test_SOURCES = nft-expr_dup-test.c
+nft_expr_dup_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_fwd_test_SOURCES = nft-expr_fwd-test.c
+nft_expr_fwd_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_immediate_test_SOURCES = nft-expr_immediate-test.c
+nft_expr_immediate_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_limit_test_SOURCES = nft-expr_limit-test.c
+nft_expr_limit_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_lookup_test_SOURCES = nft-expr_lookup-test.c
+nft_expr_lookup_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_log_test_SOURCES = nft-expr_log-test.c
+nft_expr_log_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_match_test_SOURCES = nft-expr_match-test.c
+nft_expr_match_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_masq_test_SOURCES = nft-expr_masq-test.c
+nft_expr_masq_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_meta_test_SOURCES = nft-expr_meta-test.c
+nft_expr_meta_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_numgen_test_SOURCES = nft-expr_numgen-test.c
+nft_expr_numgen_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_nat_test_SOURCES = nft-expr_nat-test.c
+nft_expr_nat_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_objref_test_SOURCES = nft-expr_objref-test.c
+nft_expr_objref_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_payload_test_SOURCES = nft-expr_payload-test.c
+nft_expr_payload_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_queue_test_SOURCES = nft-expr_queue-test.c
+nft_expr_queue_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_quota_test_SOURCES = nft-expr_quota-test.c
+nft_expr_quota_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_range_test_SOURCES = nft-expr_range-test.c
+nft_expr_range_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_reject_test_SOURCES = nft-expr_reject-test.c
+nft_expr_reject_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_redir_test_SOURCES = nft-expr_redir-test.c
+nft_expr_redir_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_target_test_SOURCES = nft-expr_target-test.c
+nft_expr_target_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
+nft_expr_hash_test_SOURCES = nft-expr_hash-test.c
+nft_expr_hash_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
diff --git a/tests/Makefile.in b/tests/Makefile.in
new file mode 100644
index 0000000..67ce680
--- /dev/null
+++ b/tests/Makefile.in
@@ -0,0 +1,1707 @@
+# Makefile.in generated by automake 1.16.3 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+check_PROGRAMS = nft-table-test$(EXEEXT) nft-chain-test$(EXEEXT) \
+ nft-object-test$(EXEEXT) nft-rule-test$(EXEEXT) \
+ nft-set-test$(EXEEXT) nft-flowtable-test$(EXEEXT) \
+ nft-expr_bitwise-test$(EXEEXT) \
+ nft-expr_byteorder-test$(EXEEXT) \
+ nft-expr_counter-test$(EXEEXT) nft-expr_cmp-test$(EXEEXT) \
+ nft-expr_ct-test$(EXEEXT) nft-expr_dup-test$(EXEEXT) \
+ nft-expr_fwd-test$(EXEEXT) nft-expr_exthdr-test$(EXEEXT) \
+ nft-expr_immediate-test$(EXEEXT) nft-expr_limit-test$(EXEEXT) \
+ nft-expr_lookup-test$(EXEEXT) nft-expr_log-test$(EXEEXT) \
+ nft-expr_match-test$(EXEEXT) nft-expr_masq-test$(EXEEXT) \
+ nft-expr_meta-test$(EXEEXT) nft-expr_numgen-test$(EXEEXT) \
+ nft-expr_nat-test$(EXEEXT) nft-expr_objref-test$(EXEEXT) \
+ nft-expr_payload-test$(EXEEXT) nft-expr_queue-test$(EXEEXT) \
+ nft-expr_range-test$(EXEEXT) nft-expr_quota-test$(EXEEXT) \
+ nft-expr_redir-test$(EXEEXT) nft-expr_reject-test$(EXEEXT) \
+ nft-expr_target-test$(EXEEXT) nft-expr_hash-test$(EXEEXT)
+subdir = tests
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/gcc4_visibility.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am_nft_chain_test_OBJECTS = nft-chain-test.$(OBJEXT)
+nft_chain_test_OBJECTS = $(am_nft_chain_test_OBJECTS)
+am__DEPENDENCIES_1 =
+nft_chain_test_DEPENDENCIES = ../src/libnftnl.la $(am__DEPENDENCIES_1)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+am_nft_expr_bitwise_test_OBJECTS = nft-expr_bitwise-test.$(OBJEXT)
+nft_expr_bitwise_test_OBJECTS = $(am_nft_expr_bitwise_test_OBJECTS)
+nft_expr_bitwise_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_byteorder_test_OBJECTS = \
+ nft-expr_byteorder-test.$(OBJEXT)
+nft_expr_byteorder_test_OBJECTS = \
+ $(am_nft_expr_byteorder_test_OBJECTS)
+nft_expr_byteorder_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_cmp_test_OBJECTS = nft-expr_cmp-test.$(OBJEXT)
+nft_expr_cmp_test_OBJECTS = $(am_nft_expr_cmp_test_OBJECTS)
+nft_expr_cmp_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_counter_test_OBJECTS = nft-expr_counter-test.$(OBJEXT)
+nft_expr_counter_test_OBJECTS = $(am_nft_expr_counter_test_OBJECTS)
+nft_expr_counter_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_ct_test_OBJECTS = nft-expr_ct-test.$(OBJEXT)
+nft_expr_ct_test_OBJECTS = $(am_nft_expr_ct_test_OBJECTS)
+nft_expr_ct_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_dup_test_OBJECTS = nft-expr_dup-test.$(OBJEXT)
+nft_expr_dup_test_OBJECTS = $(am_nft_expr_dup_test_OBJECTS)
+nft_expr_dup_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_exthdr_test_OBJECTS = nft-expr_exthdr-test.$(OBJEXT)
+nft_expr_exthdr_test_OBJECTS = $(am_nft_expr_exthdr_test_OBJECTS)
+nft_expr_exthdr_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_fwd_test_OBJECTS = nft-expr_fwd-test.$(OBJEXT)
+nft_expr_fwd_test_OBJECTS = $(am_nft_expr_fwd_test_OBJECTS)
+nft_expr_fwd_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_hash_test_OBJECTS = nft-expr_hash-test.$(OBJEXT)
+nft_expr_hash_test_OBJECTS = $(am_nft_expr_hash_test_OBJECTS)
+nft_expr_hash_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_immediate_test_OBJECTS = \
+ nft-expr_immediate-test.$(OBJEXT)
+nft_expr_immediate_test_OBJECTS = \
+ $(am_nft_expr_immediate_test_OBJECTS)
+nft_expr_immediate_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_limit_test_OBJECTS = nft-expr_limit-test.$(OBJEXT)
+nft_expr_limit_test_OBJECTS = $(am_nft_expr_limit_test_OBJECTS)
+nft_expr_limit_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_log_test_OBJECTS = nft-expr_log-test.$(OBJEXT)
+nft_expr_log_test_OBJECTS = $(am_nft_expr_log_test_OBJECTS)
+nft_expr_log_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_lookup_test_OBJECTS = nft-expr_lookup-test.$(OBJEXT)
+nft_expr_lookup_test_OBJECTS = $(am_nft_expr_lookup_test_OBJECTS)
+nft_expr_lookup_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_masq_test_OBJECTS = nft-expr_masq-test.$(OBJEXT)
+nft_expr_masq_test_OBJECTS = $(am_nft_expr_masq_test_OBJECTS)
+nft_expr_masq_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_match_test_OBJECTS = nft-expr_match-test.$(OBJEXT)
+nft_expr_match_test_OBJECTS = $(am_nft_expr_match_test_OBJECTS)
+nft_expr_match_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_meta_test_OBJECTS = nft-expr_meta-test.$(OBJEXT)
+nft_expr_meta_test_OBJECTS = $(am_nft_expr_meta_test_OBJECTS)
+nft_expr_meta_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_nat_test_OBJECTS = nft-expr_nat-test.$(OBJEXT)
+nft_expr_nat_test_OBJECTS = $(am_nft_expr_nat_test_OBJECTS)
+nft_expr_nat_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_numgen_test_OBJECTS = nft-expr_numgen-test.$(OBJEXT)
+nft_expr_numgen_test_OBJECTS = $(am_nft_expr_numgen_test_OBJECTS)
+nft_expr_numgen_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_objref_test_OBJECTS = nft-expr_objref-test.$(OBJEXT)
+nft_expr_objref_test_OBJECTS = $(am_nft_expr_objref_test_OBJECTS)
+nft_expr_objref_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_payload_test_OBJECTS = nft-expr_payload-test.$(OBJEXT)
+nft_expr_payload_test_OBJECTS = $(am_nft_expr_payload_test_OBJECTS)
+nft_expr_payload_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_queue_test_OBJECTS = nft-expr_queue-test.$(OBJEXT)
+nft_expr_queue_test_OBJECTS = $(am_nft_expr_queue_test_OBJECTS)
+nft_expr_queue_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_quota_test_OBJECTS = nft-expr_quota-test.$(OBJEXT)
+nft_expr_quota_test_OBJECTS = $(am_nft_expr_quota_test_OBJECTS)
+nft_expr_quota_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_range_test_OBJECTS = nft-expr_range-test.$(OBJEXT)
+nft_expr_range_test_OBJECTS = $(am_nft_expr_range_test_OBJECTS)
+nft_expr_range_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_redir_test_OBJECTS = nft-expr_redir-test.$(OBJEXT)
+nft_expr_redir_test_OBJECTS = $(am_nft_expr_redir_test_OBJECTS)
+nft_expr_redir_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_reject_test_OBJECTS = nft-expr_reject-test.$(OBJEXT)
+nft_expr_reject_test_OBJECTS = $(am_nft_expr_reject_test_OBJECTS)
+nft_expr_reject_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_expr_target_test_OBJECTS = nft-expr_target-test.$(OBJEXT)
+nft_expr_target_test_OBJECTS = $(am_nft_expr_target_test_OBJECTS)
+nft_expr_target_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_flowtable_test_OBJECTS = nft-flowtable-test.$(OBJEXT)
+nft_flowtable_test_OBJECTS = $(am_nft_flowtable_test_OBJECTS)
+nft_flowtable_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_object_test_OBJECTS = nft-object-test.$(OBJEXT)
+nft_object_test_OBJECTS = $(am_nft_object_test_OBJECTS)
+nft_object_test_DEPENDENCIES = ../src/libnftnl.la \
+ $(am__DEPENDENCIES_1)
+am_nft_rule_test_OBJECTS = nft-rule-test.$(OBJEXT)
+nft_rule_test_OBJECTS = $(am_nft_rule_test_OBJECTS)
+nft_rule_test_DEPENDENCIES = ../src/libnftnl.la $(am__DEPENDENCIES_1)
+am_nft_set_test_OBJECTS = nft-set-test.$(OBJEXT)
+nft_set_test_OBJECTS = $(am_nft_set_test_OBJECTS)
+nft_set_test_DEPENDENCIES = ../src/libnftnl.la $(am__DEPENDENCIES_1)
+am_nft_table_test_OBJECTS = nft-table-test.$(OBJEXT)
+nft_table_test_OBJECTS = $(am_nft_table_test_OBJECTS)
+nft_table_test_DEPENDENCIES = ../src/libnftnl.la $(am__DEPENDENCIES_1)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/nft-chain-test.Po \
+ ./$(DEPDIR)/nft-expr_bitwise-test.Po \
+ ./$(DEPDIR)/nft-expr_byteorder-test.Po \
+ ./$(DEPDIR)/nft-expr_cmp-test.Po \
+ ./$(DEPDIR)/nft-expr_counter-test.Po \
+ ./$(DEPDIR)/nft-expr_ct-test.Po \
+ ./$(DEPDIR)/nft-expr_dup-test.Po \
+ ./$(DEPDIR)/nft-expr_exthdr-test.Po \
+ ./$(DEPDIR)/nft-expr_fwd-test.Po \
+ ./$(DEPDIR)/nft-expr_hash-test.Po \
+ ./$(DEPDIR)/nft-expr_immediate-test.Po \
+ ./$(DEPDIR)/nft-expr_limit-test.Po \
+ ./$(DEPDIR)/nft-expr_log-test.Po \
+ ./$(DEPDIR)/nft-expr_lookup-test.Po \
+ ./$(DEPDIR)/nft-expr_masq-test.Po \
+ ./$(DEPDIR)/nft-expr_match-test.Po \
+ ./$(DEPDIR)/nft-expr_meta-test.Po \
+ ./$(DEPDIR)/nft-expr_nat-test.Po \
+ ./$(DEPDIR)/nft-expr_numgen-test.Po \
+ ./$(DEPDIR)/nft-expr_objref-test.Po \
+ ./$(DEPDIR)/nft-expr_payload-test.Po \
+ ./$(DEPDIR)/nft-expr_queue-test.Po \
+ ./$(DEPDIR)/nft-expr_quota-test.Po \
+ ./$(DEPDIR)/nft-expr_range-test.Po \
+ ./$(DEPDIR)/nft-expr_redir-test.Po \
+ ./$(DEPDIR)/nft-expr_reject-test.Po \
+ ./$(DEPDIR)/nft-expr_target-test.Po \
+ ./$(DEPDIR)/nft-flowtable-test.Po \
+ ./$(DEPDIR)/nft-object-test.Po ./$(DEPDIR)/nft-rule-test.Po \
+ ./$(DEPDIR)/nft-set-test.Po ./$(DEPDIR)/nft-table-test.Po
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(nft_chain_test_SOURCES) $(nft_expr_bitwise_test_SOURCES) \
+ $(nft_expr_byteorder_test_SOURCES) \
+ $(nft_expr_cmp_test_SOURCES) $(nft_expr_counter_test_SOURCES) \
+ $(nft_expr_ct_test_SOURCES) $(nft_expr_dup_test_SOURCES) \
+ $(nft_expr_exthdr_test_SOURCES) $(nft_expr_fwd_test_SOURCES) \
+ $(nft_expr_hash_test_SOURCES) \
+ $(nft_expr_immediate_test_SOURCES) \
+ $(nft_expr_limit_test_SOURCES) $(nft_expr_log_test_SOURCES) \
+ $(nft_expr_lookup_test_SOURCES) $(nft_expr_masq_test_SOURCES) \
+ $(nft_expr_match_test_SOURCES) $(nft_expr_meta_test_SOURCES) \
+ $(nft_expr_nat_test_SOURCES) $(nft_expr_numgen_test_SOURCES) \
+ $(nft_expr_objref_test_SOURCES) \
+ $(nft_expr_payload_test_SOURCES) \
+ $(nft_expr_queue_test_SOURCES) $(nft_expr_quota_test_SOURCES) \
+ $(nft_expr_range_test_SOURCES) $(nft_expr_redir_test_SOURCES) \
+ $(nft_expr_reject_test_SOURCES) \
+ $(nft_expr_target_test_SOURCES) $(nft_flowtable_test_SOURCES) \
+ $(nft_object_test_SOURCES) $(nft_rule_test_SOURCES) \
+ $(nft_set_test_SOURCES) $(nft_table_test_SOURCES)
+DIST_SOURCES = $(nft_chain_test_SOURCES) \
+ $(nft_expr_bitwise_test_SOURCES) \
+ $(nft_expr_byteorder_test_SOURCES) \
+ $(nft_expr_cmp_test_SOURCES) $(nft_expr_counter_test_SOURCES) \
+ $(nft_expr_ct_test_SOURCES) $(nft_expr_dup_test_SOURCES) \
+ $(nft_expr_exthdr_test_SOURCES) $(nft_expr_fwd_test_SOURCES) \
+ $(nft_expr_hash_test_SOURCES) \
+ $(nft_expr_immediate_test_SOURCES) \
+ $(nft_expr_limit_test_SOURCES) $(nft_expr_log_test_SOURCES) \
+ $(nft_expr_lookup_test_SOURCES) $(nft_expr_masq_test_SOURCES) \
+ $(nft_expr_match_test_SOURCES) $(nft_expr_meta_test_SOURCES) \
+ $(nft_expr_nat_test_SOURCES) $(nft_expr_numgen_test_SOURCES) \
+ $(nft_expr_objref_test_SOURCES) \
+ $(nft_expr_payload_test_SOURCES) \
+ $(nft_expr_queue_test_SOURCES) $(nft_expr_quota_test_SOURCES) \
+ $(nft_expr_range_test_SOURCES) $(nft_expr_redir_test_SOURCES) \
+ $(nft_expr_reject_test_SOURCES) \
+ $(nft_expr_target_test_SOURCES) $(nft_flowtable_test_SOURCES) \
+ $(nft_object_test_SOURCES) $(nft_rule_test_SOURCES) \
+ $(nft_set_test_SOURCES) $(nft_table_test_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors_dummy = \
+ mgn= red= grn= lgn= blu= brg= std=; \
+ am__color_tests=no
+am__tty_colors = { \
+ $(am__tty_colors_dummy); \
+ if test "X$(AM_COLOR_TESTS)" = Xno; then \
+ am__color_tests=no; \
+ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
+ am__color_tests=yes; \
+ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
+ am__color_tests=yes; \
+ fi; \
+ if test $$am__color_tests = yes; then \
+ red=''; \
+ grn=''; \
+ lgn=''; \
+ blu=''; \
+ mgn=''; \
+ brg=''; \
+ std=''; \
+ fi; \
+}
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__recheck_rx = ^[ ]*:recheck:[ ]*
+am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
+am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
+# A command that, given a newline-separated list of test names on the
+# standard input, print the name of the tests that are to be re-run
+# upon "make recheck".
+am__list_recheck_tests = $(AWK) '{ \
+ recheck = 1; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ { \
+ if ((getline line2 < ($$0 ".log")) < 0) \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
+ { \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
+ { \
+ break; \
+ } \
+ }; \
+ if (recheck) \
+ print $$0; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# A command that, given a newline-separated list of test names on the
+# standard input, create the global log from their .trs and .log files.
+am__create_global_log = $(AWK) ' \
+function fatal(msg) \
+{ \
+ print "fatal: making $@: " msg | "cat >&2"; \
+ exit 1; \
+} \
+function rst_section(header) \
+{ \
+ print header; \
+ len = length(header); \
+ for (i = 1; i <= len; i = i + 1) \
+ printf "="; \
+ printf "\n\n"; \
+} \
+{ \
+ copy_in_global_log = 1; \
+ global_test_result = "RUN"; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".trs"); \
+ if (line ~ /$(am__global_test_result_rx)/) \
+ { \
+ sub("$(am__global_test_result_rx)", "", line); \
+ sub("[ ]*$$", "", line); \
+ global_test_result = line; \
+ } \
+ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
+ copy_in_global_log = 0; \
+ }; \
+ if (copy_in_global_log) \
+ { \
+ rst_section(global_test_result ": " $$0); \
+ while ((rc = (getline line < ($$0 ".log"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".log"); \
+ print line; \
+ }; \
+ printf "\n"; \
+ }; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# Restructured Text title.
+am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
+# Solaris 10 'make', and several other traditional 'make' implementations,
+# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
+# by disabling -e (using the XSI extension "set +e") if it's set.
+am__sh_e_setup = case $$- in *e*) set +e;; esac
+# Default flags passed to test drivers.
+am__common_driver_flags = \
+ --color-tests "$$am__color_tests" \
+ --enable-hard-errors "$$am__enable_hard_errors" \
+ --expect-failure "$$am__expect_failure"
+# To be inserted before the command running the test. Creates the
+# directory for the log if needed. Stores in $dir the directory
+# containing $f, in $tst the test, in $log the log. Executes the
+# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
+# passes TESTS_ENVIRONMENT. Set up options for the wrapper that
+# will run the test scripts (or their associated LOG_COMPILER, if
+# thy have one).
+am__check_pre = \
+$(am__sh_e_setup); \
+$(am__vpath_adj_setup) $(am__vpath_adj) \
+$(am__tty_colors); \
+srcdir=$(srcdir); export srcdir; \
+case "$@" in \
+ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
+ *) am__odir=.;; \
+esac; \
+test "x$$am__odir" = x"." || test -d "$$am__odir" \
+ || $(MKDIR_P) "$$am__odir" || exit $$?; \
+if test -f "./$$f"; then dir=./; \
+elif test -f "$$f"; then dir=; \
+else dir="$(srcdir)/"; fi; \
+tst=$$dir$$f; log='$@'; \
+if test -n '$(DISABLE_HARD_ERRORS)'; then \
+ am__enable_hard_errors=no; \
+else \
+ am__enable_hard_errors=yes; \
+fi; \
+case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
+ am__expect_failure=yes;; \
+ *) \
+ am__expect_failure=no;; \
+esac; \
+$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
+# A shell command to get the names of the tests scripts with any registered
+# extension removed (i.e., equivalently, the names of the test logs, with
+# the '.log' extension removed). The result is saved in the shell variable
+# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
+# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
+# since that might cause problem with VPATH rewrites for suffix-less tests.
+# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
+am__set_TESTS_bases = \
+ bases='$(TEST_LOGS)'; \
+ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
+ bases=`echo $$bases`
+AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)'
+RECHECK_LOGS = $(TEST_LOGS)
+AM_RECURSIVE_TARGETS = check recheck
+TEST_SUITE_LOG = test-suite.log
+TEST_EXTENSIONS = @EXEEXT@ .test
+LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver
+LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
+am__set_b = \
+ case '$@' in \
+ */*) \
+ case '$*' in \
+ */*) b='$*';; \
+ *) b=`echo '$@' | sed 's/\.log$$//'`; \
+ esac;; \
+ *) \
+ b='$*';; \
+ esac
+am__test_logs1 = $(TESTS:=.log)
+am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
+TEST_LOGS = $(am__test_logs2:.test.log=.log)
+TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/build-aux/test-driver
+TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
+ $(TEST_LOG_FLAGS)
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/Make_global.am \
+ $(top_srcdir)/build-aux/depcomp \
+ $(top_srcdir)/build-aux/test-driver
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GCC_FVISIBILITY_HIDDEN = @GCC_FVISIBILITY_HIDDEN@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBMNL_CFLAGS = @LIBMNL_CFLAGS@
+LIBMNL_LIBS = @LIBMNL_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+regular_CFLAGS = @regular_CFLAGS@
+regular_CPPFLAGS = @regular_CPPFLAGS@
+runstatedir = @runstatedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+# This is _NOT_ the library release version, it's an API version.
+# Extracted from Chapter 6 "Library interface versions" of the libtool docs.
+#
+# <snippet>
+# Here are a set of rules to help you update your library version information:
+#
+# 1. Start with version information of `0:0:0' for each libtool library.
+# 2. Update the version information only immediately before a public release
+# of your software. More frequent updates are unnecessary, and only guarantee
+# that the current interface number gets larger faster.
+# 3. If the library source code has changed at all since the last update,
+# then increment revision (`c:r:a' becomes `c:r+1:a').
+# 4. If any interfaces have been added, removed, or changed since the last
+# update, increment current, and set revision to 0.
+# 5. If any interfaces have been added since the last public release, then
+# increment age.
+# 6. If any interfaces have been removed since the last public release, then
+# set age to 0.
+# </snippet>
+#
+LIBVERSION = 17:0:6
+AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_srcdir}/include ${LIBMNL_CFLAGS} ${LIBMXML_CFLAGS}
+AM_CFLAGS = ${regular_CFLAGS} ${GCC_FVISIBILITY_HIDDEN}
+TESTS = $(check_PROGRAMS)
+nft_table_test_SOURCES = nft-table-test.c
+nft_table_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_chain_test_SOURCES = nft-chain-test.c
+nft_chain_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_object_test_SOURCES = nft-object-test.c
+nft_object_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_rule_test_SOURCES = nft-rule-test.c
+nft_rule_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_set_test_SOURCES = nft-set-test.c
+nft_set_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_flowtable_test_SOURCES = nft-flowtable-test.c
+nft_flowtable_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_bitwise_test_SOURCES = nft-expr_bitwise-test.c
+nft_expr_bitwise_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_byteorder_test_SOURCES = nft-expr_byteorder-test.c
+nft_expr_byteorder_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_cmp_test_SOURCES = nft-expr_cmp-test.c
+nft_expr_cmp_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_counter_test_SOURCES = nft-expr_counter-test.c
+nft_expr_counter_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_exthdr_test_SOURCES = nft-expr_exthdr-test.c
+nft_expr_exthdr_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_ct_test_SOURCES = nft-expr_ct-test.c
+nft_expr_ct_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_dup_test_SOURCES = nft-expr_dup-test.c
+nft_expr_dup_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_fwd_test_SOURCES = nft-expr_fwd-test.c
+nft_expr_fwd_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_immediate_test_SOURCES = nft-expr_immediate-test.c
+nft_expr_immediate_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_limit_test_SOURCES = nft-expr_limit-test.c
+nft_expr_limit_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_lookup_test_SOURCES = nft-expr_lookup-test.c
+nft_expr_lookup_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_log_test_SOURCES = nft-expr_log-test.c
+nft_expr_log_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_match_test_SOURCES = nft-expr_match-test.c
+nft_expr_match_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_masq_test_SOURCES = nft-expr_masq-test.c
+nft_expr_masq_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_meta_test_SOURCES = nft-expr_meta-test.c
+nft_expr_meta_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_numgen_test_SOURCES = nft-expr_numgen-test.c
+nft_expr_numgen_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_nat_test_SOURCES = nft-expr_nat-test.c
+nft_expr_nat_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_objref_test_SOURCES = nft-expr_objref-test.c
+nft_expr_objref_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_payload_test_SOURCES = nft-expr_payload-test.c
+nft_expr_payload_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_queue_test_SOURCES = nft-expr_queue-test.c
+nft_expr_queue_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_quota_test_SOURCES = nft-expr_quota-test.c
+nft_expr_quota_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_range_test_SOURCES = nft-expr_range-test.c
+nft_expr_range_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_reject_test_SOURCES = nft-expr_reject-test.c
+nft_expr_reject_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_redir_test_SOURCES = nft-expr_redir-test.c
+nft_expr_redir_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_target_test_SOURCES = nft-expr_target-test.c
+nft_expr_target_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+nft_expr_hash_test_SOURCES = nft-expr_hash-test.c
+nft_expr_hash_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Make_global.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign tests/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
+ esac;
+$(top_srcdir)/Make_global.am $(am__empty):
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-checkPROGRAMS:
+ @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+
+nft-chain-test$(EXEEXT): $(nft_chain_test_OBJECTS) $(nft_chain_test_DEPENDENCIES) $(EXTRA_nft_chain_test_DEPENDENCIES)
+ @rm -f nft-chain-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_chain_test_OBJECTS) $(nft_chain_test_LDADD) $(LIBS)
+
+nft-expr_bitwise-test$(EXEEXT): $(nft_expr_bitwise_test_OBJECTS) $(nft_expr_bitwise_test_DEPENDENCIES) $(EXTRA_nft_expr_bitwise_test_DEPENDENCIES)
+ @rm -f nft-expr_bitwise-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_bitwise_test_OBJECTS) $(nft_expr_bitwise_test_LDADD) $(LIBS)
+
+nft-expr_byteorder-test$(EXEEXT): $(nft_expr_byteorder_test_OBJECTS) $(nft_expr_byteorder_test_DEPENDENCIES) $(EXTRA_nft_expr_byteorder_test_DEPENDENCIES)
+ @rm -f nft-expr_byteorder-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_byteorder_test_OBJECTS) $(nft_expr_byteorder_test_LDADD) $(LIBS)
+
+nft-expr_cmp-test$(EXEEXT): $(nft_expr_cmp_test_OBJECTS) $(nft_expr_cmp_test_DEPENDENCIES) $(EXTRA_nft_expr_cmp_test_DEPENDENCIES)
+ @rm -f nft-expr_cmp-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_cmp_test_OBJECTS) $(nft_expr_cmp_test_LDADD) $(LIBS)
+
+nft-expr_counter-test$(EXEEXT): $(nft_expr_counter_test_OBJECTS) $(nft_expr_counter_test_DEPENDENCIES) $(EXTRA_nft_expr_counter_test_DEPENDENCIES)
+ @rm -f nft-expr_counter-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_counter_test_OBJECTS) $(nft_expr_counter_test_LDADD) $(LIBS)
+
+nft-expr_ct-test$(EXEEXT): $(nft_expr_ct_test_OBJECTS) $(nft_expr_ct_test_DEPENDENCIES) $(EXTRA_nft_expr_ct_test_DEPENDENCIES)
+ @rm -f nft-expr_ct-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_ct_test_OBJECTS) $(nft_expr_ct_test_LDADD) $(LIBS)
+
+nft-expr_dup-test$(EXEEXT): $(nft_expr_dup_test_OBJECTS) $(nft_expr_dup_test_DEPENDENCIES) $(EXTRA_nft_expr_dup_test_DEPENDENCIES)
+ @rm -f nft-expr_dup-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_dup_test_OBJECTS) $(nft_expr_dup_test_LDADD) $(LIBS)
+
+nft-expr_exthdr-test$(EXEEXT): $(nft_expr_exthdr_test_OBJECTS) $(nft_expr_exthdr_test_DEPENDENCIES) $(EXTRA_nft_expr_exthdr_test_DEPENDENCIES)
+ @rm -f nft-expr_exthdr-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_exthdr_test_OBJECTS) $(nft_expr_exthdr_test_LDADD) $(LIBS)
+
+nft-expr_fwd-test$(EXEEXT): $(nft_expr_fwd_test_OBJECTS) $(nft_expr_fwd_test_DEPENDENCIES) $(EXTRA_nft_expr_fwd_test_DEPENDENCIES)
+ @rm -f nft-expr_fwd-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_fwd_test_OBJECTS) $(nft_expr_fwd_test_LDADD) $(LIBS)
+
+nft-expr_hash-test$(EXEEXT): $(nft_expr_hash_test_OBJECTS) $(nft_expr_hash_test_DEPENDENCIES) $(EXTRA_nft_expr_hash_test_DEPENDENCIES)
+ @rm -f nft-expr_hash-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_hash_test_OBJECTS) $(nft_expr_hash_test_LDADD) $(LIBS)
+
+nft-expr_immediate-test$(EXEEXT): $(nft_expr_immediate_test_OBJECTS) $(nft_expr_immediate_test_DEPENDENCIES) $(EXTRA_nft_expr_immediate_test_DEPENDENCIES)
+ @rm -f nft-expr_immediate-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_immediate_test_OBJECTS) $(nft_expr_immediate_test_LDADD) $(LIBS)
+
+nft-expr_limit-test$(EXEEXT): $(nft_expr_limit_test_OBJECTS) $(nft_expr_limit_test_DEPENDENCIES) $(EXTRA_nft_expr_limit_test_DEPENDENCIES)
+ @rm -f nft-expr_limit-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_limit_test_OBJECTS) $(nft_expr_limit_test_LDADD) $(LIBS)
+
+nft-expr_log-test$(EXEEXT): $(nft_expr_log_test_OBJECTS) $(nft_expr_log_test_DEPENDENCIES) $(EXTRA_nft_expr_log_test_DEPENDENCIES)
+ @rm -f nft-expr_log-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_log_test_OBJECTS) $(nft_expr_log_test_LDADD) $(LIBS)
+
+nft-expr_lookup-test$(EXEEXT): $(nft_expr_lookup_test_OBJECTS) $(nft_expr_lookup_test_DEPENDENCIES) $(EXTRA_nft_expr_lookup_test_DEPENDENCIES)
+ @rm -f nft-expr_lookup-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_lookup_test_OBJECTS) $(nft_expr_lookup_test_LDADD) $(LIBS)
+
+nft-expr_masq-test$(EXEEXT): $(nft_expr_masq_test_OBJECTS) $(nft_expr_masq_test_DEPENDENCIES) $(EXTRA_nft_expr_masq_test_DEPENDENCIES)
+ @rm -f nft-expr_masq-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_masq_test_OBJECTS) $(nft_expr_masq_test_LDADD) $(LIBS)
+
+nft-expr_match-test$(EXEEXT): $(nft_expr_match_test_OBJECTS) $(nft_expr_match_test_DEPENDENCIES) $(EXTRA_nft_expr_match_test_DEPENDENCIES)
+ @rm -f nft-expr_match-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_match_test_OBJECTS) $(nft_expr_match_test_LDADD) $(LIBS)
+
+nft-expr_meta-test$(EXEEXT): $(nft_expr_meta_test_OBJECTS) $(nft_expr_meta_test_DEPENDENCIES) $(EXTRA_nft_expr_meta_test_DEPENDENCIES)
+ @rm -f nft-expr_meta-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_meta_test_OBJECTS) $(nft_expr_meta_test_LDADD) $(LIBS)
+
+nft-expr_nat-test$(EXEEXT): $(nft_expr_nat_test_OBJECTS) $(nft_expr_nat_test_DEPENDENCIES) $(EXTRA_nft_expr_nat_test_DEPENDENCIES)
+ @rm -f nft-expr_nat-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_nat_test_OBJECTS) $(nft_expr_nat_test_LDADD) $(LIBS)
+
+nft-expr_numgen-test$(EXEEXT): $(nft_expr_numgen_test_OBJECTS) $(nft_expr_numgen_test_DEPENDENCIES) $(EXTRA_nft_expr_numgen_test_DEPENDENCIES)
+ @rm -f nft-expr_numgen-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_numgen_test_OBJECTS) $(nft_expr_numgen_test_LDADD) $(LIBS)
+
+nft-expr_objref-test$(EXEEXT): $(nft_expr_objref_test_OBJECTS) $(nft_expr_objref_test_DEPENDENCIES) $(EXTRA_nft_expr_objref_test_DEPENDENCIES)
+ @rm -f nft-expr_objref-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_objref_test_OBJECTS) $(nft_expr_objref_test_LDADD) $(LIBS)
+
+nft-expr_payload-test$(EXEEXT): $(nft_expr_payload_test_OBJECTS) $(nft_expr_payload_test_DEPENDENCIES) $(EXTRA_nft_expr_payload_test_DEPENDENCIES)
+ @rm -f nft-expr_payload-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_payload_test_OBJECTS) $(nft_expr_payload_test_LDADD) $(LIBS)
+
+nft-expr_queue-test$(EXEEXT): $(nft_expr_queue_test_OBJECTS) $(nft_expr_queue_test_DEPENDENCIES) $(EXTRA_nft_expr_queue_test_DEPENDENCIES)
+ @rm -f nft-expr_queue-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_queue_test_OBJECTS) $(nft_expr_queue_test_LDADD) $(LIBS)
+
+nft-expr_quota-test$(EXEEXT): $(nft_expr_quota_test_OBJECTS) $(nft_expr_quota_test_DEPENDENCIES) $(EXTRA_nft_expr_quota_test_DEPENDENCIES)
+ @rm -f nft-expr_quota-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_quota_test_OBJECTS) $(nft_expr_quota_test_LDADD) $(LIBS)
+
+nft-expr_range-test$(EXEEXT): $(nft_expr_range_test_OBJECTS) $(nft_expr_range_test_DEPENDENCIES) $(EXTRA_nft_expr_range_test_DEPENDENCIES)
+ @rm -f nft-expr_range-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_range_test_OBJECTS) $(nft_expr_range_test_LDADD) $(LIBS)
+
+nft-expr_redir-test$(EXEEXT): $(nft_expr_redir_test_OBJECTS) $(nft_expr_redir_test_DEPENDENCIES) $(EXTRA_nft_expr_redir_test_DEPENDENCIES)
+ @rm -f nft-expr_redir-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_redir_test_OBJECTS) $(nft_expr_redir_test_LDADD) $(LIBS)
+
+nft-expr_reject-test$(EXEEXT): $(nft_expr_reject_test_OBJECTS) $(nft_expr_reject_test_DEPENDENCIES) $(EXTRA_nft_expr_reject_test_DEPENDENCIES)
+ @rm -f nft-expr_reject-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_reject_test_OBJECTS) $(nft_expr_reject_test_LDADD) $(LIBS)
+
+nft-expr_target-test$(EXEEXT): $(nft_expr_target_test_OBJECTS) $(nft_expr_target_test_DEPENDENCIES) $(EXTRA_nft_expr_target_test_DEPENDENCIES)
+ @rm -f nft-expr_target-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_expr_target_test_OBJECTS) $(nft_expr_target_test_LDADD) $(LIBS)
+
+nft-flowtable-test$(EXEEXT): $(nft_flowtable_test_OBJECTS) $(nft_flowtable_test_DEPENDENCIES) $(EXTRA_nft_flowtable_test_DEPENDENCIES)
+ @rm -f nft-flowtable-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_flowtable_test_OBJECTS) $(nft_flowtable_test_LDADD) $(LIBS)
+
+nft-object-test$(EXEEXT): $(nft_object_test_OBJECTS) $(nft_object_test_DEPENDENCIES) $(EXTRA_nft_object_test_DEPENDENCIES)
+ @rm -f nft-object-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_object_test_OBJECTS) $(nft_object_test_LDADD) $(LIBS)
+
+nft-rule-test$(EXEEXT): $(nft_rule_test_OBJECTS) $(nft_rule_test_DEPENDENCIES) $(EXTRA_nft_rule_test_DEPENDENCIES)
+ @rm -f nft-rule-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_rule_test_OBJECTS) $(nft_rule_test_LDADD) $(LIBS)
+
+nft-set-test$(EXEEXT): $(nft_set_test_OBJECTS) $(nft_set_test_DEPENDENCIES) $(EXTRA_nft_set_test_DEPENDENCIES)
+ @rm -f nft-set-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_set_test_OBJECTS) $(nft_set_test_LDADD) $(LIBS)
+
+nft-table-test$(EXEEXT): $(nft_table_test_OBJECTS) $(nft_table_test_DEPENDENCIES) $(EXTRA_nft_table_test_DEPENDENCIES)
+ @rm -f nft-table-test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(nft_table_test_OBJECTS) $(nft_table_test_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-chain-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_bitwise-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_byteorder-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_cmp-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_counter-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_ct-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_dup-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_exthdr-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_fwd-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_hash-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_immediate-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_limit-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_log-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_lookup-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_masq-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_match-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_meta-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_nat-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_numgen-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_objref-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_payload-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_queue-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_quota-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_range-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_redir-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_reject-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-expr_target-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-flowtable-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-object-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-rule-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-set-test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nft-table-test.Po@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+ @$(MKDIR_P) $(@D)
+ @echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+# Recover from deleted '.trs' file; this should ensure that
+# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
+# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
+# to avoid problems with "make -n".
+.log.trs:
+ rm -f $< $@
+ $(MAKE) $(AM_MAKEFLAGS) $<
+
+# Leading 'am--fnord' is there to ensure the list of targets does not
+# expand to empty, as could happen e.g. with make check TESTS=''.
+am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
+am--force-recheck:
+ @:
+
+$(TEST_SUITE_LOG): $(TEST_LOGS)
+ @$(am__set_TESTS_bases); \
+ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
+ redo_bases=`for i in $$bases; do \
+ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
+ done`; \
+ if test -n "$$redo_bases"; then \
+ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
+ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
+ if $(am__make_dryrun); then :; else \
+ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
+ fi; \
+ fi; \
+ if test -n "$$am__remaking_logs"; then \
+ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
+ "recursion detected" >&2; \
+ elif test -n "$$redo_logs"; then \
+ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
+ fi; \
+ if $(am__make_dryrun); then :; else \
+ st=0; \
+ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
+ for i in $$redo_bases; do \
+ test -f $$i.trs && test -r $$i.trs \
+ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
+ test -f $$i.log && test -r $$i.log \
+ || { echo "$$errmsg $$i.log" >&2; st=1; }; \
+ done; \
+ test $$st -eq 0 || exit 1; \
+ fi
+ @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
+ ws='[ ]'; \
+ results=`for b in $$bases; do echo $$b.trs; done`; \
+ test -n "$$results" || results=/dev/null; \
+ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
+ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
+ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
+ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
+ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
+ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
+ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
+ if test `expr $$fail + $$xpass + $$error` -eq 0; then \
+ success=true; \
+ else \
+ success=false; \
+ fi; \
+ br='==================='; br=$$br$$br$$br$$br; \
+ result_count () \
+ { \
+ if test x"$$1" = x"--maybe-color"; then \
+ maybe_colorize=yes; \
+ elif test x"$$1" = x"--no-color"; then \
+ maybe_colorize=no; \
+ else \
+ echo "$@: invalid 'result_count' usage" >&2; exit 4; \
+ fi; \
+ shift; \
+ desc=$$1 count=$$2; \
+ if test $$maybe_colorize = yes && test $$count -gt 0; then \
+ color_start=$$3 color_end=$$std; \
+ else \
+ color_start= color_end=; \
+ fi; \
+ echo "$${color_start}# $$desc $$count$${color_end}"; \
+ }; \
+ create_testsuite_report () \
+ { \
+ result_count $$1 "TOTAL:" $$all "$$brg"; \
+ result_count $$1 "PASS: " $$pass "$$grn"; \
+ result_count $$1 "SKIP: " $$skip "$$blu"; \
+ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
+ result_count $$1 "FAIL: " $$fail "$$red"; \
+ result_count $$1 "XPASS:" $$xpass "$$red"; \
+ result_count $$1 "ERROR:" $$error "$$mgn"; \
+ }; \
+ { \
+ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
+ $(am__rst_title); \
+ create_testsuite_report --no-color; \
+ echo; \
+ echo ".. contents:: :depth: 2"; \
+ echo; \
+ for b in $$bases; do echo $$b; done \
+ | $(am__create_global_log); \
+ } >$(TEST_SUITE_LOG).tmp || exit 1; \
+ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
+ if $$success; then \
+ col="$$grn"; \
+ else \
+ col="$$red"; \
+ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
+ fi; \
+ echo "$${col}$$br$${std}"; \
+ echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \
+ echo "$${col}$$br$${std}"; \
+ create_testsuite_report --maybe-color; \
+ echo "$$col$$br$$std"; \
+ if $$success; then :; else \
+ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
+ if test -n "$(PACKAGE_BUGREPORT)"; then \
+ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
+ fi; \
+ echo "$$col$$br$$std"; \
+ fi; \
+ $$success || exit 1
+
+check-TESTS: $(check_PROGRAMS)
+ @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
+ @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ trs_list=`for i in $$bases; do echo $$i.trs; done`; \
+ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
+ exit $$?;
+recheck: all $(check_PROGRAMS)
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ bases=`for i in $$bases; do echo $$i; done \
+ | $(am__list_recheck_tests)` || exit 1; \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ log_list=`echo $$log_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
+ am__force_recheck=am--force-recheck \
+ TEST_LOGS="$$log_list"; \
+ exit $$?
+nft-table-test.log: nft-table-test$(EXEEXT)
+ @p='nft-table-test$(EXEEXT)'; \
+ b='nft-table-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-chain-test.log: nft-chain-test$(EXEEXT)
+ @p='nft-chain-test$(EXEEXT)'; \
+ b='nft-chain-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-object-test.log: nft-object-test$(EXEEXT)
+ @p='nft-object-test$(EXEEXT)'; \
+ b='nft-object-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-rule-test.log: nft-rule-test$(EXEEXT)
+ @p='nft-rule-test$(EXEEXT)'; \
+ b='nft-rule-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-set-test.log: nft-set-test$(EXEEXT)
+ @p='nft-set-test$(EXEEXT)'; \
+ b='nft-set-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-flowtable-test.log: nft-flowtable-test$(EXEEXT)
+ @p='nft-flowtable-test$(EXEEXT)'; \
+ b='nft-flowtable-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_bitwise-test.log: nft-expr_bitwise-test$(EXEEXT)
+ @p='nft-expr_bitwise-test$(EXEEXT)'; \
+ b='nft-expr_bitwise-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_byteorder-test.log: nft-expr_byteorder-test$(EXEEXT)
+ @p='nft-expr_byteorder-test$(EXEEXT)'; \
+ b='nft-expr_byteorder-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_counter-test.log: nft-expr_counter-test$(EXEEXT)
+ @p='nft-expr_counter-test$(EXEEXT)'; \
+ b='nft-expr_counter-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_cmp-test.log: nft-expr_cmp-test$(EXEEXT)
+ @p='nft-expr_cmp-test$(EXEEXT)'; \
+ b='nft-expr_cmp-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_ct-test.log: nft-expr_ct-test$(EXEEXT)
+ @p='nft-expr_ct-test$(EXEEXT)'; \
+ b='nft-expr_ct-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_dup-test.log: nft-expr_dup-test$(EXEEXT)
+ @p='nft-expr_dup-test$(EXEEXT)'; \
+ b='nft-expr_dup-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_fwd-test.log: nft-expr_fwd-test$(EXEEXT)
+ @p='nft-expr_fwd-test$(EXEEXT)'; \
+ b='nft-expr_fwd-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_exthdr-test.log: nft-expr_exthdr-test$(EXEEXT)
+ @p='nft-expr_exthdr-test$(EXEEXT)'; \
+ b='nft-expr_exthdr-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_immediate-test.log: nft-expr_immediate-test$(EXEEXT)
+ @p='nft-expr_immediate-test$(EXEEXT)'; \
+ b='nft-expr_immediate-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_limit-test.log: nft-expr_limit-test$(EXEEXT)
+ @p='nft-expr_limit-test$(EXEEXT)'; \
+ b='nft-expr_limit-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_lookup-test.log: nft-expr_lookup-test$(EXEEXT)
+ @p='nft-expr_lookup-test$(EXEEXT)'; \
+ b='nft-expr_lookup-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_log-test.log: nft-expr_log-test$(EXEEXT)
+ @p='nft-expr_log-test$(EXEEXT)'; \
+ b='nft-expr_log-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_match-test.log: nft-expr_match-test$(EXEEXT)
+ @p='nft-expr_match-test$(EXEEXT)'; \
+ b='nft-expr_match-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_masq-test.log: nft-expr_masq-test$(EXEEXT)
+ @p='nft-expr_masq-test$(EXEEXT)'; \
+ b='nft-expr_masq-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_meta-test.log: nft-expr_meta-test$(EXEEXT)
+ @p='nft-expr_meta-test$(EXEEXT)'; \
+ b='nft-expr_meta-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_numgen-test.log: nft-expr_numgen-test$(EXEEXT)
+ @p='nft-expr_numgen-test$(EXEEXT)'; \
+ b='nft-expr_numgen-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_nat-test.log: nft-expr_nat-test$(EXEEXT)
+ @p='nft-expr_nat-test$(EXEEXT)'; \
+ b='nft-expr_nat-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_objref-test.log: nft-expr_objref-test$(EXEEXT)
+ @p='nft-expr_objref-test$(EXEEXT)'; \
+ b='nft-expr_objref-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_payload-test.log: nft-expr_payload-test$(EXEEXT)
+ @p='nft-expr_payload-test$(EXEEXT)'; \
+ b='nft-expr_payload-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_queue-test.log: nft-expr_queue-test$(EXEEXT)
+ @p='nft-expr_queue-test$(EXEEXT)'; \
+ b='nft-expr_queue-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_range-test.log: nft-expr_range-test$(EXEEXT)
+ @p='nft-expr_range-test$(EXEEXT)'; \
+ b='nft-expr_range-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_quota-test.log: nft-expr_quota-test$(EXEEXT)
+ @p='nft-expr_quota-test$(EXEEXT)'; \
+ b='nft-expr_quota-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_redir-test.log: nft-expr_redir-test$(EXEEXT)
+ @p='nft-expr_redir-test$(EXEEXT)'; \
+ b='nft-expr_redir-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_reject-test.log: nft-expr_reject-test$(EXEEXT)
+ @p='nft-expr_reject-test$(EXEEXT)'; \
+ b='nft-expr_reject-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_target-test.log: nft-expr_target-test$(EXEEXT)
+ @p='nft-expr_target-test$(EXEEXT)'; \
+ b='nft-expr_target-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+nft-expr_hash-test.log: nft-expr_hash-test$(EXEEXT)
+ @p='nft-expr_hash-test$(EXEEXT)'; \
+ b='nft-expr_hash-test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+.test.log:
+ @p='$<'; \
+ $(am__set_b); \
+ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+@am__EXEEXT_TRUE@.test$(EXEEXT).log:
+@am__EXEEXT_TRUE@ @p='$<'; \
+@am__EXEEXT_TRUE@ $(am__set_b); \
+@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
+@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
+
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+ -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
+ -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs)
+ -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -f ./$(DEPDIR)/nft-chain-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_bitwise-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_byteorder-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_cmp-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_counter-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_ct-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_dup-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_exthdr-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_fwd-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_hash-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_immediate-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_limit-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_log-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_lookup-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_masq-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_match-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_meta-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_nat-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_numgen-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_objref-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_payload-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_queue-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_quota-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_range-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_redir-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_reject-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_target-test.Po
+ -rm -f ./$(DEPDIR)/nft-flowtable-test.Po
+ -rm -f ./$(DEPDIR)/nft-object-test.Po
+ -rm -f ./$(DEPDIR)/nft-rule-test.Po
+ -rm -f ./$(DEPDIR)/nft-set-test.Po
+ -rm -f ./$(DEPDIR)/nft-table-test.Po
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f ./$(DEPDIR)/nft-chain-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_bitwise-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_byteorder-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_cmp-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_counter-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_ct-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_dup-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_exthdr-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_fwd-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_hash-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_immediate-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_limit-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_log-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_lookup-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_masq-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_match-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_meta-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_nat-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_numgen-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_objref-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_payload-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_queue-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_quota-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_range-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_redir-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_reject-test.Po
+ -rm -f ./$(DEPDIR)/nft-expr_target-test.Po
+ -rm -f ./$(DEPDIR)/nft-flowtable-test.Po
+ -rm -f ./$(DEPDIR)/nft-object-test.Po
+ -rm -f ./$(DEPDIR)/nft-rule-test.Po
+ -rm -f ./$(DEPDIR)/nft-set-test.Po
+ -rm -f ./$(DEPDIR)/nft-table-test.Po
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-TESTS \
+ check-am clean clean-checkPROGRAMS clean-generic clean-libtool \
+ cscopelist-am ctags ctags-am distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ recheck tags tags-am uninstall uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/nft-chain-test.c b/tests/nft-chain-test.c
new file mode 100644
index 0000000..35a65be
--- /dev/null
+++ b/tests/nft-chain-test.c
@@ -0,0 +1,109 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libnftnl/chain.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_chain(struct nftnl_chain *a, struct nftnl_chain *b)
+{
+
+ if (strcmp(nftnl_chain_get_str(a, NFTNL_CHAIN_NAME),
+ nftnl_chain_get_str(b, NFTNL_CHAIN_NAME)) != 0)
+ print_err("Chain name mismatches");
+ if (strcmp(nftnl_chain_get_str(a, NFTNL_CHAIN_TABLE),
+ nftnl_chain_get_str(b, NFTNL_CHAIN_TABLE)) != 0)
+ print_err("Chain table mismatches");
+ if (nftnl_chain_get_u32(a, NFTNL_CHAIN_FAMILY) !=
+ nftnl_chain_get_u32(b, NFTNL_CHAIN_FAMILY))
+ print_err("Chain family mismatches");
+ if (nftnl_chain_get_u32(a, NFTNL_CHAIN_POLICY) !=
+ nftnl_chain_get_u32(b, NFTNL_CHAIN_POLICY))
+ print_err("Chain policy mismatches");
+ if (nftnl_chain_get_u32(a, NFTNL_CHAIN_HOOKNUM) !=
+ nftnl_chain_get_u32(b, NFTNL_CHAIN_HOOKNUM))
+ print_err("Chain hooknum mismatches");
+ if (nftnl_chain_get_s32(a, NFTNL_CHAIN_PRIO) !=
+ nftnl_chain_get_s32(b, NFTNL_CHAIN_PRIO))
+ print_err("Chain Prio mismatches");
+ if (nftnl_chain_get_u32(a, NFTNL_CHAIN_USE) !=
+ nftnl_chain_get_u32(b, NFTNL_CHAIN_USE))
+ print_err("Chain use mismatches");
+ if (nftnl_chain_get_u64(a, NFTNL_CHAIN_PACKETS) !=
+ nftnl_chain_get_u64(b, NFTNL_CHAIN_PACKETS))
+ print_err("Chain packets mismatches");
+ if (nftnl_chain_get_u64(a, NFTNL_CHAIN_BYTES) !=
+ nftnl_chain_get_u64(b, NFTNL_CHAIN_BYTES))
+ print_err("Chain bytes mismatches");
+ if (nftnl_chain_get_u64(a, NFTNL_CHAIN_HANDLE) !=
+ nftnl_chain_get_u64(b, NFTNL_CHAIN_HANDLE))
+ print_err("Chain handle mismatches");
+ if (strcmp(nftnl_chain_get_str(a, NFTNL_CHAIN_TYPE),
+ nftnl_chain_get_str(b, NFTNL_CHAIN_TYPE)) != 0)
+ print_err("Chain type mismatches");
+ if (strcmp(nftnl_chain_get_str(a, NFTNL_CHAIN_DEV),
+ nftnl_chain_get_str(b, NFTNL_CHAIN_DEV)) != 0)
+ print_err("Chain device mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_chain *a, *b;
+ char buf[4096];
+ struct nlmsghdr *nlh;
+
+ a = nftnl_chain_alloc();
+ b = nftnl_chain_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+
+ nftnl_chain_set_str(a, NFTNL_CHAIN_NAME, "test");
+ nftnl_chain_set_u32(a, NFTNL_CHAIN_FAMILY, AF_INET);
+ nftnl_chain_set_str(a, NFTNL_CHAIN_TABLE, "Table");
+ nftnl_chain_set_u32(a, NFTNL_CHAIN_POLICY,0x12345678);
+ nftnl_chain_set_u32(a, NFTNL_CHAIN_HOOKNUM, 0x34567812);
+ nftnl_chain_set_s32(a, NFTNL_CHAIN_PRIO, 0x56781234);
+ nftnl_chain_set_u32(a, NFTNL_CHAIN_USE, 0x78123456);
+ nftnl_chain_set_u64(a, NFTNL_CHAIN_PACKETS, 0x1234567812345678);
+ nftnl_chain_set_u64(a, NFTNL_CHAIN_BYTES, 0x7812345678123456);
+ nftnl_chain_set_u64(a, NFTNL_CHAIN_HANDLE, 0x5678123456781234);
+ nftnl_chain_set_str(a, NFTNL_CHAIN_TYPE, "Prueba");
+ nftnl_chain_set_str(a, NFTNL_CHAIN_DEV, "eth0");
+
+ /* cmd extracted from include/linux/netfilter/nf_tables.h */
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWCHAIN, AF_INET, 0, 1234);
+ nftnl_chain_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_chain_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ cmp_nftnl_chain(a, b);
+
+ nftnl_chain_free(a);
+ nftnl_chain_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+
+}
diff --git a/tests/nft-expr_bitwise-test.c b/tests/nft-expr_bitwise-test.c
new file mode 100644
index 0000000..44c4bf0
--- /dev/null
+++ b/tests/nft-expr_bitwise-test.c
@@ -0,0 +1,285 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *test, const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m [%s] %s\n", test, msg);
+}
+
+static void cmp_nftnl_expr_bool(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ uint32_t maska, maskb;
+ uint32_t xora, xorb;
+
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BITWISE_DREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BITWISE_DREG))
+ print_err("bool", "Expr BITWISE_DREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BITWISE_SREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BITWISE_SREG))
+ print_err("bool", "Expr BITWISE_SREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BITWISE_OP) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BITWISE_OP))
+ print_err("bool", "Expr BITWISE_OP mismatches");
+ if (nftnl_expr_get_u16(rule_a, NFTNL_EXPR_BITWISE_LEN) !=
+ nftnl_expr_get_u16(rule_b, NFTNL_EXPR_BITWISE_LEN))
+ print_err("bool", "Expr BITWISE_LEN mismatches");
+ nftnl_expr_get(rule_a, NFTNL_EXPR_BITWISE_MASK, &maska);
+ nftnl_expr_get(rule_b, NFTNL_EXPR_BITWISE_MASK, &maskb);
+ if (maska != maskb)
+ print_err("bool", "Size of BITWISE_MASK mismatches");
+ nftnl_expr_get(rule_a, NFTNL_EXPR_BITWISE_XOR, &xora);
+ nftnl_expr_get(rule_b, NFTNL_EXPR_BITWISE_XOR, &xorb);
+ if (xora != xorb)
+ print_err("bool", "Size of BITWISE_XOR mismatches");
+}
+
+static void cmp_nftnl_expr_lshift(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ uint32_t data_a, data_b;
+
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BITWISE_DREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BITWISE_DREG))
+ print_err("lshift", "Expr BITWISE_DREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BITWISE_SREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BITWISE_SREG))
+ print_err("lshift", "Expr BITWISE_SREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BITWISE_OP) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BITWISE_OP))
+ print_err("lshift", "Expr BITWISE_OP mismatches");
+ if (nftnl_expr_get_u16(rule_a, NFTNL_EXPR_BITWISE_LEN) !=
+ nftnl_expr_get_u16(rule_b, NFTNL_EXPR_BITWISE_LEN))
+ print_err("lshift", "Expr BITWISE_LEN mismatches");
+ nftnl_expr_get(rule_a, NFTNL_EXPR_BITWISE_DATA, &data_a);
+ nftnl_expr_get(rule_b, NFTNL_EXPR_BITWISE_DATA, &data_b);
+ if (data_a != data_b)
+ print_err("lshift", "Expr BITWISE_DATA mismatches");
+}
+
+static void cmp_nftnl_expr_rshift(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ uint32_t data_a, data_b;
+
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BITWISE_DREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BITWISE_DREG))
+ print_err("rshift", "Expr BITWISE_DREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BITWISE_SREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BITWISE_SREG))
+ print_err("rshift", "Expr BITWISE_SREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BITWISE_OP) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BITWISE_OP))
+ print_err("rshift", "Expr BITWISE_OP mismatches");
+ if (nftnl_expr_get_u16(rule_a, NFTNL_EXPR_BITWISE_LEN) !=
+ nftnl_expr_get_u16(rule_b, NFTNL_EXPR_BITWISE_LEN))
+ print_err("rshift", "Expr BITWISE_LEN mismatches");
+ nftnl_expr_get(rule_a, NFTNL_EXPR_BITWISE_DATA, &data_a);
+ nftnl_expr_get(rule_b, NFTNL_EXPR_BITWISE_DATA, &data_b);
+ if (data_a != data_b)
+ print_err("rshift", "Expr BITWISE_DATA mismatches");
+}
+
+static void test_bool(void)
+{
+ struct nftnl_rule *a, *b = NULL;
+ struct nftnl_expr *ex = NULL;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b = NULL;
+ struct nftnl_expr *rule_a, *rule_b = NULL;
+ uint32_t mask = 0x01010101;
+ uint32_t xor = 0x12345678;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("bool", "OOM");
+ ex = nftnl_expr_alloc("bitwise");
+ if (ex == NULL)
+ print_err("bool", "OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_SREG, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_DREG, 0x78123456);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_OP, NFT_BITWISE_BOOL);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_LEN, 0x56781234);
+ nftnl_expr_set(ex, NFTNL_EXPR_BITWISE_MASK, &mask, sizeof(mask));
+ nftnl_expr_set(ex, NFTNL_EXPR_BITWISE_XOR, &xor, sizeof(xor));
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("bool", "parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("bool", "OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("bool", "OOM");
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("bool", "More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+
+ cmp_nftnl_expr_bool(rule_a,rule_b);
+
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+}
+
+static void test_lshift(void)
+{
+ struct nftnl_rule *a, *b = NULL;
+ struct nftnl_expr *ex = NULL;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b = NULL;
+ struct nftnl_expr *rule_a, *rule_b = NULL;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("lshift", "OOM");
+ ex = nftnl_expr_alloc("bitwise");
+ if (ex == NULL)
+ print_err("lshift", "OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_SREG, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_DREG, 0x78123456);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_OP, NFT_BITWISE_LSHIFT);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_LEN, 0x56781234);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_DATA, 13);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("lshift", "parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("lshift", "OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("lshift", "OOM");
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("lshift", "More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+
+ cmp_nftnl_expr_lshift(rule_a,rule_b);
+
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+}
+
+static void test_rshift(void)
+{
+ struct nftnl_rule *a, *b = NULL;
+ struct nftnl_expr *ex = NULL;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b = NULL;
+ struct nftnl_expr *rule_a, *rule_b = NULL;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("rshift", "OOM");
+ ex = nftnl_expr_alloc("bitwise");
+ if (ex == NULL)
+ print_err("rshift", "OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_SREG, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_DREG, 0x78123456);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_OP, NFT_BITWISE_RSHIFT);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_LEN, 0x56781234);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BITWISE_DATA, 17);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("rshift", "parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("rshift", "OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("rshift", "OOM");
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("rshift", "More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+
+ cmp_nftnl_expr_rshift(rule_a,rule_b);
+
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+}
+
+int main(int argc, char *argv[])
+{
+ test_bool();
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ test_lshift();
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ test_rshift();
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_byteorder-test.c b/tests/nft-expr_byteorder-test.c
new file mode 100644
index 0000000..30e64c0
--- /dev/null
+++ b/tests/nft-expr_byteorder-test.c
@@ -0,0 +1,107 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BYTEORDER_DREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BYTEORDER_DREG))
+ print_err("Expr NFTNL_EXPR_BYTEORDER_DREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BYTEORDER_SREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BYTEORDER_SREG))
+ print_err("Expr NFTNL_EXPR_BYTEORDER_SREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BYTEORDER_OP) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BYTEORDER_OP))
+ print_err("Expr NFTNL_EXPR_BYTEORDER_OP mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BYTEORDER_LEN) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BYTEORDER_LEN))
+ print_err("Expr NFTNL_EXPR_BYTEORDER_DREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_BYTEORDER_SIZE) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_BYTEORDER_SIZE))
+ print_err("Expr NFTNL_EXPR_BITWISE_SIZE mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("byteorder");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BYTEORDER_SREG, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BYTEORDER_DREG, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BYTEORDER_OP, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BYTEORDER_LEN, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_BYTEORDER_SIZE, 0x12345678);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a,rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_cmp-test.c b/tests/nft-expr_cmp-test.c
new file mode 100644
index 0000000..0bab67b
--- /dev/null
+++ b/tests/nft-expr_cmp-test.c
@@ -0,0 +1,102 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ uint32_t data_lena, data_lenb;
+
+ nftnl_expr_get(rule_a, NFTNL_EXPR_CMP_DATA, &data_lena);
+ nftnl_expr_get(rule_b, NFTNL_EXPR_CMP_DATA, &data_lenb);
+ if (data_lena != data_lenb)
+ print_err("Size of NFTNL_EXPR_CMP_DATA mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_CMP_SREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_CMP_SREG))
+ print_err("Expr NFTNL_EXPR_CMP_SREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_CMP_OP) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_CMP_OP))
+ print_err("Expr NFTNL_EXPR_CMP_OP mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+ uint32_t data_len = 0x01010101;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("cmp");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set(ex, NFTNL_EXPR_CMP_DATA, &data_len, sizeof(data_len));
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_CMP_SREG, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_CMP_OP, 0x78123456);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_counter-test.c b/tests/nft-expr_counter-test.c
new file mode 100644
index 0000000..81c3fe1
--- /dev/null
+++ b/tests/nft-expr_counter-test.c
@@ -0,0 +1,93 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u64(rule_a, NFTNL_EXPR_CTR_BYTES) !=
+ nftnl_expr_get_u64(rule_b, NFTNL_EXPR_CTR_BYTES))
+ print_err("Expr NFTNL_EXPR_CTR_BYTES mismatches");
+ if (nftnl_expr_get_u64(rule_a, NFTNL_EXPR_CTR_PACKETS) !=
+ nftnl_expr_get_u64(rule_b, NFTNL_EXPR_CTR_PACKETS))
+ print_err("Expr NFTNL_EXPR_CTR_PACKETS mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+
+ ex = nftnl_expr_alloc("counter");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u64(ex, NFTNL_EXPR_CTR_BYTES, 0x123456789abcdef0);
+ nftnl_expr_set_u64(ex, NFTNL_EXPR_CTR_PACKETS, 0xf0123456789abcde);
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_ct-test.c b/tests/nft-expr_ct-test.c
new file mode 100644
index 0000000..548a426
--- /dev/null
+++ b/tests/nft-expr_ct-test.c
@@ -0,0 +1,97 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_CT_KEY) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_CT_KEY))
+ print_err("Expr CT_KEY mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_CT_DIR) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_CT_DIR))
+ print_err("Expr CT_DIR mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_CT_DREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_CT_DREG))
+ print_err("Expr CT_DREG mismatches");
+}
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("ct");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_CT_KEY, 0x1234568);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_CT_DIR, 0x12);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_CT_DREG, 0x78123456);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_dup-test.c b/tests/nft-expr_dup-test.c
new file mode 100644
index 0000000..0c5df9a
--- /dev/null
+++ b/tests/nft-expr_dup-test.c
@@ -0,0 +1,94 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_DUP_SREG_ADDR) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_DUP_SREG_ADDR))
+ print_err("Expr SREG_TO mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_DUP_SREG_DEV) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_DUP_SREG_DEV))
+ print_err("Expr SREG_OIF mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("dup");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_DUP_SREG_ADDR, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_DUP_SREG_DEV, 0x78123456);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_exthdr-test.c b/tests/nft-expr_exthdr-test.c
new file mode 100644
index 0000000..b2c72b7
--- /dev/null
+++ b/tests/nft-expr_exthdr-test.c
@@ -0,0 +1,101 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_EXTHDR_DREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_EXTHDR_DREG))
+ print_err("Expr NFTNL_EXPR_EXTHDR_DREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_EXTHDR_TYPE) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_EXTHDR_TYPE))
+ print_err("Expr NFTNL_EXPR_EXTHDR_TYPE mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_EXTHDR_OFFSET) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_EXTHDR_OFFSET))
+ print_err("Expr NFTNL_EXPR_EXTHDR_OFFSET mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_EXTHDR_LEN) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_EXTHDR_LEN))
+ print_err("Expr NFTNL_EXPR_EXTHDR_LEN mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("exthdr");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_EXTHDR_DREG, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_EXTHDR_TYPE, 0x12);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_EXTHDR_OFFSET, 0x78123456);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_EXTHDR_LEN, 0x56781234);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_fwd-test.c b/tests/nft-expr_fwd-test.c
new file mode 100644
index 0000000..825dad3
--- /dev/null
+++ b/tests/nft-expr_fwd-test.c
@@ -0,0 +1,90 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_FWD_SREG_DEV) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_FWD_SREG_DEV))
+ print_err("Expr SREG_OIF mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("dup");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_FWD_SREG_DEV, 0x78123456);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_hash-test.c b/tests/nft-expr_hash-test.c
new file mode 100644
index 0000000..6644bb7
--- /dev/null
+++ b/tests/nft-expr_hash-test.c
@@ -0,0 +1,110 @@
+/*
+ * (C) 2016 by Laura Garcia <nevola@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_HASH_SREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_HASH_SREG))
+ print_err("Expr NFTNL_EXPR_HASH_SREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_HASH_DREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_HASH_DREG))
+ print_err("Expr NFTNL_EXPR_HASH_DREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_HASH_MODULUS) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_HASH_MODULUS))
+ print_err("Expr NFTNL_EXPR_HASH_MODULUS mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_HASH_SEED) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_HASH_SEED))
+ print_err("Expr NFTNL_EXPR_HASH_SEED mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_HASH_OFFSET) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_HASH_OFFSET))
+ print_err("Expr NFTNL_EXPR_HASH_OFFSET mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_HASH_TYPE) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_HASH_TYPE))
+ print_err("Expr NFTNL_EXPR_HASH_TYPE mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("hash");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_HASH_SREG, 0x1234568);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_HASH_DREG, 0x78123456);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_HASH_MODULUS, 0x78123456);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_HASH_SEED, 0x78123456);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_HASH_OFFSET, 0x3612845);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_HASH_TYPE, NFT_HASH_JENKINS);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_immediate-test.c b/tests/nft-expr_immediate-test.c
new file mode 100644
index 0000000..5027813
--- /dev/null
+++ b/tests/nft-expr_immediate-test.c
@@ -0,0 +1,135 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr_verdict(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ const char *chain_a, *chain_b;
+ uint32_t len_a, len_b;
+
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_IMM_DREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_IMM_DREG))
+ print_err("Expr NFTNL_EXPR_IMM_DREG mismatches");
+
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_IMM_VERDICT) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_IMM_VERDICT))
+ print_err("Expr NFTNL_EXPR_IMM_VERDICT mismatches");
+
+ chain_a = nftnl_expr_get(rule_a, NFTNL_EXPR_IMM_CHAIN, &len_a);
+ chain_b = nftnl_expr_get(rule_b, NFTNL_EXPR_IMM_CHAIN, &len_b);
+ if (len_a != len_b || strncmp(chain_a, chain_b, len_a))
+ print_err("Expr NFTNL_EXPR_IMM_CHAIN mismatches");
+}
+
+static void cmp_nftnl_expr_value(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ const uint32_t *data_a, *data_b;
+ uint32_t len_a, len_b;
+
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_IMM_DREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_IMM_DREG))
+ print_err("Expr NFTNL_EXPR_IMM_DREG mismatches");
+
+ data_a = nftnl_expr_get(rule_a, NFTNL_EXPR_IMM_DATA, &len_a);
+ data_b = nftnl_expr_get(rule_b, NFTNL_EXPR_IMM_DATA, &len_b);
+ if (len_a != len_b || memcmp(data_a, data_b, len_a))
+ print_err("Expr NFTNL_EXPR_IMM_DATA mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex_val, *ex_ver;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+ const char *chain = "tests_chain01234";
+ const char *data = "test_data_01234";
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex_val = nftnl_expr_alloc("immediate");
+ ex_ver = nftnl_expr_alloc("immediate");
+ if (!ex_val || !ex_ver)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex_val, NFTNL_EXPR_IMM_DREG, 0x1234568);
+ nftnl_expr_set(ex_val, NFTNL_EXPR_IMM_DATA, data, sizeof(data));
+
+ nftnl_expr_set_u32(ex_ver, NFTNL_EXPR_IMM_DREG, 0x1234568);
+ nftnl_expr_set_u32(ex_ver, NFTNL_EXPR_IMM_VERDICT, NFT_GOTO);
+ nftnl_expr_set(ex_ver, NFTNL_EXPR_IMM_CHAIN, chain, sizeof(chain));
+
+ nftnl_rule_add_expr(a, ex_val);
+ nftnl_rule_add_expr(a, ex_ver);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr_value(rule_a, rule_b);
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr_verdict(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 2 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_limit-test.c b/tests/nft-expr_limit-test.c
new file mode 100644
index 0000000..38aaf56
--- /dev/null
+++ b/tests/nft-expr_limit-test.c
@@ -0,0 +1,108 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u64(rule_a, NFTNL_EXPR_LIMIT_RATE) !=
+ nftnl_expr_get_u64(rule_b, NFTNL_EXPR_LIMIT_RATE))
+ print_err("Expr CTR_BYTES mismatches");
+ if (nftnl_expr_get_u64(rule_a, NFTNL_EXPR_LIMIT_UNIT) !=
+ nftnl_expr_get_u64(rule_b, NFTNL_EXPR_LIMIT_UNIT))
+ print_err("Expr CTR_PACKET mismatches");
+ if (nftnl_expr_get_u64(rule_a, NFTNL_EXPR_LIMIT_BURST) !=
+ nftnl_expr_get_u64(rule_b, NFTNL_EXPR_LIMIT_BURST))
+ print_err("Expr CTR_PACKET mismatches");
+ if (nftnl_expr_get_u64(rule_a, NFTNL_EXPR_LIMIT_TYPE) !=
+ nftnl_expr_get_u64(rule_b, NFTNL_EXPR_LIMIT_TYPE))
+ print_err("Expr TYPE mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_LIMIT_FLAGS) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_LIMIT_FLAGS))
+ print_err("Expr FLAGS mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("limit");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u64(ex, NFTNL_EXPR_LIMIT_RATE, 0x123456789abcdef0);
+ nftnl_expr_set_u64(ex, NFTNL_EXPR_LIMIT_UNIT, 0xf0123456789abcde);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_LIMIT_BURST, 0x89123456);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_LIMIT_TYPE, 0xdef01234);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_LIMIT_FLAGS, 0x34def012);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_log-test.c b/tests/nft-expr_log-test.c
new file mode 100644
index 0000000..275ffae
--- /dev/null
+++ b/tests/nft-expr_log-test.c
@@ -0,0 +1,101 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+ test_ok = 0;
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_LOG_SNAPLEN) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_LOG_SNAPLEN))
+ print_err("Expr NFTNL_EXPR_LOG_SNAPLEN mismatches");
+ if (nftnl_expr_get_u16(rule_a, NFTNL_EXPR_LOG_GROUP) !=
+ nftnl_expr_get_u16(rule_b, NFTNL_EXPR_LOG_GROUP))
+ print_err("Expr NFTNL_EXPR_LOG_GROUP mismatches");
+ if (nftnl_expr_get_u16(rule_a, NFTNL_EXPR_LOG_QTHRESHOLD) !=
+ nftnl_expr_get_u16(rule_b, NFTNL_EXPR_LOG_QTHRESHOLD))
+ print_err("Expr NFTNL_EXPR_LOG_QTHRESHOLD mismatches");
+ if(strcmp(nftnl_expr_get_str(rule_a, NFTNL_EXPR_LOG_PREFIX),
+ nftnl_expr_get_str(rule_b, NFTNL_EXPR_LOG_PREFIX)) != 0)
+ print_err("Expr NFTNL_EXPR_LOG_PREFIX mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("log");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_LOG_SNAPLEN, 0x12345678);
+ nftnl_expr_set_u16(ex, NFTNL_EXPR_LOG_GROUP, 0x1234);
+ nftnl_expr_set_u16(ex, NFTNL_EXPR_LOG_QTHRESHOLD, 0x3412);
+ nftnl_expr_set_str(ex, NFTNL_EXPR_LOG_PREFIX, "test");
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_lookup-test.c b/tests/nft-expr_lookup-test.c
new file mode 100644
index 0000000..9b70525
--- /dev/null
+++ b/tests/nft-expr_lookup-test.c
@@ -0,0 +1,111 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_LOOKUP_SREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_LOOKUP_SREG))
+ print_err("Expr NFTNL_EXPR_LOOKUP_SREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_LOOKUP_DREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_LOOKUP_DREG))
+ print_err("Expr NFTNL_EXPR_LOOKUP_DREG mismatches");
+ if (strcmp(nftnl_expr_get_str(rule_a, NFTNL_EXPR_LOOKUP_SET),
+ nftnl_expr_get_str(rule_b, NFTNL_EXPR_LOOKUP_SET)))
+ print_err("Expr NFTNL_EXPR_LOOKUP_SET mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_LOOKUP_SET_ID) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_LOOKUP_SET_ID))
+ print_err("Expr NFTNL_EXPR_LOOKUP_SET_ID mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_LOOKUP_FLAGS) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_LOOKUP_FLAGS)) {
+ print_err("Expr NFTNL_EXPR_LOOKUP_FLAGS mismatches");
+ printf("%X %X\n",
+ nftnl_expr_get_u32(rule_a, NFTNL_EXPR_LOOKUP_FLAGS),
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_LOOKUP_FLAGS));
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+ const char *lookup_set = "test_set_01243";
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("lookup");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_LOOKUP_SREG, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_LOOKUP_DREG, 0x78123456);
+ nftnl_expr_set_str(ex, NFTNL_EXPR_LOOKUP_SET, lookup_set);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_LOOKUP_FLAGS, 0x12345678);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_masq-test.c b/tests/nft-expr_masq-test.c
new file mode 100644
index 0000000..0917914
--- /dev/null
+++ b/tests/nft-expr_masq-test.c
@@ -0,0 +1,97 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_MASQ_FLAGS) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_MASQ_FLAGS))
+ print_err("Expr NFTNL_EXPR_MASQ_FLAGS mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_MASQ_REG_PROTO_MIN) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_MASQ_REG_PROTO_MIN))
+ print_err("Expr NFTNL_EXPR_MASQ_REG_PROTO_MIN mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_MASQ_REG_PROTO_MAX) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_MASQ_REG_PROTO_MAX))
+ print_err("Expr NFTNL_EXPR_MASQ_REG_PROTO_MAX mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("masq");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_MASQ_FLAGS, 0x1234568);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_MASQ_REG_PROTO_MIN, 0x5432178);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_MASQ_REG_PROTO_MAX, 0x8765421);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_match-test.c b/tests/nft-expr_match-test.c
new file mode 100644
index 0000000..fdeacc4
--- /dev/null
+++ b/tests/nft-expr_match-test.c
@@ -0,0 +1,108 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void print_err2(const char *msg, uint32_t a, uint32_t b)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s size a: %d b: %d \n", msg, a, b);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ uint32_t lena, lenb;
+
+ if (strcmp(nftnl_expr_get_str(rule_a, NFTNL_EXPR_MT_NAME),
+ nftnl_expr_get_str(rule_b, NFTNL_EXPR_MT_NAME)) != 0)
+ print_err("Expr NFTNL_EXPR_MT_NAME mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_MT_REV) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_MT_REV))
+ print_err("Expr NFTNL_EXPR_MT_REV mismatches");
+ nftnl_expr_get(rule_a, NFTNL_EXPR_MT_INFO, &lena);
+ nftnl_expr_get(rule_b, NFTNL_EXPR_MT_INFO, &lenb);
+ if (lena != lenb)
+ print_err2("Expr NFTNL_EXPR_MT_INFO size mismatches", lena, lenb);
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+ char data[16] = "0123456789abcdef";
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("match");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_str(ex, NFTNL_EXPR_MT_NAME, "Tests");
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_MT_REV, 0x12345678);
+ nftnl_expr_set(ex, NFTNL_EXPR_MT_INFO, strdup(data), sizeof(data));
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_meta-test.c b/tests/nft-expr_meta-test.c
new file mode 100644
index 0000000..2f03fb1
--- /dev/null
+++ b/tests/nft-expr_meta-test.c
@@ -0,0 +1,94 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_META_KEY) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_META_KEY))
+ print_err("Expr NFTNL_EXPR_META_KEY mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_META_DREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_META_DREG))
+ print_err("Expr NFTNL_EXPR_META_DREG mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("meta");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_META_KEY, 0x1234568);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_META_DREG, 0x78123456);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_nat-test.c b/tests/nft-expr_nat-test.c
new file mode 100644
index 0000000..3a365dd
--- /dev/null
+++ b/tests/nft-expr_nat-test.c
@@ -0,0 +1,116 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <linux/netfilter/xt_iprange.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NAT_TYPE) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NAT_TYPE))
+ print_err("Expr NFTNL_EXPR_NAT_TYPE mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NAT_FAMILY) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NAT_FAMILY))
+ print_err("Expr NFTNL_EXPR_NAT_FAMILY mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NAT_REG_ADDR_MIN) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NAT_REG_ADDR_MIN))
+ print_err("Expr NFTNL_EXPR_NAT_REG_ADDR_MIN mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NAT_REG_ADDR_MAX) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NAT_REG_ADDR_MAX))
+ print_err("Expr NFTNL_EXPR_NAT_REG_ADDR_MAX mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NAT_REG_PROTO_MIN) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NAT_REG_PROTO_MIN))
+ print_err("Expr NFTNL_EXPR_NAT_REG_PROTO_MIN mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NAT_REG_PROTO_MAX) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NAT_REG_PROTO_MAX))
+ print_err("Expr NFTNL_EXPR_NAT_REG_PROTO_MAX mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NAT_FLAGS) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NAT_FLAGS))
+ print_err("Expr NFTNL_EXPR_NAT_FLAGS mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("nat");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_NAT_TYPE, 0x1234568);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_NAT_FAMILY, 0x3456721);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_NAT_REG_ADDR_MIN, 0x1452638);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_NAT_REG_ADDR_MAX, 0x5134682);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_NAT_REG_PROTO_MIN, 0x6124385);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_NAT_REG_PROTO_MAX, 0x2153846);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_NAT_FLAGS, 0x4213683);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_numgen-test.c b/tests/nft-expr_numgen-test.c
new file mode 100644
index 0000000..94df50f
--- /dev/null
+++ b/tests/nft-expr_numgen-test.c
@@ -0,0 +1,102 @@
+/*
+ * (C) 2016 by Laura Garcia <nevola@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NG_DREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NG_DREG))
+ print_err("Expr NFTNL_EXPR_NG_DREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NG_MODULUS) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NG_MODULUS))
+ print_err("Expr NFTNL_EXPR_NG_MODULUS mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NG_TYPE) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NG_TYPE))
+ print_err("Expr NFTNL_EXPR_NG_TYPE mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_NG_OFFSET) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_NG_OFFSET))
+ print_err("Expr NFTNL_EXPR_NG_OFFSET mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("numgen");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_NG_DREG, 0x1234568);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_NG_MODULUS, 0x78123456);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_NG_TYPE, NFT_NG_INCREMENTAL);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_NG_OFFSET, 0x1000000);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_objref-test.c b/tests/nft-expr_objref-test.c
new file mode 100644
index 0000000..08e27ce
--- /dev/null
+++ b/tests/nft-expr_objref-test.c
@@ -0,0 +1,96 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_OBJREF_IMM_TYPE) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_OBJREF_IMM_TYPE))
+ print_err("Expr NFTNL_EXPR_OBJREF_IMM_TYPE mismatches");
+ if (strcmp(nftnl_expr_get_str(rule_a, NFTNL_EXPR_OBJREF_IMM_NAME),
+ nftnl_expr_get_str(rule_b, NFTNL_EXPR_OBJREF_IMM_NAME)))
+ print_err("Expr NFTNL_EXPR_OBJREF_IMM_NAME mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+ const char *name = "test_set_01243";
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("lookup");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_OBJREF_IMM_TYPE, 0x78123456);
+ nftnl_expr_set_str(ex, NFTNL_EXPR_OBJREF_IMM_NAME, name);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_payload-test.c b/tests/nft-expr_payload-test.c
new file mode 100644
index 0000000..aec1710
--- /dev/null
+++ b/tests/nft-expr_payload-test.c
@@ -0,0 +1,103 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+
+#include <linux/netfilter/nf_tables.h>
+#include <linux/netfilter/xt_iprange.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_PAYLOAD_DREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_PAYLOAD_DREG))
+ print_err("Expr NFTNL_EXPR_PAYLOAD_DREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_PAYLOAD_BASE) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_PAYLOAD_BASE))
+ print_err("Expr NFTNL_EXPR_PAYLOAD_BASE mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_PAYLOAD_OFFSET) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_PAYLOAD_OFFSET))
+ print_err("Expr NFTNL_EXPR_PAYLOAD_OFFSET mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_PAYLOAD_LEN) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_PAYLOAD_LEN))
+ print_err("Expr NFTNL_EXPR_PAYLOAD_LEN mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("payload");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_PAYLOAD_DREG, 0x1234568);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_PAYLOAD_BASE, 0x78123456);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_PAYLOAD_OFFSET, 0x56781234);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_PAYLOAD_LEN, 0x78561234);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_queue-test.c b/tests/nft-expr_queue-test.c
new file mode 100644
index 0000000..d007b98
--- /dev/null
+++ b/tests/nft-expr_queue-test.c
@@ -0,0 +1,102 @@
+/*
+ * (C) 2013 by Eric Leblond <eric@regit.org>
+ *
+ * Based on test framework by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <linux/netfilter/xt_iprange.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u16(rule_a, NFTNL_EXPR_QUEUE_NUM) !=
+ nftnl_expr_get_u16(rule_b, NFTNL_EXPR_QUEUE_NUM))
+ print_err("Expr NFTNL_EXPR_QUEUE_NUM mismatches");
+ if (nftnl_expr_get_u16(rule_a, NFTNL_EXPR_QUEUE_TOTAL) !=
+ nftnl_expr_get_u16(rule_b, NFTNL_EXPR_QUEUE_TOTAL))
+ print_err("Expr NFTNL_EXPR_QUEUE_TOTAL mismatches");
+ if (nftnl_expr_get_u16(rule_a, NFTNL_EXPR_QUEUE_FLAGS) !=
+ nftnl_expr_get_u16(rule_b, NFTNL_EXPR_QUEUE_FLAGS))
+ print_err("Expr NFTNL_EXPR_QUEUE_FLAGS mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("queue");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u16(ex, NFTNL_EXPR_QUEUE_NUM, 0x01010);
+ nftnl_expr_set_u16(ex, NFTNL_EXPR_QUEUE_TOTAL, 0x1234);
+ nftnl_expr_set_u16(ex, NFTNL_EXPR_QUEUE_FLAGS, 0x4321);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_quota-test.c b/tests/nft-expr_quota-test.c
new file mode 100644
index 0000000..a3eb2e3
--- /dev/null
+++ b/tests/nft-expr_quota-test.c
@@ -0,0 +1,92 @@
+/*
+ * (C) 2016 by Pablo Neira Ayuso <pablo@netfilter.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a, struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u64(rule_a, NFTNL_EXPR_QUOTA_BYTES) !=
+ nftnl_expr_get_u64(rule_b, NFTNL_EXPR_QUOTA_BYTES))
+ print_err("Expr NFTNL_EXPR_QUOTA_BYTES mismatches");
+ if (nftnl_expr_get_u64(rule_a, NFTNL_EXPR_QUOTA_FLAGS) !=
+ nftnl_expr_get_u64(rule_b, NFTNL_EXPR_QUOTA_FLAGS))
+ print_err("Expr NFTNL_EXPR_QUOTA_FLAGS mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+
+ ex = nftnl_expr_alloc("counter");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u64(ex, NFTNL_EXPR_QUOTA_BYTES, 0x123456789abcdef0);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_QUOTA_FLAGS, 0x12345678);
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_range-test.c b/tests/nft-expr_range-test.c
new file mode 100644
index 0000000..6ef896b
--- /dev/null
+++ b/tests/nft-expr_range-test.c
@@ -0,0 +1,109 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void range_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ uint32_t data_a, data_b;
+
+ nftnl_expr_get(rule_a, NFTNL_EXPR_RANGE_FROM_DATA, &data_a);
+ nftnl_expr_get(rule_b, NFTNL_EXPR_RANGE_FROM_DATA, &data_b);
+ if (data_a != data_b)
+ print_err("Size of NFTNL_EXPR_RANGE_FROM_DATA mismatches");
+ nftnl_expr_get(rule_a, NFTNL_EXPR_RANGE_TO_DATA, &data_a);
+ nftnl_expr_get(rule_b, NFTNL_EXPR_RANGE_TO_DATA, &data_b);
+ if (data_a != data_b)
+ print_err("Size of NFTNL_EXPR_RANGE_TO_DATA mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_RANGE_SREG) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_RANGE_SREG))
+ print_err("Expr NFTNL_EXPR_RANGE_SREG mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_RANGE_OP) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_RANGE_OP))
+ print_err("Expr NFTNL_EXPR_RANGE_OP mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+ uint32_t data_a = 0x01010101, data_b = 0x02020202;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("range");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set(ex, NFTNL_EXPR_RANGE_FROM_DATA,
+ &data_a, sizeof(data_a));
+ nftnl_expr_set(ex, NFTNL_EXPR_RANGE_TO_DATA,
+ &data_b, sizeof(data_b));
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_RANGE_SREG, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_RANGE_OP, 0x78123456);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ range_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_redir-test.c b/tests/nft-expr_redir-test.c
new file mode 100644
index 0000000..8e1f30c
--- /dev/null
+++ b/tests/nft-expr_redir-test.c
@@ -0,0 +1,97 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_REDIR_REG_PROTO_MIN) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_REDIR_REG_PROTO_MIN))
+ print_err("Expr NFTNL_EXPR_REDIR_REG_PROTO_MIN mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_REDIR_REG_PROTO_MAX) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_REDIR_REG_PROTO_MAX))
+ print_err("Expr NFTNL_EXPR_REDIR_REG_PROTO_MAX mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_REDIR_FLAGS) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_REDIR_FLAGS))
+ print_err("Expr NFTNL_EXPR_REDIR_FLAGS mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("redir");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_REDIR_REG_PROTO_MIN, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_REDIR_REG_PROTO_MAX, 0x56781234);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_REDIR_FLAGS, 0x12003400);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("Parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More than 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_reject-test.c b/tests/nft-expr_reject-test.c
new file mode 100644
index 0000000..049401d
--- /dev/null
+++ b/tests/nft-expr_reject-test.c
@@ -0,0 +1,96 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <linux/netfilter/xt_iprange.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_REJECT_TYPE) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_REJECT_TYPE))
+ print_err("Expr NFTNL_EXPR_REJECT_TYPE mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_REJECT_CODE) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_REJECT_CODE))
+ print_err("Expr NFTNL_EXPR_REJECT_CODE mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+ ex = nftnl_expr_alloc("reject");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_REJECT_TYPE, 0x12345678);
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_REJECT_CODE, 0x45681234);
+
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-expr_target-test.c b/tests/nft-expr_target-test.c
new file mode 100644
index 0000000..a517206
--- /dev/null
+++ b/tests/nft-expr_target-test.c
@@ -0,0 +1,108 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libmnl/libmnl.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/expr.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void print_err2(const char *msg, uint32_t a, uint32_t b)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s size a: %d b: %d \n",msg, a, b);
+}
+
+static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
+ struct nftnl_expr *rule_b)
+{
+ uint32_t lena, lenb;
+
+ if (strcmp(nftnl_expr_get_str(rule_a, NFTNL_EXPR_TG_NAME),
+ nftnl_expr_get_str(rule_b, NFTNL_EXPR_TG_NAME)) != 0)
+ print_err("Expr NFTNL_EXPR_TG_NAME mismatches");
+ if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_TG_REV) !=
+ nftnl_expr_get_u32(rule_b, NFTNL_EXPR_TG_REV))
+ print_err("Expr NFTNL_EXPR_TG_REV mismatches");
+ nftnl_expr_get(rule_a, NFTNL_EXPR_TG_INFO, &lena);
+ nftnl_expr_get(rule_b, NFTNL_EXPR_TG_INFO, &lenb);
+ if (lena != lenb)
+ print_err2("Expr NFTNL_EXPR_TG_INFO size mismatches", lena, lenb);
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_rule *a, *b;
+ struct nftnl_expr *ex;
+ struct nlmsghdr *nlh;
+ char buf[4096];
+ struct nftnl_expr_iter *iter_a, *iter_b;
+ struct nftnl_expr *rule_a, *rule_b;
+ char data[16] = "0123456789abcdef";
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+
+ ex = nftnl_expr_alloc("target");
+ if (ex == NULL)
+ print_err("OOM");
+
+ nftnl_expr_set(ex, NFTNL_EXPR_TG_NAME, "test", strlen("test"));
+ nftnl_expr_set_u32(ex, NFTNL_EXPR_TG_REV, 0x56781234);
+ nftnl_expr_set(ex, NFTNL_EXPR_TG_INFO, strdup(data), sizeof(data));
+ nftnl_rule_add_expr(a, ex);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ iter_a = nftnl_expr_iter_create(a);
+ iter_b = nftnl_expr_iter_create(b);
+ if (iter_a == NULL || iter_b == NULL)
+ print_err("OOM");
+
+ rule_a = nftnl_expr_iter_next(iter_a);
+ rule_b = nftnl_expr_iter_next(iter_b);
+ if (rule_a == NULL || rule_b == NULL)
+ print_err("OOM");
+
+ cmp_nftnl_expr(rule_a, rule_b);
+
+ if (nftnl_expr_iter_next(iter_a) != NULL ||
+ nftnl_expr_iter_next(iter_b) != NULL)
+ print_err("More 1 expr.");
+
+ nftnl_expr_iter_destroy(iter_a);
+ nftnl_expr_iter_destroy(iter_b);
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-flowtable-test.c b/tests/nft-flowtable-test.c
new file mode 100644
index 0000000..8ab8d4c
--- /dev/null
+++ b/tests/nft-flowtable-test.c
@@ -0,0 +1,87 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libnftnl/flowtable.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_flowtable(struct nftnl_flowtable *a, struct nftnl_flowtable *b)
+{
+ if (strcmp(nftnl_flowtable_get_str(a, NFTNL_FLOWTABLE_NAME),
+ nftnl_flowtable_get_str(b, NFTNL_FLOWTABLE_NAME)) != 0)
+ print_err("Flowtable name mismatches");
+ if (strcmp(nftnl_flowtable_get_str(a, NFTNL_FLOWTABLE_TABLE),
+ nftnl_flowtable_get_str(b, NFTNL_FLOWTABLE_TABLE)) != 0)
+ print_err("Flowtable table mismatches");
+ if (nftnl_flowtable_get_u32(a, NFTNL_FLOWTABLE_FAMILY) !=
+ nftnl_flowtable_get_u32(b, NFTNL_FLOWTABLE_FAMILY))
+ print_err("Flowtable family mismatches");
+ if (nftnl_flowtable_get_u32(a, NFTNL_FLOWTABLE_HOOKNUM) !=
+ nftnl_flowtable_get_u32(b, NFTNL_FLOWTABLE_HOOKNUM))
+ print_err("Flowtable hooknum mismatches");
+ if (nftnl_flowtable_get_s32(a, NFTNL_FLOWTABLE_PRIO) !=
+ nftnl_flowtable_get_s32(b, NFTNL_FLOWTABLE_PRIO))
+ print_err("Flowtable prio mismatches");
+ if (nftnl_flowtable_get_u32(a, NFTNL_FLOWTABLE_USE) !=
+ nftnl_flowtable_get_u32(b, NFTNL_FLOWTABLE_USE))
+ print_err("Flowtable use mismatches");
+#if 0
+ if (nftnl_flowtable_get_u32(a, NFTNL_FLOWTABLE_SIZE) !=
+ nftnl_flowtable_get_u32(b, NFTNL_FLOWTABLE_SIZE))
+ print_err("Flowtable size mismatches");
+#endif
+ if (nftnl_flowtable_get_u32(a, NFTNL_FLOWTABLE_FLAGS) !=
+ nftnl_flowtable_get_u32(b, NFTNL_FLOWTABLE_FLAGS))
+ print_err("Flowtable flags mismatches");
+ if (nftnl_flowtable_get_u64(a, NFTNL_FLOWTABLE_HANDLE) !=
+ nftnl_flowtable_get_u64(b, NFTNL_FLOWTABLE_HANDLE))
+ print_err("Flowtable handle mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_flowtable *a, *b;
+ char buf[4096];
+ struct nlmsghdr *nlh;
+
+ a = nftnl_flowtable_alloc();
+ b = nftnl_flowtable_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+
+ nftnl_flowtable_set_str(a, NFTNL_FLOWTABLE_NAME, "test");
+ nftnl_flowtable_set_u32(a, NFTNL_FLOWTABLE_FAMILY, AF_INET);
+ nftnl_flowtable_set_str(a, NFTNL_FLOWTABLE_TABLE, "Table");
+ nftnl_flowtable_set_u32(a, NFTNL_FLOWTABLE_HOOKNUM, 0x34567812);
+ nftnl_flowtable_set_s32(a, NFTNL_FLOWTABLE_PRIO, 0x56781234);
+ nftnl_flowtable_set_u32(a, NFTNL_FLOWTABLE_USE, 0x78123456);
+ nftnl_flowtable_set_u32(a, NFTNL_FLOWTABLE_SIZE, 0x89016745);
+ nftnl_flowtable_set_u32(a, NFTNL_FLOWTABLE_FLAGS, 0x45016723);
+ nftnl_flowtable_set_u64(a, NFTNL_FLOWTABLE_HANDLE, 0x2345016789);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWFLOWTABLE, AF_INET,
+ 0, 1234);
+ nftnl_flowtable_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_flowtable_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ cmp_nftnl_flowtable(a, b);
+
+ nftnl_flowtable_free(a);
+ nftnl_flowtable_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-object-test.c b/tests/nft-object-test.c
new file mode 100644
index 0000000..d2ca444
--- /dev/null
+++ b/tests/nft-object-test.c
@@ -0,0 +1,78 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+
+#include <linux/netfilter/nf_tables.h>
+#include <libnftnl/object.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_obj(struct nftnl_obj *a, struct nftnl_obj *b)
+{
+ if (strcmp(nftnl_obj_get_str(a, NFTNL_OBJ_TABLE),
+ nftnl_obj_get_str(b, NFTNL_OBJ_TABLE)) != 0)
+ print_err("table name mismatches");
+ if (strcmp(nftnl_obj_get_str(a, NFTNL_OBJ_NAME),
+ nftnl_obj_get_str(b, NFTNL_OBJ_NAME)) != 0)
+ print_err("name mismatches");
+ if (nftnl_obj_get_u32(a, NFTNL_OBJ_FAMILY) !=
+ nftnl_obj_get_u32(b, NFTNL_OBJ_FAMILY))
+ print_err("family mismatches");
+ if (nftnl_obj_get_u32(a, NFTNL_OBJ_TYPE) !=
+ nftnl_obj_get_u32(b, NFTNL_OBJ_TYPE))
+ print_err("type mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ char buf[4096];
+ struct nlmsghdr *nlh;
+ struct nftnl_obj *a;
+ struct nftnl_obj *b;
+
+ a = nftnl_obj_alloc();
+ b = nftnl_obj_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+
+ nftnl_obj_set_str(a, NFTNL_OBJ_TABLE, "test");
+ nftnl_obj_set_str(a, NFTNL_OBJ_NAME, "test");
+ nftnl_obj_set_u32(a, NFTNL_OBJ_FAMILY, AF_INET);
+ nftnl_obj_set_u32(a, NFTNL_OBJ_USE, 1);
+ nftnl_obj_set_u64(a, NFTNL_OBJ_CTR_BYTES, 0x12345678abcd);
+ nftnl_obj_set_u64(a, NFTNL_OBJ_CTR_PKTS, 0xcd12345678ab);
+
+ /* cmd extracted from include/linux/netfilter/nf_tables.h */
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWOBJ, AF_INET, 0, 1234);
+ nftnl_obj_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_obj_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ cmp_nftnl_obj(a, b);
+
+ nftnl_obj_free(a);
+ nftnl_obj_free(b);
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-rule-test.c b/tests/nft-rule-test.c
new file mode 100644
index 0000000..3a92223
--- /dev/null
+++ b/tests/nft-rule-test.c
@@ -0,0 +1,116 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <linux/netfilter/nf_tables.h>
+#include <libnftnl/rule.h>
+#include <libnftnl/udata.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_rule(struct nftnl_rule *a, struct nftnl_rule *b)
+{
+ const void *udata_a, *udata_b;
+ uint32_t len_a, len_b;
+
+ if (nftnl_rule_get_u32(a, NFTNL_RULE_FAMILY) !=
+ nftnl_rule_get_u32(b, NFTNL_RULE_FAMILY))
+ print_err("Rule family mismatches");
+ if (strcmp(nftnl_rule_get_str(a, NFTNL_RULE_TABLE),
+ nftnl_rule_get_str(b, NFTNL_RULE_TABLE)) != 0)
+ print_err("Rule table mismatches");
+ if (strcmp(nftnl_rule_get_str(a, NFTNL_RULE_CHAIN),
+ nftnl_rule_get_str(b, NFTNL_RULE_CHAIN)) != 0)
+ print_err("Rule table mismatches");
+ if (nftnl_rule_get_u64(a, NFTNL_RULE_HANDLE) !=
+ nftnl_rule_get_u64(b, NFTNL_RULE_HANDLE))
+ print_err("Rule handle mismatches");
+ if (nftnl_rule_get_u32(a, NFTNL_RULE_COMPAT_PROTO) !=
+ nftnl_rule_get_u32(b, NFTNL_RULE_COMPAT_PROTO))
+ print_err("Rule compat_proto mismatches");
+ if (nftnl_rule_get_u32(a, NFTNL_RULE_COMPAT_FLAGS) !=
+ nftnl_rule_get_u32(b, NFTNL_RULE_COMPAT_FLAGS))
+ print_err("Rule compat_flags mismatches");
+ if (nftnl_rule_get_u32(a, NFTNL_RULE_ID) !=
+ nftnl_rule_get_u32(b, NFTNL_RULE_ID))
+ print_err("Rule id mismatches");
+ if (nftnl_rule_get_u32(a, NFTNL_RULE_POSITION_ID) !=
+ nftnl_rule_get_u32(b, NFTNL_RULE_POSITION_ID))
+ print_err("Rule position_id mismatches");
+ if (nftnl_rule_get_u64(a, NFTNL_RULE_POSITION) !=
+ nftnl_rule_get_u64(b, NFTNL_RULE_POSITION))
+ print_err("Rule compat_position mismatches");
+
+ udata_a = nftnl_rule_get_data(a, NFTNL_RULE_USERDATA, &len_a);
+ udata_b = nftnl_rule_get_data(b, NFTNL_RULE_USERDATA, &len_b);
+
+ if (len_a != len_b || memcmp(udata_a, udata_b, len_a) != 0)
+ print_err("Rule userdata mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_udata_buf *udata;
+ struct nftnl_rule *a, *b;
+ char buf[4096];
+ struct nlmsghdr *nlh;
+
+ a = nftnl_rule_alloc();
+ b = nftnl_rule_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+
+ udata = nftnl_udata_buf_alloc(NFT_USERDATA_MAXLEN);
+ if (!udata)
+ print_err("OOM");
+
+ if (!nftnl_udata_put_strz(udata, 0, "hello world"))
+ print_err("User data too big");
+
+ nftnl_rule_set_u32(a, NFTNL_RULE_FAMILY, AF_INET);
+ nftnl_rule_set_str(a, NFTNL_RULE_TABLE, "table");
+ nftnl_rule_set_str(a, NFTNL_RULE_CHAIN, "chain");
+ nftnl_rule_set_u64(a, NFTNL_RULE_HANDLE, 0x1234567812345678);
+ nftnl_rule_set_u32(a, NFTNL_RULE_COMPAT_PROTO, 0x12345678);
+ nftnl_rule_set_u32(a, NFTNL_RULE_COMPAT_FLAGS, 0x12345678);
+ nftnl_rule_set_u32(a, NFTNL_RULE_ID, 0x12345678);
+ nftnl_rule_set_u32(a, NFTNL_RULE_POSITION_ID, 0x12345678);
+ nftnl_rule_set_u64(a, NFTNL_RULE_POSITION, 0x1234567812345678);
+ nftnl_rule_set_data(a, NFTNL_RULE_USERDATA,
+ nftnl_udata_buf_data(udata),
+ nftnl_udata_buf_len(udata));
+ nftnl_udata_buf_free(udata);
+
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, AF_INET, 0, 1234);
+ nftnl_rule_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_rule_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ cmp_nftnl_rule(a,b);
+
+ nftnl_rule_free(a);
+ nftnl_rule_free(b);
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-set-test.c b/tests/nft-set-test.c
new file mode 100644
index 0000000..66916fe
--- /dev/null
+++ b/tests/nft-set-test.c
@@ -0,0 +1,92 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <linux/netfilter/nf_tables.h>
+
+#include <libnftnl/set.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_set(struct nftnl_set *a, struct nftnl_set *b)
+{
+ if (strcmp(nftnl_set_get_str(a, NFTNL_SET_TABLE),
+ nftnl_set_get_str(b, NFTNL_SET_TABLE)) != 0)
+ print_err("Set table mismatches");
+ if (strcmp(nftnl_set_get_str(a, NFTNL_SET_NAME),
+ nftnl_set_get_str(b, NFTNL_SET_NAME)) != 0)
+ print_err("Set name mismatches");
+ if (nftnl_set_get_u32(a, NFTNL_SET_FLAGS) !=
+ nftnl_set_get_u32(b, NFTNL_SET_FLAGS))
+ print_err("Set flags mismatches");
+ if (nftnl_set_get_u32(a, NFTNL_SET_KEY_TYPE) !=
+ nftnl_set_get_u32(b, NFTNL_SET_KEY_TYPE))
+ print_err("Set key-type mismatches");
+ if (nftnl_set_get_u32(a, NFTNL_SET_KEY_LEN) !=
+ nftnl_set_get_u32(b, NFTNL_SET_KEY_LEN))
+ print_err("Set key-len mismatches");
+ if (nftnl_set_get_u32(a, NFTNL_SET_DATA_TYPE) !=
+ nftnl_set_get_u32(b, NFTNL_SET_DATA_TYPE))
+ print_err("Set data-type mismatches");
+ if (nftnl_set_get_u32(a, NFTNL_SET_DATA_LEN) !=
+ nftnl_set_get_u32(b, NFTNL_SET_DATA_LEN))
+ print_err("Set data-len mismatches");
+ if (strcmp(nftnl_set_get_str(a, NFTNL_SET_USERDATA),
+ nftnl_set_get_str(b, NFTNL_SET_USERDATA)) != 0)
+ print_err("Set userdata mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ struct nftnl_set *a, *b = NULL;
+ char buf[4096];
+ struct nlmsghdr *nlh;
+
+ a = nftnl_set_alloc();
+ b = nftnl_set_alloc();
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+
+ nftnl_set_set_str(a, NFTNL_SET_TABLE, "test-table");
+ nftnl_set_set_str(a, NFTNL_SET_NAME, "test-name");
+ nftnl_set_set_u32(a, NFTNL_SET_FLAGS, 0x12345678);
+ nftnl_set_set_u32(a, NFTNL_SET_KEY_TYPE, 0x12345678);
+ nftnl_set_set_u32(a, NFTNL_SET_KEY_LEN, 0x12345678);
+ nftnl_set_set_u32(a, NFTNL_SET_DATA_TYPE, 0x12345678);
+ nftnl_set_set_u32(a, NFTNL_SET_DATA_LEN, 0x12345678);
+ nftnl_set_set_u32(a, NFTNL_SET_FAMILY, 0x12345678);
+ nftnl_set_set_str(a, NFTNL_SET_USERDATA, "testing user data");
+
+ /* cmd extracted from include/linux/netfilter/nf_tables.h */
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWSET, AF_INET, 0, 1234);
+ nftnl_set_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_set_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ cmp_nftnl_set(a,b);
+
+ nftnl_set_free(a); nftnl_set_free(b);
+
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}
diff --git a/tests/nft-table-test.c b/tests/nft-table-test.c
new file mode 100644
index 0000000..53cf3d1
--- /dev/null
+++ b/tests/nft-table-test.c
@@ -0,0 +1,73 @@
+/*
+ * (C) 2013 by Ana Rey Botello <anarey@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netinet/in.h>
+
+#include <linux/netfilter/nf_tables.h>
+#include <libnftnl/table.h>
+
+static int test_ok = 1;
+
+static void print_err(const char *msg)
+{
+ test_ok = 0;
+ printf("\033[31mERROR:\e[0m %s\n", msg);
+}
+
+static void cmp_nftnl_table(struct nftnl_table *a, struct nftnl_table *b)
+{
+ if (strcmp(nftnl_table_get_str(a, NFTNL_TABLE_NAME),
+ nftnl_table_get_str(b, NFTNL_TABLE_NAME)) != 0)
+ print_err("table name mismatches");
+ if (nftnl_table_get_u32(a, NFTNL_TABLE_FLAGS) !=
+ nftnl_table_get_u32(b, NFTNL_TABLE_FLAGS))
+ print_err("table flags mismatches");
+ if (nftnl_table_get_u32(a, NFTNL_TABLE_FAMILY) !=
+ nftnl_table_get_u32(b, NFTNL_TABLE_FAMILY))
+ print_err("table family mismatches");
+}
+
+int main(int argc, char *argv[])
+{
+ char buf[4096];
+ struct nlmsghdr *nlh;
+
+ struct nftnl_table *a = NULL;
+ struct nftnl_table *b = NULL;
+ a = nftnl_table_alloc();
+ b = nftnl_table_alloc();
+
+ if (a == NULL || b == NULL)
+ print_err("OOM");
+
+ nftnl_table_set_str(a, NFTNL_TABLE_NAME, "test");
+ nftnl_table_set_u32(a, NFTNL_TABLE_FAMILY, AF_INET);
+ nftnl_table_set_u32(a, NFTNL_TABLE_FLAGS, 0);
+
+ /* cmd extracted from include/linux/netfilter/nf_tables.h */
+ nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWTABLE, AF_INET, 0, 1234);
+ nftnl_table_nlmsg_build_payload(nlh, a);
+
+ if (nftnl_table_nlmsg_parse(nlh, b) < 0)
+ print_err("parsing problems");
+
+ cmp_nftnl_table(a,b);
+
+ nftnl_table_free(a);
+ nftnl_table_free(b);
+ if (!test_ok)
+ exit(EXIT_FAILURE);
+
+ printf("%s: \033[32mOK\e[0m\n", argv[0]);
+ return EXIT_SUCCESS;
+}