13#include <netinet/in.h>
15#include <linux/netfilter/nfnetlink_cttimeout.h>
16#include <libmnl/libmnl.h>
17#include <libnetfilter_cttimeout/libnetfilter_cttimeout.h>
19static int timeout_cb(
const struct nlmsghdr *nlh,
void *data)
21 struct nfct_timeout *t;
31 perror(
"nfct_timeout_nlmsg_parse_payload");
44int main(
int argc,
char *argv[])
46 struct mnl_socket *nl;
47 char buf[MNL_SOCKET_BUFFER_SIZE];
50 struct nfct_timeout *t = NULL;
73 nl = mnl_socket_open(NETLINK_NETFILTER);
75 perror(
"mnl_socket_open");
79 if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) {
80 perror(
"mnl_socket_bind");
83 portid = mnl_socket_get_portid(nl);
85 if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
86 perror(
"mnl_socket_send");
90 ret = mnl_socket_recvfrom(nl, buf,
sizeof(buf));
92 ret = mnl_cb_run(buf, ret, seq, portid, timeout_cb, NULL);
95 ret = mnl_socket_recvfrom(nl, buf,
sizeof(buf));
101 mnl_socket_close(nl);
int nfct_timeout_snprintf(char *buf, size_t size, const struct nfct_timeout *, unsigned int type, unsigned int flags)
void nfct_timeout_free(struct nfct_timeout *)
struct nfct_timeout * nfct_timeout_alloc(void)
int nfct_timeout_attr_set(struct nfct_timeout *t, uint32_t type, const void *data)
struct nlmsghdr * nfct_timeout_nlmsg_build_hdr(char *buf, uint8_t cmd, uint16_t flags, uint32_t seq)
void nfct_timeout_nlmsg_build_payload(struct nlmsghdr *, const struct nfct_timeout *)
int nfct_timeout_nlmsg_parse_payload(const struct nlmsghdr *nlh, struct nfct_timeout *)