I am trying to create a kernel module that will be able to send out modified packets from ones it receives through netfilter hooking. I'm using a code skeleton provided here. I am creating a raw socket inside the kernel simply using this code:
struct socket *sockptr;
sock_create(PF_INET, SOCK_RAW, IPPROTO_TCP, &sockptr);
The sendpacket function is called by this:
len = sendpacket(sockptr, dev, IPPROTO_TCP, duplicate, ntohs(dupiph->tot_len));
socketptr being the raw socket I created, dev being the net_device in passed to me by the hooking function, and duplicate being a modified copy of the original packet.
The return from the call to dev_queue_xmit indicates that the packet was transmitted successfully but I cannot see the packet on the wire. I have two questions: first, I would like to be able to better debug what is happening so any advice concerning that is much appreciated. Also, I am wondering if I am handling the socket creation properly or if there is some type of configuration I am missing. This is all very new to me so it very well could be that I am missing something silly.