Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4749 → Rev 4750

/branches/network/uspace/srv/net/tl/tcp/tcp.c
172,7 → 172,6
*/
int tcp_release_and_return( packet_t packet, int result );
 
int tcp_get_packet_dimension( device_id_t device_id, packet_dimension_ref * packet_dimension );
void tcp_prepare_operation_header( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, int synchronize, int finalize );
int tcp_prepare_timeout( int ( * timeout_function )( void * tcp_timeout_t ), socket_core_ref socket, tcp_socket_data_ref socket_data, size_t sequence_number, tcp_socket_state_t state, suseconds_t timeout, int globals_read_only );
void tcp_free_socket_data( socket_core_ref socket );
206,8 → 205,6
int tcp_accept_message( socket_cores_ref local_sockets, int socket_id, size_t * addrlen );
int tcp_close_message( socket_cores_ref local_sockets, int socket_id );
 
DEVICE_MAP_IMPLEMENT( packet_dimensions, packet_dimension_t );
 
/** TCP global data.
*/
tcp_globals_t tcp_globals;
1632,29 → 1629,6
}
}
 
int tcp_get_packet_dimension( device_id_t device_id, packet_dimension_ref * packet_dimension ){
ERROR_DECLARE;
 
assert( packet_dimension );
 
* packet_dimension = packet_dimensions_find( & tcp_globals.dimensions, device_id );
if( ! * packet_dimension ){
// ask for and remember them if not found
* packet_dimension = malloc( sizeof( ** packet_dimension ));
if( ! * packet_dimension ) return ENOMEM;
if( ERROR_OCCURRED( ip_packet_size_req( tcp_globals.ip_phone, device_id, & ( ** packet_dimension ).addr_len, & ( ** packet_dimension ).prefix, & ( ** packet_dimension ).content, & ( ** packet_dimension ).suffix ))){
free( * packet_dimension );
return ERROR_CODE;
}
ERROR_CODE = packet_dimensions_add( & tcp_globals.dimensions, device_id, * packet_dimension );
if( ERROR_CODE < 0 ){
free( * packet_dimension );
return ERROR_CODE;
}
}
return EOK;
}
 
void tcp_prepare_operation_header( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, int synchronize, int finalize ){
assert( socket );
assert( socket_data );
1778,7 → 1752,7
return ENOTCONN;
}
 
ERROR_PROPAGATE( tcp_get_packet_dimension( socket_data->device_id, & packet_dimension ));
ERROR_PROPAGATE( tl_get_ip_packet_dimension( tcp_globals.ip_phone, & tcp_globals.dimensions, socket_data->device_id, & packet_dimension ));
 
// TODO return the device_id + data_fragment_size if different - the client should send it again
// ( two messages are better than ip fragmentation )
1869,7 → 1843,7
assert( packet );
 
// get the device packet dimension
ERROR_PROPAGATE( tcp_get_packet_dimension( socket_data->device_id, & packet_dimension ));
ERROR_PROPAGATE( tl_get_ip_packet_dimension( tcp_globals.ip_phone, & tcp_globals.dimensions, socket_data->device_id, & packet_dimension ));
// get a new packet
* packet = packet_get_4( tcp_globals.net_phone, sizeof( tcp_header_t ), packet_dimension->addr_len, packet_dimension->prefix, packet_dimension->suffix );
if( ! * packet ) return ENOMEM;