Changeset 918e9910 in mainline


Ignore:
Timestamp:
2010-02-12T13:50:47Z (14 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
827d73f
Parents:
4be390b
Message:
  • zero IP checksum flip fix
Location:
uspace/srv/net
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/checksum.c

    r4be390b r918e9910  
    4646 */
    4747#define CRC_DIVIDER_LE  0xEDB88320
    48 
    49 /** IP checksum value for computed zero checksum.
    50  *  Zero is returned as 0xFFFF (not flipped)
    51  */
    52 #define IP_CHECKSUM_ZERO                        0xFFFFu
    5348
    5449uint32_t compute_crc32_le( uint32_t seed, uint8_t * data, size_t length ){
     
    135130uint16_t flip_checksum( uint16_t checksum ){
    136131        // flip, zero is returned as 0xFFFF (not flipped)
    137         return ( ~ checksum ) ? ( uint16_t ) ( ~ checksum ) : IP_CHECKSUM_ZERO;
     132        checksum = ~ checksum;
     133        return checksum ? checksum : IP_CHECKSUM_ZERO;
    138134}
    139135
  • uspace/srv/net/il/ip/ip.c

    r4be390b r918e9910  
    12041204        }
    12051205        // checksum
    1206         if(( header->header_checksum ) && ( IP_HEADER_CHECKSUM( header ))){
     1206        if(( header->header_checksum ) && ( IP_HEADER_CHECKSUM( header ) != IP_CHECKSUM_ZERO )){
    12071207                phone = ip_prepare_icmp_and_get_phone( 0, packet, header );
    12081208                if( phone >= 0 ){
  • uspace/srv/net/include/checksum.h

    r4be390b r918e9910  
    4141
    4242#include <sys/types.h>
     43
     44/** IP checksum value for computed zero checksum.
     45 *  Zero is returned as 0xFFFF (not flipped)
     46 */
     47#define IP_CHECKSUM_ZERO                        0xFFFFu
    4348
    4449/**     Computes CRC32 value.
  • uspace/srv/net/tl/icmp/icmp.c

    r4be390b r918e9910  
    617617        // checksum
    618618        if( header->checksum ){
    619                 while( ICMP_CHECKSUM( header, length )){
     619                while( ICMP_CHECKSUM( header, length ) != IP_CHECKSUM_ZERO ){
    620620                        // set the original message type on error notification
    621621                        // type swap observed in Qemu
  • uspace/srv/net/tl/tcp/tcp.c

    r4be390b r918e9910  
    382382                }
    383383                checksum = compute_checksum( checksum, socket_data->pseudo_header, socket_data->headerlen );
    384                 if( flip_checksum( compact_checksum( checksum ))){
     384                if( flip_checksum( compact_checksum( checksum )) != IP_CHECKSUM_ZERO ){
    385385                        printf( "checksum err %x -> %x\n", header->checksum, flip_checksum( compact_checksum( checksum )));
    386386                        fibril_rwlock_write_unlock( socket_data->local_lock );
  • uspace/srv/net/tl/udp/udp.c

    r4be390b r918e9910  
    372372        // check checksum
    373373        if( header->checksum ){
    374                 if( flip_checksum( compact_checksum( checksum ))){
     374                if( flip_checksum( compact_checksum( checksum )) != IP_CHECKSUM_ZERO ){
    375375                        if( tl_prepare_icmp_packet( udp_globals.net_phone, udp_globals.icmp_phone, packet, error ) == EOK ){
    376376                                // checksum error ICMP
Note: See TracChangeset for help on using the changeset viewer.