I'm using netfilter queues on Ubuntu 14.10. Everything is working so far, I'm seeing packets and setting the verdict, but I'd like to get a better idea of what I'm reading from the queue.
Starting from this page.
This is the code in question:
fd = nfq_fd(h);
while ((rv = recv(fd, buf, sizeof(buf), 0)) >= 0)
{
printf("pkt received\n");
nfq_handle_packet(h, buf, rv);
}
At the point where they have a printf(), what exactly has been read from fd? I assume it is the packet preceeded by some kind of netfilter-specific header, but I have no idea what that header would be. I'm looking at a dump of the bytes I'm reading, but I'm not seeing a valid L2, L3, nor L4 anywhere in there.
Note that as per the documentation, I did setup the queue in copy mode with this line:
nfq_set_mode(qh, NFQNL_COPY_PACKET, 0xffff);