14#include <netinet/in.h>
16#include <linux/netfilter/nf_tables.h>
17#include <libnftnl/table.h>
19static int test_ok = 1;
21static void print_err(
const char *msg)
24 printf(
"\033[31mERROR:\e[0m %s\n", msg);
29 if (strcmp(nftnl_table_get_str(a, NFTNL_TABLE_NAME),
30 nftnl_table_get_str(b, NFTNL_TABLE_NAME)) != 0)
31 print_err(
"table name mismatches");
32 if (nftnl_table_get_u32(a, NFTNL_TABLE_FLAGS) !=
33 nftnl_table_get_u32(b, NFTNL_TABLE_FLAGS))
34 print_err(
"table flags mismatches");
35 if (nftnl_table_get_u32(a, NFTNL_TABLE_FAMILY) !=
36 nftnl_table_get_u32(b, NFTNL_TABLE_FAMILY))
37 print_err(
"table family mismatches");
40int main(
int argc,
char *argv[])
47 a = nftnl_table_alloc();
48 b = nftnl_table_alloc();
50 if (a == NULL || b == NULL)
53 nftnl_table_set_str(a, NFTNL_TABLE_NAME,
"test");
54 nftnl_table_set_u32(a, NFTNL_TABLE_FAMILY, AF_INET);
55 nftnl_table_set_u32(a, NFTNL_TABLE_FLAGS, 0);
58 nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWTABLE, AF_INET, 0, 1234);
59 nftnl_table_nlmsg_build_payload(nlh, a);
61 if (nftnl_table_nlmsg_parse(nlh, b) < 0)
62 print_err(
"parsing problems");
71 printf(
"%s: \033[32mOK\e[0m\n", argv[0]);