Thanks.
Jeff Shipman - CCD
Sandia National Laboratories
(505) 844-1158 / MS-1372
-----Original Message-----
From: John McBride [mailto:jmcbride@aep.ie]
Sent: Thursday, June 13, 2002 11:19 AM
To: Shipman, Jeffrey E
Subject: RE: TCP checksum?
Jeffrey,
find snippet I used to update checksum in my netfilter module -
partly nicked from nat core code
/***************************************************************************
*/
static void update_checksum(struct sk_buff *skb)
{
struct tcphdr *th;
struct iphdr * iph;
int len;
iph = skb->nh.iph;
th = (struct tcphdr *)((u_int32_t *)iph + iph->ihl);
len = skb->len;
/* IP checksum */
iph->check = 0;
iph->check = ip_fast_csum((u8 *)iph, iph->ihl);
if (iph->protocol != IPPROTO_TCP)
return;
th->check = 0;
th->check = tcp_v4_check(th,
len - 4*iph->ihl,
iph->saddr, iph->daddr,
csum_partial((char *)th, len-4*iph->ihl,
0));
}
/***************************************************************************
*/
-----Original Message-----
From: Shipman, Jeffrey E [mailto:jeshipm@sandia.gov]
Sent: Thursday, June 13, 2002 4:11 PM
To: 'linux-kernel@vger.kernel.org'
Subject: TCP checksum?
I'm looking for a function similar to skb_checksum(), but
for the tcphdr->check field. I'm playing around with a module
I've written for netfilter and I would like to modify options of
the IP and TCP headers. For example, right now I'm trying
to set the destination IP to the source IP, but the TCP checksum
is coming out incorrectly. How can I calculate this checksum?
Thanks a lot in advance. Also, if anyone knows where some
documentation about the TCP/IP stack in the kernel are, please
let me know.
Jeff Shipman - CCD
Sandia National Laboratories
(505) 844-1158 / MS-1372
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Accelerated Encryption Processing Ltd.
Bray Business Park,
Southern Cross Route ,
Bray, Co Wicklow,
Ireland
********************************************************************
This email and any files transmitted with it are confidential
and intended solely for the use of the individual or entity to
whom they are addressed. If you have received this email
in error please notify the postmaster at the address below.
This footnote also confirms that this email message has been
checked the presence of computer viruses.
**********************************************************************
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/