34,61 → 34,35 |
*/ |
|
#include <async.h> |
#include <errno.h> |
#include <stdio.h> |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
//#include <sys/mman.h> |
|
#include "../modules.h" |
|
#include "tcp.h" |
|
extern struct { |
int ip_phone; |
} tcp_globals; |
#define NAME "TCP protocol" |
|
static void client_connection( ipc_callid_t iid, ipc_call_t * icall ); |
int main( int argc, char * argv[] ); |
void tcp_print_name( void ); |
int tcp_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall )); |
|
/** Default thread for new connections. |
*/ |
static void client_connection( ipc_callid_t iid, ipc_call_t * icall ){ |
ipc_callid_t callid; |
ipc_call_t call; |
ipcarg_t arg1, arg2, arg3; |
int res; |
extern tcp_globals_t tcp_globals; |
|
/* Accept the connection */ |
ipc_answer_0( iid, EOK ); |
|
while( true ){ |
callid = async_get_call( & call ); |
arg1 = 0; |
arg2 = 0; |
arg3 = 0; |
res = tcp_call( callid ); |
if( res == EOK ){ |
res = tcp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 ); |
} |
ipc_answer_2( callid, EOK, arg1, arg2 ); |
} |
void tcp_print_name( void ){ |
printf( NAME ); |
} |
|
/** Starts the module. |
* Parameters are ignored. |
*/ |
int main( int argc, char * argv[] ){ |
services_t need[ 2 ]; |
int * need_phone[ 2 ]; |
int tcp_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall )){ |
services_t need[ 3 ]; |
int * need_phone[ 3 ]; |
|
printf("tcp : HelenOS TCP network protocol\n"); |
|
need[ 0 ] = SERVICE_IP; |
need[ 1 ] = NULL; |
need[ 1 ] = SERVICE_NETWORKING; |
need[ 2 ] = NULL; |
need_phone[ 0 ] = & tcp_globals.ip_phone; |
need_phone[ 1 ] = NULL; |
|
need_phone[ 1 ] = & tcp_globals.networking_phone; |
need_phone[ 2 ] = NULL; |
return start_service( SERVICE_TCP, need, need_phone, client_connection, tcp_initialize ); |
} |
|