5 #include <libmnl/libmnl.h>
6 #include <libnetfilter_cthelper/libnetfilter_cthelper.h>
8 static int nfct_helper_cb(
const struct nlmsghdr *nlh,
void *data)
14 if (nfct_helper == NULL) {
20 perror(
"nfct_helper_parse_nl_msg");
33 int main(
int argc,
char *argv[])
35 struct mnl_socket *nl;
36 char buf[MNL_SOCKET_BUFFER_SIZE];
42 fprintf(stderr,
"Usage: %s\n", argv[0]);
50 nl = mnl_socket_open(NETLINK_NETFILTER);
52 perror(
"mnl_socket_open");
56 if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) {
57 perror(
"mnl_socket_bind");
60 portid = mnl_socket_get_portid(nl);
62 if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
63 perror(
"mnl_socket_send");
67 ret = mnl_socket_recvfrom(nl, buf,
sizeof(buf));
69 ret = mnl_cb_run(buf, ret, seq, portid, nfct_helper_cb, &full);
72 ret = mnl_socket_recvfrom(nl, buf,
sizeof(buf));
int nfct_helper_nlmsg_parse_payload(const struct nlmsghdr *nlh, struct nfct_helper *nfct_helper)
struct nfct_helper * nfct_helper_alloc(void)
int nfct_helper_snprintf(char *buf, size_t size, struct nfct_helper *nfct_helper, unsigned int type, unsigned int flags)
struct nlmsghdr * nfct_helper_nlmsg_build_hdr(char *buf, uint8_t cmd, uint16_t flags, uint32_t seq)
void nfct_helper_free(struct nfct_helper *h)