Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4706 → Rev 4707

/branches/network/uspace/srv/net/tl/tcp/tcp.c
54,35 → 54,42
#include "tcp.h"
#include "tcp_module.h"
 
/** Free ports pool start.
*/
#define TCP_FREE_PORTS_START 1025
 
/** Free ports pool end.
*/
#define TCP_FREE_PORTS_END 65535
 
/** TCP global data.
*/
tcp_globals_t tcp_globals;
 
int tcp_received_msg( device_id_t device_id, packet_t packet, services_t receiver );
int tcp_received_msg( device_id_t device_id, packet_t packet, services_t receiver, services_t error );
 
/** Initializes the module.
*/
int tcp_initialize( async_client_conn_t client_connection ){
// ERROR_DECLARE;
ERROR_DECLARE;
 
// ipcarg_t arg1, arg2;
// packet_t packet;
 
/* printf( "TCP - testing to send to IP:\n" );
ERROR_PROPAGATE( ip_echo( tcp_globals.ip_phone, 12, 34, 0, 0, 0, & arg1, & arg2, NULL, NULL, NULL ));
if(( arg1 != 12 ) || ( arg2 != 34 )) return EINVAL;
printf( "OK\n" );
*/
fibril_rwlock_initialize( & tcp_globals.lock );
fibril_rwlock_write_lock( & tcp_globals.lock );
tcp_globals.icmp_phone = icmp_connect_module( SERVICE_ICMP );
if( tcp_globals.icmp_phone < 0 ){
return tcp_globals.icmp_phone;
}
tcp_globals.ip_phone = ip_bind_service( SERVICE_IP, IPPROTO_TCP, SERVICE_TCP, client_connection, tcp_received_msg );
/* printf( "TCP - testing to send packet to IP:\n" );
packet = packet_get_4( tcp_globals.net_phone, 6, 20, 30, 20 );
if( ! packet ) return ENOMEM;
packet_copy_data( packet, "Hi, this is TCP", 16 );
ip_send_msg( tcp_globals.ip_phone, -1, packet, SERVICE_TCP );
printf( "OK\n" );
*/ return EOK;
if( tcp_globals.ip_phone < 0 ){
return tcp_globals.ip_phone;
}
ERROR_PROPAGATE( socket_ports_initialize( & tcp_globals.sockets ));
tcp_globals.last_used_port = TCP_FREE_PORTS_START - 1;
fibril_rwlock_write_unlock( & tcp_globals.lock );
return EOK;
}
 
int tcp_received_msg( device_id_t device_id, packet_t packet, services_t receiver ){
int tcp_received_msg( device_id_t device_id, packet_t packet, services_t receiver, services_t error ){
// TODO received
// TODO remove debug dump:
uint8_t * data;
104,7 → 111,7
return EOK;
case NET_TL_RECEIVED:
ERROR_PROPAGATE( packet_translate( tcp_globals.net_phone, & packet, IPC_GET_PACKET( call )));
return tcp_received_msg( IPC_GET_DEVICE( call ), packet, 0 );
return tcp_received_msg( IPC_GET_DEVICE( call ), packet, SERVICE_TCP, IPC_GET_ERROR( call ));
}
return ENOTSUP;
}