I am writing a Kernel Module that uses Netfilter hooks to modify some of the TCP header information and obviously, before sending, I want to re-calculate the checksum.
I al
Here is an example which combine netfilter API + checksum for TCP (not IP):
http://www.linuxvirtualserver.org/software/tcpsp/index.html
Look into the file called tcpsp_core.c.
th->check = 0;
th->check = csum_tcpudp_magic(iph->saddr, iph->daddr,
datalen, iph->protocol,
csum_partial((char *)th, datalen, 0));
skb->ip_summed = CHECKSUM_UNNECESSARY;
(notice it is assigned zero first, checksum calculated, then IP checksum indicated as not needed).
Depends on which netfilter module u load (there are many!!!) they will work at different layer, eg, iptable working at IP layer is shown below (image):
http://ars.sciencedirect.com/content/image/1-s2.0-S1389128608004040-gr3.jpg