Subversion Repositories HelenOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 3845 → Rev 3846

/branches/network/uspace/srv/net/tcp/tcp_module.h
0,0 → 1,48
/*
* Copyright (c) 2008 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
*/
 
/**
* @file
*/
 
#ifndef __NET_TCP_MODULE_H__
#define __NET_TCP_MODULE_H__
 
#include <ipc/ipc.h>
 
int tcp_initialize( void );
int tcp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
 
#endif
 
/** @}
*/
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/branches/network/uspace/srv/net/tcp/tcp.c
34,17 → 34,20
*/
 
#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;
 
53,23 → 56,26
int tcp_initialize( void ){
ERROR_DECLARE;
 
/* ipcarg_t arg1, arg2;
ipcarg_t arg1, arg2;
packet_t packet;
 
printf( "\nTCP - testing to send IP:\t" );
ERROR_PROPAGATE( ip_message( NET_IP_ECHO, 12, 34, NULL, & arg1, & arg2, NULL ));
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 ));
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;
}
 
int tcp_call( ipc_callid_t callid ){
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" );
return EOK;
}
 
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 ){
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 )){
case IPC_M_PHONE_HUNGUP:
return EOK;
}
/branches/network/uspace/srv/net/tcp/tcp.h
34,19 → 34,9
* @file
*/
 
#ifndef __NET_TCP_INTERNALS_H__
#define __NET_TCP_INTERNALS_H__
#ifndef __NET_TCP_H__
#define __NET_TCP_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{
54,10 → 44,6
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,17 → 35,22
 
#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( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall ));
int tcp_start_module( async_client_conn_t client_connection );
 
extern tcp_globals_t tcp_globals;
 
53,17 → 58,20
printf( NAME );
}
 
int tcp_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall )){
services_t need[ 3 ];
int * need_phone[ 3 ];
int tcp_start_module( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
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 );
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;
}
 
/** @}
/branches/network/uspace/srv/net/tcp/Makefile
45,9 → 45,10
$(NAME)_module.c \
$(NAME).c \
../module.c \
../modules.c
../modules.c \
../packet.c
 
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
DEFS += -D TCP_BUNDLE=1 -D $(NAME)_message=module_message -D $(NAME)_start_module=module_start -D $(NAME)_print_name=module_print_name
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))