233,7 → 233,7 |
checksum = compact_checksum(compute_checksum( 0, data, length )); |
|
// flip, zero is returned as 0xFFFF (not flipped) |
return ( ~ checksum ) ? ~ checksum : IP_HEADER_CHECKSUM_ZERO; |
return ( ~ checksum ) ? ( uint16_t ) ( ~ checksum ) : IP_HEADER_CHECKSUM_ZERO; |
} |
|
int ip_initialize( async_client_conn_t client_connection ){ |
906,10 → 906,12 |
ip_header_ref last_header; |
uint8_t * src; |
uint8_t * dest; |
int address_length; |
size_t address_length; |
int result; |
|
address_length = packet_get_addr( packet, & src, & dest ); |
if( address_length <= 0 ) return EINVAL; |
result = packet_get_addr( packet, & src, & dest ); |
if( result <= 0 ) return EINVAL; |
address_length = ( size_t ) result; |
if( packet_get_data_length( packet ) <= sizeof( ip_header_t )) return ENOMEM; |
// get header |
header = ( ip_header_ref ) packet_get_data( packet ); |
994,7 → 996,7 |
next = sizeof( ip_header_t ); |
// process all ip options |
while( next < first->ihl ){ |
option = ( ip_option_ref ) ((( void * ) first ) + next ); |
option = ( ip_option_ref ) ((( uint8_t * ) first ) + next ); |
// skip end or noop |
if(( option->type == IPOPT_END ) || ( option->type == IPOPT_NOOP )){ |
++ next; |
1001,7 → 1003,7 |
}else{ |
// copy if said so or skip |
if( IPOPT_COPIED( option->type )){ |
memcpy((( void * ) last ) + length, (( void * ) first ) + next, option->length ); |
memcpy((( uint8_t * ) last ) + length, (( uint8_t * ) first ) + next, option->length ); |
length += option->length; |
} |
// next option |
1010,7 → 1012,7 |
} |
// align 4 byte boundary |
if( length % 4 ){ |
bzero((( void * ) last ) + length, 4 - ( length % 4 )); |
bzero((( uint8_t * ) last ) + length, 4 - ( length % 4 )); |
last->ihl = length / 4 + 1; |
}else{ |
last->ihl = length / 4; |