Initializing libipq
#include <linux/netfilter.h> /* \ for libipq methods */
#include <libipq.h> /* / and types. */
/* we want to get IP traffic. */
struct ipq_handle *h = ipq_create_handle(0, PF_INET);
if (!h) {
ipq_perror("ipq_create_handle:");
exit(1);
}
// set the queuing mode - we want to have the packets copied
// to user space, with up to BUFSIZE octets copied.
#define BUFSIZE 2048
rc = ipq_set_mode(h, IPQ_COPY_PACKET, BUFSIZE);
if (rc < 0) {
ipq_perror("ipq_set_mode:");
ipq_destroy_handle(h);
exit(1);
}
Originally written by
guy keren