summaryrefslogtreecommitdiffstats
path: root/_queue/nfqnl_test.c
blob: 28971da9ae2d720c61a1b45bb515182809c73646 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/in.h>

#include "libnfqnetlink.h"

int main(int argc, char **argv)
{
	struct nfqnl_handle h;
	int rv;
	char buf[4096];

	rv = nfqnl_open(&h, 0);
	if (rv < 0)
		exit(rv);

	nfqnl_bind_pf(&h, AF_INET);
	nfqnl_bind(&h, 0);
	nfqnl_set_mode(&h, 0, NFQNL_COPY_PACKET, 0xffff);

	while (recv(h.nfnlh.fd, buf, sizeof(buf), 0) > 0) {
		printf("pkt received\n");
	}

	nfqnl_unbind(&h, 0);
	nfqnl_unbind_pf(&h, AF_INET);

	nfqnl_close(&h);

	exit(0);
}