5 #include <netinet/in.h>
6 #include <libmnl/libmnl.h>
7 #include <libnetfilter_cthelper/libnetfilter_cthelper.h>
9 int main(
int argc,
char *argv[])
11 struct mnl_socket *nl;
12 char buf[MNL_SOCKET_BUFFER_SIZE];
20 printf(
"Usage: %s [helper-name] [queue-num]\n", argv[0]);
25 if (nfct_helper == NULL) {
31 nfct_helper_attr_set_u32(nfct_helper, NFCTH_ATTR_QUEUE_NUM, atoi(argv[2]));
32 nfct_helper_attr_set_u16(nfct_helper, NFCTH_ATTR_PROTO_L3NUM, AF_INET);
33 nfct_helper_attr_set_u8(nfct_helper, NFCTH_ATTR_PROTO_L4NUM, IPPROTO_TCP);
41 nfct_helper_policy_attr_set_u32(p, NFCTH_ATTR_POLICY_TIMEOUT, 100);
42 nfct_helper_policy_attr_set_u32(p, NFCTH_ATTR_POLICY_MAX, 100);
48 NLM_F_CREATE | NLM_F_ACK, seq);
54 nl = mnl_socket_open(NETLINK_NETFILTER);
56 perror(
"mnl_socket_open");
60 if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) {
61 perror(
"mnl_socket_bind");
64 portid = mnl_socket_get_portid(nl);
66 if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
67 perror(
"mnl_socket_send");
71 ret = mnl_socket_recvfrom(nl, buf,
sizeof(buf));
73 ret = mnl_cb_run(buf, ret, seq, portid, NULL, NULL);
76 ret = mnl_socket_recvfrom(nl, buf,
sizeof(buf));
void nfct_helper_policy_attr_set(struct nfct_helper_policy *p, enum nfct_helper_policy_attr_type type, const void *data)
struct nfct_helper * nfct_helper_alloc(void)
void nfct_helper_policy_free(struct nfct_helper_policy *p)
struct nfct_helper_policy * nfct_helper_policy_alloc(void)
void nfct_helper_nlmsg_build_payload(struct nlmsghdr *nlh, struct nfct_helper *nfct_helper)
struct nlmsghdr * nfct_helper_nlmsg_build_hdr(char *buf, uint8_t cmd, uint16_t flags, uint32_t seq)
void nfct_helper_attr_set(struct nfct_helper *nfct_helper, enum nfct_helper_attr_type type, const void *data)
void nfct_helper_free(struct nfct_helper *h)