summaryrefslogtreecommitdiffstats
path: root/utils/nfulnl_test.c
blob: 06db38f8f94657f0f9ab2481c5de6770014d44da (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
34
35
36
37
38

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

#include "libnfnetlink_log.h"

int main(int argc, char **argv)
{
	struct nfulnl_handle h;
	struct nfulnl_g_handle qh;
	struct nfulnl_g_handle qh100;
	int rv;
	char buf[4096];

	rv = nfulnl_open(&h);
	if (rv < 0)
		exit(rv);

	nfulnl_unbind_pf(&h, AF_INET);
	nfulnl_bind_pf(&h, AF_INET);
	nfulnl_bind_group(&h, &qh, 0);
	nfulnl_bind_group(&h, &qh100, 100);
	nfulnl_set_mode(&qh, NFULNL_COPY_PACKET, 0xffff);

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

	nfulnl_unbind_group(&qh100);
	nfulnl_unbind_group(&qh);
	nfulnl_unbind_pf(&h, AF_INET);

	nfulnl_close(&h);

	exit(0);
}