Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Fallucchi Antonio <fallucch@cisbic.com>
To: netfilter@lists.netfilter.org
Subject: tcp checkum claculation!!
Date: Thu, 16 Sep 2004 18:43:32 +0200	[thread overview]
Message-ID: <4149C2B4.4010409@cisbic.com> (raw)

Hi,

I need a Help for recalculate the checksum of TCP packet. I read the 
packet from iptables_queue, and sum  16 bit word from and add the 
pseudoheader   ipsource, ipdest, 6, tcp_len (form the ip packet), and i 
see the buddy. I all width complement!

I have see the site  http://www.netfor2.com/tcpsum.htm

and the my code is:

	for (i=0;i<11;i=i+2)
	{
		sum+=*pseudobuff++;
	}

	nwords=swap(len_tcp)-(len_ip*4);
	
	while(nwords>1)
	{
		sum+=*buff++;
		nwords-=2;	
	}
	if(nwords==1)
	{
		sum+=*(unsigned char *)buff;
	}
	
	sum=(sum>>16)+(sum&0xffff);
	sum+=(sum>>16);
	
	sum = ~sum;

but the result isn't correct...

tancks for the help.

bye bye


                 reply	other threads:[~2004-09-16 16:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4149C2B4.4010409@cisbic.com \
    --to=fallucch@cisbic.com \
    --cc=netfilter@lists.netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox