Rev 4731 | Rev 4743 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4731 | Rev 4735 | ||
---|---|---|---|
Line 491... | Line 491... | ||
491 | fibril_rwlock_read_lock( & ip_globals.netifs_lock ); |
491 | fibril_rwlock_read_lock( & ip_globals.netifs_lock ); |
492 | // device specified? |
492 | // device specified? |
493 | if( device_id > 0 ){ |
493 | if( device_id > 0 ){ |
494 | netif = ip_netifs_find( & ip_globals.netifs, device_id ); |
494 | netif = ip_netifs_find( & ip_globals.netifs, device_id ); |
495 | route = ip_netif_find_route( netif, * dest ); |
495 | route = ip_netif_find_route( netif, * dest ); |
- | 496 | if( netif && ( ! route ) && ( ip_globals.gateway.netif == netif )){ |
|
- | 497 | route = & ip_globals.gateway; |
|
- | 498 | } |
|
496 | }else{ |
499 | }else{ |
497 | route = ip_find_route( * dest ); |
500 | route = ip_find_route( * dest ); |
498 | netif = route ? route->netif : NULL; |
501 | netif = route ? route->netif : NULL; |
499 | } |
502 | } |
500 | if( !( netif && route )){ |
503 | if( !( netif && route )){ |
Line 695... | Line 698... | ||
695 | return ip_set_gateway_req( 0, IPC_GET_DEVICE( call ), IP_GET_GATEWAY( call )); |
698 | return ip_set_gateway_req( 0, IPC_GET_DEVICE( call ), IP_GET_GATEWAY( call )); |
696 | case NET_IP_GET_ROUTE: |
699 | case NET_IP_GET_ROUTE: |
697 | ERROR_PROPAGATE( data_receive(( void ** ) & addr, & addrlen )); |
700 | ERROR_PROPAGATE( data_receive(( void ** ) & addr, & addrlen )); |
698 | ERROR_PROPAGATE( ip_get_route_req( 0, IP_GET_PROTOCOL( call ), addr, ( socklen_t ) addrlen, IPC_SET_DEVICE( answer ), & header, & headerlen )); |
701 | ERROR_PROPAGATE( ip_get_route_req( 0, IP_GET_PROTOCOL( call ), addr, ( socklen_t ) addrlen, IPC_SET_DEVICE( answer ), & header, & headerlen )); |
699 | * IP_SET_HEADERLEN( answer ) = headerlen; |
702 | * IP_SET_HEADERLEN( answer ) = headerlen; |
- | 703 | * answer_count = 2; |
|
700 | if( ! ERROR_OCCURRED( data_reply( & headerlen, sizeof( headerlen )))){ |
704 | if( ! ERROR_OCCURRED( data_reply( & headerlen, sizeof( headerlen )))){ |
701 | ERROR_CODE = data_reply( header, headerlen ); |
705 | ERROR_CODE = data_reply( header, headerlen ); |
702 | } |
706 | } |
703 | free( header ); |
707 | free( header ); |
704 | return ERROR_CODE; |
708 | return ERROR_CODE; |
Line 935... | Line 939... | ||
935 | memcpy( data, (( void * ) header ) + IP_TOTAL_LENGTH( header ) - length, length ); |
939 | memcpy( data, (( void * ) header ) + IP_TOTAL_LENGTH( header ) - length, length ); |
936 | ERROR_PROPAGATE( packet_trim( packet, 0, length )); |
940 | ERROR_PROPAGATE( packet_trim( packet, 0, length )); |
937 | header->total_length = htons( IP_TOTAL_LENGTH( header ) - length ); |
941 | header->total_length = htons( IP_TOTAL_LENGTH( header ) - length ); |
938 | new_header->total_length = htons( IP_HEADER_LENGTH( new_header ) + length ); |
942 | new_header->total_length = htons( IP_HEADER_LENGTH( new_header ) + length ); |
939 | offset = IP_FRAGMENT_OFFSET( header ) + IP_HEADER_DATA_LENGTH( header ); |
943 | offset = IP_FRAGMENT_OFFSET( header ) + IP_HEADER_DATA_LENGTH( header ); |
940 | printf( "offset %d = %d + %d\n", offset, IP_FRAGMENT_OFFSET( header ), IP_HEADER_DATA_LENGTH( header )); |
- | |
941 | new_header->fragment_offset_high = IP_COMPUTE_FRAGMENT_OFFSET_HIGH( offset ); |
944 | new_header->fragment_offset_high = IP_COMPUTE_FRAGMENT_OFFSET_HIGH( offset ); |
942 | new_header->fragment_offset_low = IP_COMPUTE_FRAGMENT_OFFSET_LOW( offset ); |
945 | new_header->fragment_offset_low = IP_COMPUTE_FRAGMENT_OFFSET_LOW( offset ); |
943 | new_header->header_checksum = IP_HEADER_CHECKSUM( new_header ); |
946 | new_header->header_checksum = IP_HEADER_CHECKSUM( new_header ); |
944 | ERROR_PROPAGATE( packet_set_addr( new_packet, ( const uint8_t * ) src, ( const uint8_t * ) dest, addrlen )); |
947 | ERROR_PROPAGATE( packet_set_addr( new_packet, ( const uint8_t * ) src, ( const uint8_t * ) dest, addrlen )); |
945 | return pq_insert_after( packet, new_packet ); |
948 | return pq_insert_after( packet, new_packet ); |
Line 1164... | Line 1167... | ||
1164 | memcpy( & dest_in6.sin6_addr.s6_addr, ); |
1167 | memcpy( & dest_in6.sin6_addr.s6_addr, ); |
1165 | src = ( struct sockaddr * ) & src_in; |
1168 | src = ( struct sockaddr * ) & src_in; |
1166 | dest = ( struct sockaddr * ) & dest_in; |
1169 | dest = ( struct sockaddr * ) & dest_in; |
1167 | break; |
1170 | break; |
1168 | */ default: |
1171 | */ default: |
1169 | return EAFNOSUPPORT; |
1172 | return ip_release_and_return( packet, EAFNOSUPPORT ); |
- | 1173 | } |
|
- | 1174 | if( ERROR_OCCURRED( packet_set_addr( packet, ( uint8_t * ) src, ( uint8_t * ) dest, addrlen ))){ |
|
- | 1175 | return ip_release_and_return( packet, ERROR_CODE ); |
|
- | 1176 | } |
|
- | 1177 | // trim padding if present |
|
- | 1178 | if(( ! error ) && ( IP_TOTAL_LENGTH( header ) < packet_get_data_length( packet ))){ |
|
- | 1179 | if( ERROR_OCCURRED( packet_trim( packet, 0, packet_get_data_length( packet ) - IP_TOTAL_LENGTH( header )))){ |
|
- | 1180 | return ip_release_and_return( packet, ERROR_CODE ); |
|
- | 1181 | } |
|
1170 | } |
1182 | } |
1171 | ERROR_PROPAGATE( packet_set_addr( packet, ( uint8_t * ) src, ( uint8_t * ) dest, addrlen )); |
- | |
1172 | fibril_rwlock_read_lock( & ip_globals.protos_lock ); |
1183 | fibril_rwlock_read_lock( & ip_globals.protos_lock ); |
1173 | proto = ip_protos_find( & ip_globals.protos, header->protocol ); |
1184 | proto = ip_protos_find( & ip_globals.protos, header->protocol ); |
1174 | if( ! proto ){ |
1185 | if( ! proto ){ |
1175 | fibril_rwlock_read_unlock( & ip_globals.protos_lock ); |
1186 | fibril_rwlock_read_unlock( & ip_globals.protos_lock ); |
1176 | phone = ip_prepare_icmp_and_get_phone( error, packet, header ); |
1187 | phone = ip_prepare_icmp_and_get_phone( error, packet, header ); |