Logo Search packages:      
Sourcecode: libnetfilter-queue version File versions  Download package


Library setup


int nfq_bind_pf (struct nfq_handle *h, u_int16_t pf)
int nfq_close (struct nfq_handle *h)
struct nfq_handlenfq_open (void)
int nfq_unbind_pf (struct nfq_handle *h, u_int16_t pf)

Detailed Description

Library initialisation is made in two steps.

First step is to call nfq_open() to open a NFQUEUE handler.

Second step is to tell the kernel that userspace queueing is handle by NFQUEUE for the selected protocol. This is made by calling nfq_unbind_pf() and nfq_bind_pf() with protocol information. The idea behind this is to enable simultaneously loaded modules to be used for queuing.

Here's a little code snippet that bind with AF_INET:

	h = nfq_open();
	if (!h) {
		fprintf(stderr, "error during nfq_open()\n");

	printf("unbinding existing nf_queue handler for AF_INET (if any)\n");
	if (nfq_unbind_pf(h, AF_INET) < 0) {
		fprintf(stderr, "error during nfq_unbind_pf()\n");

	printf("binding nfnetlink_queue as nf_queue handler for AF_INET\n");
	if (nfq_bind_pf(h, AF_INET) < 0) {
		fprintf(stderr, "error during nfq_bind_pf()\n");

Once this is done, you can setup and use a Queue.

When the program has finished with libnetfilter_queue, it has to call the nfq_close() function to free all associated resources.

Generated by  Doxygen 1.6.0   Back to index