Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3846 → Rev 3845

/branches/network/uspace/srv/net/tcp/tcp_module.h
File deleted
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
/branches/network/uspace/srv/net/tcp/tcp.c
34,20 → 34,17
*/
 
#include <async.h>
#include <errno.h>
#include <stdio.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
//#include <sys/mman.h>
 
#include "../err.h"
#include "../messages.h"
#include "../modules.h"
#include "../packet.h"
 
#include "../ip/ip_messages.h"
 
#include "tcp.h"
#include "tcp_module.h"
 
tcp_globals_t tcp_globals;
 
56,26 → 53,23
int tcp_initialize( void ){
ERROR_DECLARE;
 
ipcarg_t arg1, arg2;
packet_t packet;
/* ipcarg_t arg1, arg2;
 
printf( "\nTCP - testing to send to IP:\t" );
ERROR_PROPAGATE( ip_echo( tcp_globals.ip_phone, 12, 34, 0, 0, 0, & arg1, & arg2, NULL, NULL, NULL ));
printf( "\nTCP - testing to send IP:\t" );
ERROR_PROPAGATE( ip_message( NET_IP_ECHO, 12, 34, NULL, & arg1, & arg2, NULL ));
if(( arg1 != 12 ) || ( arg2 != 34 )) return EINVAL;
printf( "OK\n" );
*/
ERROR_PROPAGATE( ip_message( NET_IP_TCP_REGISTER, SERVICE_TCP, NULL, NULL, NULL, NULL, NULL ));
return EOK;
}
 
printf( "\nTCP - testing to send packet to IP:\t" );
packet = packet_create( 20, 30, 20 );
if( ! packet ) return ENOMEM;
packet_copy_data( packet, "Hi, this is TCP", 16 );
ERROR_PROPAGATE( ip_send( tcp_globals.ip_phone, -1, packet ));
printf( "\tOK\n" );
int tcp_call( ipc_callid_t callid ){
return EOK;
}
 
int tcp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
* answer_count = 0;
switch( IPC_GET_METHOD( * call )){
int tcp_message( ipc_callid_t callid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){
switch( method ){
case IPC_M_PHONE_HUNGUP:
return EOK;
}
/branches/network/uspace/srv/net/tcp/tcp.h
34,9 → 34,19
* @file
*/
 
#ifndef __NET_TCP_H__
#define __NET_TCP_H__
#ifndef __NET_TCP_INTERNALS_H__
#define __NET_TCP_INTERNALS_H__
 
#ifdef NETWORKING_modular
#define ip_message( ... ) ipc_call_sync_3_3( tcp_globals.ip_phone, __VA_ARGS__ )
#else
#ifdef NETWORKING_module
 
#include "../ip/ip.h"
 
#endif
#endif
 
typedef struct tcp_globals tcp_globals_t;
 
struct tcp_globals{
44,6 → 54,10
int networking_phone;
};
 
int tcp_initialize( void );
int tcp_call( ipc_callid_t callid );
int tcp_message( ipc_callid_t callid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 );
 
#endif
 
/** @}
/branches/network/uspace/srv/net/tcp/tcp_module.c
35,22 → 35,17
 
#include <async.h>
#include <stdio.h>
 
#include <ipc/ipc.h>
#include <ipc/services.h>
 
#include "../err.h"
#include "../modules.h"
 
#include "../include/protocols.h"
 
#include "tcp.h"
#include "tcp_module.h"
 
#define NAME "TCP protocol"
 
void tcp_print_name( void );
int tcp_start_module( async_client_conn_t client_connection );
int tcp_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall ));
 
extern tcp_globals_t tcp_globals;
 
58,20 → 53,17
printf( NAME );
}
 
int tcp_start_module( async_client_conn_t client_connection ){
ERROR_DECLARE;
int tcp_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall )){
services_t need[ 3 ];
int * need_phone[ 3 ];
 
ipcarg_t phonehash;
 
async_set_client_connection( client_connection );
tcp_globals.networking_phone = connect_to_service( SERVICE_NETWORKING );
tcp_globals.ip_phone = bind_service( SERVICE_IP, IPPROTO_TCP, 0, 0, client_connection );
ERROR_PROPAGATE( tcp_initialize());
ERROR_PROPAGATE( REGISTER_ME( SERVICE_TCP, & phonehash ));
 
async_manager();
 
return EOK;
need[ 0 ] = SERVICE_IP;
need[ 1 ] = SERVICE_NETWORKING;
need[ 2 ] = NULL;
need_phone[ 0 ] = & tcp_globals.ip_phone;
need_phone[ 1 ] = & tcp_globals.networking_phone;
need_phone[ 2 ] = NULL;
return start_service( SERVICE_TCP, need, need_phone, client_connection, tcp_initialize );
}
 
/** @}
/branches/network/uspace/srv/net/tcp/Makefile
45,10 → 45,9
$(NAME)_module.c \
$(NAME).c \
../module.c \
../modules.c \
../packet.c
../modules.c
 
DEFS += -D TCP_BUNDLE=1 -D $(NAME)_message=module_message -D $(NAME)_start_module=module_start -D $(NAME)_print_name=module_print_name
DEFS += -D NETWORKING_$(NETWORKING) -D $(NAME)_call=module_call -D $(NAME)_message=module_message -D $(NAME)_start_module=module_start -D $(NAME)_print_name=module_print_name
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))