Changeset 918e9910 in mainline
- Timestamp:
- 2010-02-12T13:50:47Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 827d73f
- Parents:
- 4be390b
- Location:
- uspace/srv/net
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/checksum.c
r4be390b r918e9910 46 46 */ 47 47 #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 0xFFFFu53 48 54 49 uint32_t compute_crc32_le( uint32_t seed, uint8_t * data, size_t length ){ … … 135 130 uint16_t flip_checksum( uint16_t checksum ){ 136 131 // 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; 138 134 } 139 135 -
uspace/srv/net/il/ip/ip.c
r4be390b r918e9910 1204 1204 } 1205 1205 // checksum 1206 if(( header->header_checksum ) && ( IP_HEADER_CHECKSUM( header ) )){1206 if(( header->header_checksum ) && ( IP_HEADER_CHECKSUM( header ) != IP_CHECKSUM_ZERO )){ 1207 1207 phone = ip_prepare_icmp_and_get_phone( 0, packet, header ); 1208 1208 if( phone >= 0 ){ -
uspace/srv/net/include/checksum.h
r4be390b r918e9910 41 41 42 42 #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 43 48 44 49 /** Computes CRC32 value. -
uspace/srv/net/tl/icmp/icmp.c
r4be390b r918e9910 617 617 // checksum 618 618 if( header->checksum ){ 619 while( ICMP_CHECKSUM( header, length ) ){619 while( ICMP_CHECKSUM( header, length ) != IP_CHECKSUM_ZERO ){ 620 620 // set the original message type on error notification 621 621 // type swap observed in Qemu -
uspace/srv/net/tl/tcp/tcp.c
r4be390b r918e9910 382 382 } 383 383 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 ){ 385 385 printf( "checksum err %x -> %x\n", header->checksum, flip_checksum( compact_checksum( checksum ))); 386 386 fibril_rwlock_write_unlock( socket_data->local_lock ); -
uspace/srv/net/tl/udp/udp.c
r4be390b r918e9910 372 372 // check checksum 373 373 if( header->checksum ){ 374 if( flip_checksum( compact_checksum( checksum )) ){374 if( flip_checksum( compact_checksum( checksum )) != IP_CHECKSUM_ZERO ){ 375 375 if( tl_prepare_icmp_packet( udp_globals.net_phone, udp_globals.icmp_phone, packet, error ) == EOK ){ 376 376 // checksum error ICMP
Note:
See TracChangeset
for help on using the changeset viewer.