As the name says, how can I work with tcp sockets in kernel space? Are there any tricky notes?
I found a message on linuxjournal.com about networking in the kernel.
May be helpful.
Take a look at ng_ksocket. Even if you will not use netgraph, this is a good kernel-level implementation of socket manipulations.