ddc5fe9c89051dfb70b4ff943a0848acbfddf50a
[platform/upstream/libnetfilter_queue.git] / utils / nfqnl_test.c
1
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include <netinet/in.h>
6
7 #include <libnfnetlink_queue/libnfnetlink_queue.h>
8
9 int main(int argc, char **argv)
10 {
11         struct nfqnl_handle h;
12         struct nfqnl_q_handle qh;
13         int rv;
14         char buf[4096];
15
16         rv = nfqnl_open(&h);
17         if (rv < 0)
18                 exit(rv);
19
20         nfqnl_bind_pf(&h, AF_INET);
21         nfqnl_create_queue(&h, &qh, 0);
22         nfqnl_set_mode(&qh, NFQNL_COPY_PACKET, 0xffff);
23
24         while (recv(h.nfnlh.fd, buf, sizeof(buf), 0) > 0) {
25                 printf("pkt received\n");
26         }
27
28         nfqnl_destroy_queue(&qh);
29         nfqnl_unbind_pf(&h, AF_INET);
30
31         nfqnl_close(&h);
32
33         exit(0);
34 }