Hey,

you will have to extract the packet, set the checksum to zero, calculate the
checksum and put it in his place.
If you need a function for calculating a 16-bit checksum, here you go:


/* int CheckSum16
 *
 *      Helper function whitch calculates a 16 bit checksum of the data.
 */
int CheckSum16 (unsigned char* data, int length) {
    unsigned int sum = 0;
    unsigned short *s = (unsigned short *)data;

    while ( length > 0 ) {
       sum += *s;
       s++;
       length -= 2;
    }

    while ( sum > 0xffff ) {
        sum = ( sum & 0xffff ) + (sum >> 16 );
    }

    sum = ~sum & 0xffff;
        return sum;
}


-----Original Message-----
From: Sergej Kononov [mailto:[EMAIL PROTECTED]
Sent: dinsdag 4 maart 2003 16:11
To: [EMAIL PROTECTED]
Subject: [WinPcap-users] Checksum of a TCP packets


Hi winpcap-users.

Give me please a code of calculation of the control sum of a TCP
package, if i have a pointer to a package: u_char *pPacket;



==================================================================
 This is the WinPcap users list. It is archived at
 http://www.mail-archive.com/[EMAIL PROTECTED]/

 To unsubscribe use
 mailto: [EMAIL PROTECTED]
==================================================================





==================================================================
 This is the WinPcap users list. It is archived at
 http://www.mail-archive.com/[EMAIL PROTECTED]/

 To unsubscribe use 
 mailto: [EMAIL PROTECTED]
==================================================================

Reply via email to