7 #include <libmnl/libmnl.h>
8 #include <linux/netfilter/nfnetlink.h>
9 #include <linux/netfilter/nfnetlink_conntrack.h>
11 static int data_cb(
const struct nlmsghdr *nlh,
void *data)
13 printf(
"nft event\n");
19 char buf[MNL_SOCKET_BUFFER_SIZE];
22 nl = mnl_socket_open(NETLINK_NETFILTER);
24 perror(
"mnl_socket_open");
28 if (mnl_socket_bind(nl, (1 << NFNLGRP_NFTABLES-1),
29 MNL_SOCKET_AUTOPID) < 0) {
30 perror(
"mnl_socket_bind");
35 ret = mnl_socket_recvfrom(nl, buf,
sizeof(buf));
37 perror(
"mnl_socket_recvfrom");
41 ret = mnl_cb_run(buf, ret, 0, 0, data_cb, NULL);