RE: TCP checksum?

From: Shipman, Jeffrey E (jeshipm@sandia.gov)
Date: Thu Jun 13 2002 - 14:58:44 EST


Thanks John, that function works great. However, I'm still having problems
where I'm not getting any responses from the destination. I've been setting
the destination address to the source address (this is just to play around
and learn things), and it's not working properly. If I connect straight to
the address (192.168.1.20), it works great. However, if I connect to
192.168.1.1, it looks like in the packet it's using 192.168.1.20, but all
I get no SYN/ACK back...my machine just keeps on sending out SYNs. Does
anyone know of things I need to also check in order to make sure this will
work. When I finish my module, it will be modifying all sorts of fields
inside of the TCP packet and I'd like to be sure that I can get responses
from remote machines.

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.

postmaster@aep.ie

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/



This archive was generated by hypermail 2b29 : Sat Jun 15 2002 - 22:00:29 EST