11#include <linux/netfilter/nf_tables.h>
12#include <libnftnl/table.h>
14static int test_ok = 1;
16static void print_err(
const char *msg)
19 printf(
"\033[31mERROR:\e[0m %s\n", msg);
24 if (strcmp(nftnl_table_get_str(a, NFTNL_TABLE_NAME),
25 nftnl_table_get_str(b, NFTNL_TABLE_NAME)) != 0)
26 print_err(
"table name mismatches");
27 if (nftnl_table_get_u32(a, NFTNL_TABLE_FLAGS) !=
28 nftnl_table_get_u32(b, NFTNL_TABLE_FLAGS))
29 print_err(
"table flags mismatches");
30 if (nftnl_table_get_u32(a, NFTNL_TABLE_FAMILY) !=
31 nftnl_table_get_u32(b, NFTNL_TABLE_FAMILY))
32 print_err(
"table family mismatches");
35int main(
int argc,
char *argv[])
42 a = nftnl_table_alloc();
43 b = nftnl_table_alloc();
45 if (a == NULL || b == NULL)
48 nftnl_table_set_str(a, NFTNL_TABLE_NAME,
"test");
49 nftnl_table_set_u32(a, NFTNL_TABLE_FAMILY, AF_INET);
50 nftnl_table_set_u32(a, NFTNL_TABLE_FLAGS, 0);
53 nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWTABLE, AF_INET, 0, 1234);
54 nftnl_table_nlmsg_build_payload(nlh, a);
56 if (nftnl_table_nlmsg_parse(nlh, b) < 0)
57 print_err(
"parsing problems");
66 printf(
"%s: \033[32mOK\e[0m\n", argv[0]);