LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-24-2009, 06:57 PM   #1
yaplej
Member
 
Registered: Apr 2009
Distribution: CentOS, Ubuntu, openSuSE
Posts: 165
Blog Entries: 1

Rep: Reputation: 22
Calculate new tcp checksum


Hey all,

I am trying to find how to calculate an entire new TCP checksum. My code now does not seem to be working correctly. Whenever a packet requires a TCP checksum it fails the TCP checksum.

I have found some other functions, but have not had much luck with any of them so far.

tcph: struct tcphdr
tcplen: skb->len - ip_hdrlen(skb)
iph: struct iphdr

Code:
tcph->check = 0;
tcph->check = tcp_v4_check(tcph, tcplen, 
           iph->saddr, 
           iph->daddr,
           csum_partial((char *)tcph, tcplen, 0));
 
Old 09-25-2009, 11:27 AM   #2
yaplej
Member
 
Registered: Apr 2009
Distribution: CentOS, Ubuntu, openSuSE
Posts: 165

Original Poster
Blog Entries: 1

Rep: Reputation: 22
My problem actually was somewhere else not with the checksum calculation. That code actually works perfectly to calculate a new checksum.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
TCP checksum doubt arun4will Programming 1 05-17-2007 08:53 AM
TCP checksum error mshenbagaraj Programming 3 05-16-2007 02:43 PM
tcp checksum incorrect x1228 Programming 1 09-11-2006 03:53 AM
TCP header checksum live_dont_exist Programming 16 04-13-2005 12:45 PM
anyone can help me with the TCP checksum? vaaub Programming 1 02-10-2004 01:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration