/branches/network/uspace/srv/net/sockaddr.c |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/include/ethernet_protocols.h |
---|
File deleted |
Property changes: |
Deleted: svn:mergeinfo |
/branches/network/uspace/srv/net/include/protocols.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/include/socket.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/include/sockaddr.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/include/hardware.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/include/protocol_map.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/include/byteorder.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/packet_queue.c |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/packet_queue.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/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))) |
/branches/network/uspace/srv/net/networking/networking.c |
---|
39,10 → 39,11 |
#include <malloc.h> |
#include <stdio.h> |
#include <task.h> |
//#include <thread.h> |
#include <unistd.h> |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
//#include <sys/mman.h> |
#include "../char_map.h" |
#include "../err.h" |
52,21 → 53,15 |
#include "../modules.h" |
//#include "../self_test.h" |
#include "../ip/ip_messages.h" |
#include "../netif/device.h" |
#include "../netif/netif_device_id_type.h" |
#if IP_BUNDLE |
#ifdef NETWORKING_module |
#include "../ip/ip_module.h" |
#include "../ip/ip.h" |
#include "../tcp/tcp.h" |
#endif |
#if TCP_BUNDLE |
#include "../tcp/tcp_module.h" |
#endif |
#define LO_NAME "lo" |
#define LO_FILENAME "/sbin/lo" |
#define DP8390_ISA_NAME "dp8390_isa" |
104,16 → 99,16 |
struct netif{ |
/** A system-unique network interface identifier. |
*/ |
device_id_t id; |
netif_device_id_t id; |
/** A serving network interface driver module index. |
*/ |
module_ref driver; |
module_ref driver_module; |
/** A serving link layer module index. |
*/ |
module_ref nil; |
module_ref link_layer_module; |
/** A serving internet layer module index. |
*/ |
module_ref il; |
module_ref internet_layer_module; |
/** A system-unique network interface name. |
*/ |
char * name; |
143,6 → 138,7 |
static void client_connection( ipc_callid_t iid, ipc_call_t * icall ); |
measured_string_ref configuration_find( measured_strings_ref configuration, const char * name ); |
int main( int argc, char * argv[] ); |
int networking_call( ipc_callid_t callid ); |
int networking_initialize( void ); |
int networking_message( ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ); |
//int parse_line( measured_strings_ref configuration, char * line ); |
150,7 → 146,7 |
int read_configuration( void ); |
task_id_t spawn( const char * fname ); |
int startup( void ); |
device_id_t generate_new_device_id( void ); |
netif_device_id_t generate_new_device_id( void ); |
static networking_globals_t networking_globals; |
173,7 → 169,7 |
tmp_module->name = name; |
tmp_module->filename = filename; |
tmp_module->service = service; |
if( ERROR_OCCURED( modules_add( modules, tmp_module->name, 0, tmp_module ))){ |
if( ERROR_OCCURED( modules_add( modules, tmp_module->name, tmp_module ))){ |
free( tmp_module ); |
return ERROR_CODE; |
} |
187,10 → 183,7 |
ipcarg_t arg1, arg2, arg3; |
int res; |
/* |
* Accept the connection |
* - Answer the first IPC_M_CONNECT_ME_TO call. |
*/ |
/* Accept the connection */ |
// printf( "\nNET-%d got %d on %x from %x", fibril_get_id(), IPC_GET_METHOD( * icall ), icall->in_phone_hash, iid ); |
ipc_answer_0( iid, EOK ); |
202,24 → 195,51 |
// printf( "\nNET-%d got %d on %x from %x", fibril_get_id(), IPC_GET_METHOD( call ), call.in_phone_hash, callid ); |
#ifdef NETWORKING_module |
if( IS_NET_IL_MESSAGE( call ) || IS_NET_IP_MESSAGE( call )){ |
res = ip_call( callid ); |
if( res == EOK ){ |
res = ip_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 ); |
} |
/* }else if( IS_NET_ARP_MESSAGE( call )){ |
res = arp_call( callid ); |
if( res == EOK ){ |
res = arp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 ); |
} |
*//* }else if( IS_NET_RARP_MESSAGE( call )){ |
res = rarp_call( callid ); |
if( res == EOK ){ |
res = rarp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 ); |
} |
*//* }else if( IS_NET_ICMP_MESSAGE( call )){ |
res = icmp_call( callid ); |
if( res == EOK ){ |
res = icmp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 ); |
} |
*//* }else if( IS_NET_UDP_MESSAGE( call )){ |
res = udp_call( callid ); |
if( res == EOK ){ |
res = udp_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 ); |
} |
*/ }else if( IS_NET_TCP_MESSAGE( call )){ |
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 ); |
} |
/* }else if( IS_NET_SOCKET_MESSAGE( call )){ |
res = socket_call( callid ); |
if( res == EOK ){ |
res = socket_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 ); |
*//* }else if( IS_NET_NIL_MESSAGE( call ) || IS_NET_ETHERNET_MESSAGE( call )){ |
} |
*//* }else if( IS_NET_LL_MESSAGE( call ) || IS_NET_ETHERNET_MESSAGE( call )){ |
res = ethernet_call( callid ); |
if( res == EOK ){ |
res = ethernet_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 ); |
} |
*/ }else{ |
#endif |
res = networking_call( callid ); |
if( res == EOK ){ |
res = networking_message( IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 ); |
} |
#ifdef NETWORKING_module |
} |
#endif |
228,18 → 248,13 |
} |
int main( int argc, char * argv[] ){ |
ERROR_DECLARE; |
ipcarg_t phonehash; |
printf("\nTask %d - HelenOS Networking subsystem", task_get_id()); |
async_set_client_connection( client_connection ); |
ERROR_PROPAGATE( networking_initialize()); |
ERROR_PROPAGATE( REGISTER_ME( SERVICE_NETWORKING, & phonehash )); |
return start_service( SERVICE_NETWORKING, NULL, NULL, client_connection, networking_initialize ); |
} |
async_manager(); |
int networking_call( ipc_callid_t callid ){ |
return EOK; |
} |
312,12 → 327,12 |
switch( method ){ |
case IPC_M_PHONE_HUNGUP: |
return EOK; |
case NET_NET_DEVICE: |
case NET_NETWORKING_DEVICE: |
// TODO configure, register |
// arg1 = netif id |
printf( "\nNetworking: new netif %d", arg1 ); |
return EOK; |
case NET_NET_GET_DEVICE_CONF: |
case NET_NETWORKING_GET_DEVICE_CONFIGURATION: |
// arg1 = netif id |
// arg2 = count |
ERROR_PROPAGATE( measured_strings_receive( & strings, & data, arg2 )); |
328,9 → 343,9 |
configuration = NULL; |
} |
for( index = 0; index < arg2; ++ index ){ |
setting = measured_strings_find( configuration, strings[ index ].value, 0 ); |
setting = measured_strings_find( configuration, strings[ index ].value ); |
if( ! setting ){ |
setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value, 0 ); |
setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value ); |
} |
if( setting ){ |
strings[ index ].length = setting->length; |
345,11 → 360,11 |
ERROR_CODE = measured_strings_reply( strings, arg2 ); |
free( strings ); |
return ERROR_CODE; |
case NET_NET_GET_CONF: |
case NET_NETWORKING_GET_CONFIGURATION: |
// arg1 = count |
ERROR_PROPAGATE( measured_strings_receive( & strings, & data, arg1 )); |
for( index = 0; index < arg1; ++ index ){ |
setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value, 0 ); |
setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value ); |
if( setting ){ |
strings[ index ].length = setting->length; |
strings[ index ].value = setting->value; |
363,7 → 378,7 |
ERROR_CODE = measured_strings_reply( strings, arg1 ); |
free( strings ); |
return ERROR_CODE; |
case NET_NET_STARTUP: |
case NET_NETWORKING_STARTUP: |
return startup(); |
} |
return ENOTSUP; |
408,7 → 423,7 |
setting = measured_string_create_bulk( value, -1 ); |
if( ! setting ) return ENOMEM; |
// add the configuration setting |
if( ERROR_OCCURED( measured_strings_add( configuration, name, 0, setting ))){ |
if( ERROR_OCCURED( measured_strings_add( configuration, name, setting ))){ |
free( setting ); |
return ERROR_CODE; |
} |
424,7 → 439,7 |
setting = measured_string_create_bulk( value, 0 ); |
if( ! setting ) return ENOMEM; |
// add the configuration setting |
if( ERROR_OCCURED( measured_strings_add( configuration, name, 0, setting ))){ |
if( ERROR_OCCURED( measured_strings_add( configuration, name, setting ))){ |
free( setting ); |
return ERROR_CODE; |
} |
431,7 → 446,7 |
return EOK; |
} |
device_id_t generate_new_device_id( void ){ |
netif_device_id_t generate_new_device_id( void ){ |
return netifs_count( & networking_globals.netifs ) + 1; |
} |
467,7 → 482,7 |
} |
// mandatory name |
// printf( "\n\tname" ); |
setting = measured_strings_find( & netif->configuration, "NAME", 0 ); |
setting = measured_strings_find( & netif->configuration, "NAME" ); |
if( ! setting ){ |
measured_strings_destroy( & netif->configuration ); |
free( netif ); |
477,7 → 492,7 |
// printf( " %s OK", netif->name ); |
// mandatory netif |
// printf( "\n\tnetif" ); |
setting = measured_strings_find( & netif->configuration, "NETIF", 0 ); |
setting = measured_strings_find( & netif->configuration, "NETIF" ); |
if( ! setting ){ |
// printf( " unknown" ); |
measured_strings_destroy( & netif->configuration ); |
485,8 → 500,8 |
return EINVAL; |
} |
// printf( " find %s in %d?", setting->value, modules_count( & networking_globals.modules )); |
netif->driver = modules_find( & networking_globals.modules, setting->value, 0 ); |
if( ! netif->driver ){ |
netif->driver_module = modules_find( & networking_globals.modules, setting->value ); |
if( ! netif->driver_module ){ |
// printf( " not found" ); |
// TODO register the unknown one |
measured_strings_destroy( & netif->configuration ); |
494,9 → 509,9 |
return EINVAL; |
} |
// printf( " found" ); |
if( ! netif->driver->task_id ){ |
netif->driver->task_id = spawn( netif->driver->filename ); |
if( ! netif->driver->task_id ){ |
if( ! netif->driver_module->task_id ){ |
netif->driver_module->task_id = spawn( netif->driver_module->filename ); |
if( ! netif->driver_module->task_id ){ |
measured_strings_destroy( & netif->configuration ); |
free( netif ); |
return EINVAL; |
505,20 → 520,20 |
// printf( " OK" ); |
// optional link layer |
// printf( "\n\tlink layer" ); |
setting = measured_strings_find( & netif->configuration, "NIL", 0 ); |
setting = measured_strings_find( & netif->configuration, "LL" ); |
if( setting ){ |
netif->nil = modules_find( & networking_globals.modules, setting->value, 0 ); |
if( ! netif->nil ){ |
netif->link_layer_module = modules_find( & networking_globals.modules, setting->value ); |
if( ! netif->link_layer_module ){ |
// TODO register the unknown one |
-- netif->driver->usage; |
-- netif->driver_module->usage; |
measured_strings_destroy( & netif->configuration ); |
free( netif ); |
return EINVAL; |
} |
if( ! netif->nil->task_id ){ |
netif->nil->task_id = spawn( netif->nil->filename ); |
if( ! netif->nil->task_id ){ |
-- netif->driver->usage; |
if( ! netif->link_layer_module->task_id ){ |
netif->link_layer_module->task_id = spawn( netif->link_layer_module->filename ); |
if( ! netif->link_layer_module->task_id ){ |
-- netif->driver_module->usage; |
measured_strings_destroy( & netif->configuration ); |
free( netif ); |
return EINVAL; |
525,34 → 540,34 |
} |
} |
}else{ |
netif->nil = NULL; |
netif->link_layer_module = NULL; |
} |
// mandatory internet layer |
// printf( "\n\tinternet layer" ); |
setting = measured_strings_find( & netif->configuration, "IL", 0 ); |
setting = measured_strings_find( & netif->configuration, "IL" ); |
if( ! setting ){ |
-- netif->driver->usage; |
-- netif->nil->usage; |
-- netif->driver_module->usage; |
-- netif->link_layer_module->usage; |
measured_strings_destroy( & netif->configuration ); |
free( netif ); |
return EINVAL; |
} |
// printf( " set %s", setting->value ); |
netif->il = modules_find( & networking_globals.modules, setting->value, 0 ); |
if( ! netif->il ){ |
netif->internet_layer_module = modules_find( & networking_globals.modules, setting->value ); |
if( ! netif->internet_layer_module ){ |
// TODO register the unknown one |
-- netif->driver->usage; |
-- netif->nil->usage; |
-- netif->driver_module->usage; |
-- netif->link_layer_module->usage; |
measured_strings_destroy( & netif->configuration ); |
free( netif ); |
return EINVAL; |
} |
// printf( " found" ); |
if( ! netif->il->task_id ){ |
netif->il->task_id = spawn( netif->il->filename ); |
if( ! netif->il->task_id ){ |
-- netif->driver->usage; |
-- netif->nil->usage; |
if( ! netif->internet_layer_module->task_id ){ |
netif->internet_layer_module->task_id = spawn( netif->internet_layer_module->filename ); |
if( ! netif->internet_layer_module->task_id ){ |
-- netif->driver_module->usage; |
-- netif->link_layer_module->usage; |
measured_strings_destroy( & netif->configuration ); |
free( netif ); |
return EINVAL; |
563,7 → 578,7 |
free( netif ); |
return ERROR_CODE; |
} |
if( ERROR_OCCURED( char_map_add( & networking_globals.netif_names, netif->name, 0, index ))){ |
if( ERROR_OCCURED( char_map_add( & networking_globals.netif_names, netif->name, index ))){ |
netifs_exclude_index( & networking_globals.netifs, index ); |
return ERROR_CODE; |
} |
570,35 → 585,32 |
// printf( "\nloopback OK" ); |
// end of the static loopback initialization |
// startup the loopback interface |
if( ! netif->driver->phone ){ |
if( ! netif->driver_module->phone ){ |
// printf( " connect?" ); |
netif->driver->phone = connect_to_service( netif->driver->service ); |
netif->driver_module->phone = connect_to_service( netif->driver_module->service ); |
} |
// printf( " connected" ); |
// TODO io, irq |
ERROR_PROPAGATE( async_req_3_0( netif->driver->phone, NET_NETIF_PROBE, netif->id, 0, 0 )); |
++ netif->driver->usage; |
if( netif->nil ){ |
if( ! netif->nil->phone ){ |
netif->nil->phone = connect_to_service( netif->nil->service ); |
ERROR_PROPAGATE( async_req_1_0( netif->driver_module->phone, NET_NETIF_PROBE, netif->id )); |
++ netif->driver_module->usage; |
if( netif->link_layer_module ){ |
if( ! netif->link_layer_module->phone ){ |
netif->link_layer_module->phone = connect_to_service( netif->link_layer_module->service ); |
} |
ERROR_PROPAGATE( async_req_2_0( netif->nil->phone, NET_NIL_DEVICE, netif->id, netif->driver->service )); |
++ netif->nil->usage; |
internet_service = netif->nil->service; |
ERROR_PROPAGATE( async_req_2_0( netif->link_layer_module->phone, NET_LL_DEVICE, netif->id, netif->driver_module->service )); |
++ netif->link_layer_module->usage; |
internet_service = netif->link_layer_module->service; |
// printf( " OK" ); |
}else{ |
internet_service = netif->driver->service; |
internet_service = netif->driver_module->service; |
// printf( " none" ); |
} |
if( ! netif->il->phone ){ |
if( ! netif->internet_layer_module->phone ){ |
// printf( " connect" ); |
netif->il->phone = connect_to_service( netif->il->service ); |
netif->internet_layer_module->phone = connect_to_service( netif->internet_layer_module->service ); |
} |
// TODO IL_BUNDLE |
ERROR_PROPAGATE( async_req_2_0( netif->il->phone, NET_IL_DEVICE, netif->id, internet_service )); |
++ netif->il->usage; |
// TODO startup? |
ERROR_PROPAGATE( async_req_1_0( netif->driver->phone, NET_NETIF_START, netif->id )); |
ERROR_PROPAGATE( async_req_2_0( netif->internet_layer_module->phone, NET_IL_DEVICE, netif->id, internet_service )); |
++ netif->internet_layer_module->usage; |
ERROR_PROPAGATE( async_req_1_0( netif->driver_module->phone, NET_NETIF_START, netif->id )); |
// printf( "\n LO OK" ); |
return EOK; |
} |
/branches/network/uspace/srv/net/networking/Makefile |
---|
47,17 → 47,13 |
../modules.c |
# ../self_test.c |
DEFS += -D NETWORKING_$(NETWORKING) |
ifeq ($(NETWORKING), module) |
SOURCES += ../ip/ip.c \ |
../tcp/tcp.c |
endif |
DEFS += -D IP_BUNDLE=1 -D TCP_BUNDLE=1 |
DEFS += -D NETWORKING_$(NETWORKING) |
endif |
OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) |
.PHONY: all clean depend disasm |
/branches/network/uspace/srv/net/modules.c |
---|
33,7 → 33,6 |
/** @file |
*/ |
#include <async.h> |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
54,21 → 53,34 |
return phone; |
} |
int bind_service( services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver ){ |
int start_service( services_t me, services_t need[], int * need_phone[], void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall ), int ( * initialize_me )( void )){ |
ipcarg_t phonehash; |
ERROR_DECLARE; |
ipcarg_t phone; |
ipcarg_t phonehash; |
if( ! client_connection ) return EINVAL; |
async_set_client_connection( client_connection ); |
phone = connect_to_service( need ); |
if( phone >= 0 ){ |
if( ERROR_OCCURED( ipc_connect_to_me( phone, arg1, arg2, arg3, & phonehash ))){ |
async_msg_0( phone, IPC_M_PHONE_HUNGUP ); |
return ERROR_CODE; |
if( need ){ |
if( ! need_phone ) return EINVAL; |
while( * need ){ |
if( ! * need_phone ) return EINVAL; |
/* Connect to the needed service */ |
** need_phone = connect_to_service( * need ); |
++ need; |
++ need_phone; |
} |
async_new_connection( phonehash, 0, NULL, client_receiver ); |
} |
return phone; |
/* Initialize service by its callback */ |
if( initialize_me ) ERROR_PROPAGATE( initialize_me()); |
/* Register service at NS */ |
if( me ) ERROR_PROPAGATE( REGISTER_ME( me, & phonehash )); |
async_manager(); |
return EOK; |
} |
/** @} |
/branches/network/uspace/srv/net/messages.h |
---|
33,16 → 33,13 |
/** @file |
*/ |
#ifndef __NET_MESSAGES_H__ |
#define __NET_MESSAGES_H__ |
#define NET_NETIF_COUNT 6 |
#define NET_NET_COUNT 9 |
#define NET_NIL_COUNT 8 |
#define NET_ETH_COUNT 0 |
#define NET_IL_COUNT 3 |
#define NET_IP_COUNT 2 |
#define NET_ARP_COUNT 4 |
#define NET_NETIF_COUNT 7 |
#define NET_NETWORKING_COUNT 4 |
#define NET_LL_COUNT 5 |
#define NET_ETHERNET_COUNT 0 |
#define NET_IL_COUNT 2 |
#define NET_IP_COUNT 4 |
#define NET_ARP_COUNT 0 |
#define NET_RARP_COUNT 0 |
#define NET_ICMP_COUNT 0 |
#define NET_UDP_COUNT 0 |
54,15 → 51,15 |
#define NET_NETIF_FIRST NET_FIRST |
#define NET_NETIF_LAST ( NET_NETIF_FIRST + NET_NETIF_COUNT ) |
#define NET_NET_FIRST ( NET_NETIF_LAST + 0 ) |
#define NET_NET_LAST ( NET_NET_FIRST + NET_NET_COUNT ) |
#define NET_NETWORKING_FIRST ( NET_NETIF_LAST + 0 ) |
#define NET_NETWORKING_LAST ( NET_NETWORKING_FIRST + NET_NETWORKING_COUNT ) |
#define NET_NIL_FIRST ( NET_NET_LAST + 0 ) |
#define NET_NIL_LAST ( NET_NIL_FIRST + NET_NIL_COUNT ) |
#define NET_ETH_FIRST ( NET_NIL_LAST + 0 ) |
#define NET_ETH_LAST ( NET_ETH_FIRST + NET_ETH_COUNT ) |
#define NET_LL_FIRST ( NET_NETWORKING_LAST + 0 ) |
#define NET_LL_LAST ( NET_LL_FIRST + NET_LL_COUNT ) |
#define NET_ETHERNET_FIRST ( NET_LL_LAST + 0 ) |
#define NET_ETHERNET_LAST ( NET_ETHERNET_FIRST + NET_ETHERNET_COUNT ) |
#define NET_IL_FIRST ( NET_ETH_LAST + 0 ) |
#define NET_IL_FIRST ( NET_ETHERNET_LAST + 0 ) |
#define NET_IL_LAST ( NET_IL_FIRST + NET_IL_COUNT ) |
#define NET_IP_FIRST ( NET_IL_LAST + 0 ) |
#define NET_IP_LAST ( NET_IP_FIRST + NET_IP_COUNT ) |
88,9 → 85,9 |
#define IS_IN_INTERVAL( item, first_inclusive, last_exclusive ) ((( item ) >= ( first_inclusive )) && (( item ) < ( last_exclusive ))) |
#define IS_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_FIRST, NET_LAST ) |
#define IS_NET_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_NET_FIRST, NET_NET_LAST ) |
#define IS_NET_NIL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_NIL_FIRST, NET_NIL_LAST ) |
#define IS_NET_ETH_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_ETH_FIRST, NET_ETH_LAST ) |
#define IS_NET_NETWORKING_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_NETWORKING_FIRST, NET_NETWORKING_LAST ) |
#define IS_NET_LL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_LL_FIRST, NET_LL_LAST ) |
#define IS_NET_ETHERNET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_ETHERNET_FIRST, NET_SOCKET_LAST ) |
#define IS_NET_IL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_IL_FIRST, NET_IL_LAST ) |
#define IS_NET_IP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_IP_FIRST, NET_IP_LAST ) |
#define IS_NET_ARP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_ARP_FIRST, NET_ARP_LAST ) |
100,75 → 97,29 |
#define IS_NET_SOCKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( call ), NET_SOCKET_FIRST, NET_SOCKET_LAST ) |
typedef enum { |
/* ( device_id, irq, io ) */ |
NET_NETIF_PROBE = NET_NETIF_FIRST, |
/* () not supported, should ask networking for a name and register device */ |
NET_NETIF_PROBE_AUTO, |
/* ( device_id ), packet_send */ |
NET_NETIF_REGISTER, |
NET_NETIF_SEND, |
/* ( device_id ) */ |
NET_NETIF_START, |
/* ( device_id ), ipc_data_read( stats ) */ |
NET_NETIF_STATS, |
/* ( device_id ) */ |
NET_NETIF_STOP, |
/* () not supported, registers new device */ |
NET_NET_DEVICE = NET_NET_FIRST, |
/* (), measured_strings_send( names ), measured_strings_return( values ) */ |
NET_NET_GET_CONF, |
/* ( device_id ), measured_strings_send( names ), measured_strings_return( values ) */ |
NET_NET_GET_DEVICE_CONF, |
/* () not supported, measured_strings_send( names ), measured_strings_send( values ) */ |
NET_NET_SET_CONF, |
/* ( device_id ) not supported, measured_strings_send( names ), measured_strings_send( values ) */ |
NET_NET_SET_DEVICE_CONF, |
/* () */ |
NET_NET_STARTUP, |
/* ( device_id ) */ |
NET_NET_START, |
/* ( device_id ) */ |
NET_NET_STOP, |
/* ( device_id ) ipc_data_read( stats ) */ |
NET_NET_STATS, |
/* ( device_id, driver_service ) */ |
NET_NIL_DEVICE = NET_NIL_FIRST, |
/* ( device_id, state ) */ |
NET_NIL_DEVICE_STATE, |
/* ( device_id, mtu ) */ |
NET_NIL_MTU, |
/* ( device_id ), packet_send */ |
NET_NIL_RECEIVED, |
/* ( device_id ), packet_send */ |
NET_NIL_SEND, |
/* ( device_id ) -> prefix, content, sufix */ |
NET_NIL_PACKET_SPACE, |
/* ( device_id ), measured_strings_return( hardware address ) */ |
NET_NIL_ADDR, |
/* ( device_id ), measured_strings_return( broadcast address ) */ |
NET_NIL_BROADCAST_ADDR, |
/* ( service ), protocol */ |
// NET_NIL_PROTOCOL, |
/* ( device_id, nil_service ) */ |
NET_NETWORKING_DEVICE = NET_NETWORKING_FIRST, |
NET_NETWORKING_GET_CONFIGURATION, |
NET_NETWORKING_GET_DEVICE_CONFIGURATION, |
NET_NETWORKING_STARTUP, |
NET_LL_DEVICE = NET_LL_FIRST, |
NET_LL_DEVICE_STATE_CHANGED, |
NET_LL_MTU_CHANGED, |
NET_LL_RECEIVED, |
NET_LL_REGISTER, |
NET_IL_DEVICE = NET_IL_FIRST, |
/* ( device_id, state ) */ |
NET_IL_DEVICE_STATE, |
/* ( device_id ), packet_send */ |
NET_IL_RECEIVED, |
/* ( device_id ), measured_strings_send( address ) */ |
// NET_IL_MY_ADDR, |
NET_IP_ECHO = NET_IP_FIRST, |
NET_IP_SEND, |
/* ( device_id, nil_service, proto ), measured_strings_send( proto_addr ) */ |
NET_ARP_DEVICE = NET_ARP_FIRST, |
/* ( device_id, protocol ), measured_strings_send( target ), measured_strings_return( translation ) */ |
NET_ARP_TRANSLATE, |
/* ( device_id ) */ |
NET_ARP_CLEAR_DEVICE, |
/* () */ |
NET_ARP_CLEAN_CACHE |
NET_IL_DEVICE_STATE_CHANGED, |
NET_IP_CONFIGURATION_DHCP = NET_IP_FIRST, |
NET_IP_CONFIGURATION_STATIC, |
NET_IP_ECHO, |
NET_IP_TCP_REGISTER |
} net_message; |
#endif |
/** @} |
*/ |
/branches/network/uspace/srv/net/measured_strings.c |
---|
30,9 → 30,8 |
* @{ |
*/ |
/** @file |
* A character string with measured length implementation file. |
* @see measured_strings.h |
/** |
* @file |
*/ |
#include <errno.h> |
40,7 → 39,6 |
#include <stdio.h> |
#include <string.h> |
#include <unistd.h> |
#include <ipc/ipc.h> |
#include "err.h" |
47,13 → 45,7 |
#include "measured_strings.h" |
#include "modules.h" |
/** Computes the lengths of the measured strings in the given array. |
* @param strings The measured strings array to be processed. Input parameter. |
* @param count The measured strings array size. Input parameter. |
* @returns The computed sizes array. |
* @returns NULL if there is no memory left. |
*/ |
size_t * prepare_lengths( const measured_string_ref strings, size_t count ); |
size_t * prepare_lengths( measured_string_ref strings, size_t count ); |
measured_string_ref measured_string_create_bulk( const char * string, size_t length ){ |
measured_string_ref new; |
65,9 → 57,7 |
if( ! new ) return NULL; |
new->length = length; |
new->value = (( char * ) new ) + sizeof( measured_string_t ); |
// append terminating zero explicitly - to be safe |
memcpy( new->value, string, new->length ); |
new->value[ new->length ] = '\0'; |
memcpy( new->value, string, new->length + 1 ); |
return new; |
} |
127,7 → 117,7 |
return EOK; |
} |
int measured_strings_reply( const measured_string_ref strings, size_t count ){ |
int measured_strings_reply( measured_string_ref strings, size_t count ){ |
ERROR_DECLARE; |
size_t * lengths; |
203,7 → 193,7 |
return EOK; |
} |
int measured_strings_send( int phone, const measured_string_ref strings, size_t count ){ |
int measured_strings_send( int phone, measured_string_ref strings, size_t count ){ |
ERROR_DECLARE; |
size_t * lengths; |
227,7 → 217,7 |
return EOK; |
} |
size_t * prepare_lengths( const measured_string_ref strings, size_t count ){ |
size_t * prepare_lengths( measured_string_ref strings, size_t count ){ |
size_t * lengths; |
int index; |
size_t length; |
/branches/network/uspace/srv/net/measured_strings.h |
---|
30,105 → 30,27 |
* @{ |
*/ |
/** @file |
* A character string with measured length header file. |
* This structure has been designed for serialization of character strings between modules. |
/** |
* @file |
*/ |
#ifndef __MEASURED_STRINGS_H__ |
#define __MEASURED_STRINGS_H__ |
/** A type definition of a character string with measured length. |
* @see measured_string |
*/ |
typedef struct measured_string measured_string_t; |
/** A type definition of a character string with measured length pointer. |
* @see measured_string |
*/ |
typedef measured_string_t * measured_string_ref; |
/** A character string with measured length. |
* This structure has been designed for serialization of character strings between modules. |
*/ |
struct measured_string{ |
/** The character string data. |
*/ |
char * value; |
/** The character string length. |
*/ |
size_t length; |
}; |
/** Creates a new measured string bundled with a copy of the given string itself as one memory block. |
* If the measured string is being freed, whole memory block is freed. |
* The measured string should be used only as a constant. |
* @param string The initial character string to be stored. Input parameter. |
* @param length The length of the given string without the terminating zero ('/0') character. If the length is zero (0), the actual length is computed. The given length is used and appended with the terminating zero ('\0') character otherwise. Input parameter. |
* @returns The new bundled charecter string with measured length. |
* @returns NULL if there is no memory left. |
*/ |
measured_string_ref measured_string_create_bulk( const char * string, size_t length ); |
/** Receives a measured strings array from a calling module. |
* Creates the array and the data memory blocks. |
* This method should be used only while processing IPC messages as the array size has to be negotiated in advance. |
* @param strings The received measured strings array. Output parameter. |
* @param data The measured strings data. This memory block stores the actual character strings. Output parameter. |
* @param count The size of the measured strings array. Input parameter. |
* @returns EOK on success. |
* @returns EINVAL if the strings or data parameter is NULL. |
* @returns EINVAL if the count parameter is zero (0). |
* @returns EINVAL if the sent array differs in size. |
* @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur). |
* @returns ENOMEM if there is no memory left. |
* @returns Other error codes as defined for the ipc_data_write_finalize() function. |
*/ |
int measured_strings_receive( measured_string_ref * strings, char ** data, size_t count ); |
/** Replies the given measured strings array to a calling module. |
* This method should be used only while processing IPC messages as the array size has to be negotiated in advance. |
* @param strings The measured strings array to be transferred. Input parameter. |
* @param count The measured strings array size. Input parameter. |
* @returns EOK on success. |
* @returns EINVAL if the strings parameter is NULL. |
* @returns EINVAL if the count parameter is zero (0). |
* @returns EINVAL if the calling module does not accept the given array size. |
* @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur). |
* @returns Other error codes as defined for the ipc_data_read_finalize() function. |
*/ |
int measured_strings_reply( const measured_string_ref strings, size_t count ); |
/** Receives a measured strings array from another module. |
* Creates the array and the data memory blocks. |
* This method should be used only following other IPC messages as the array size has to be negotiated in advance. |
* @param phone The other module phone. Input parameter. |
* @param strings The returned measured strings array. Output parameter. |
* @param data The measured strings data. This memory block stores the actual character strings. Output parameter. |
* @param count The size of the measured strings array. Input parameter. |
* @returns EOK on success. |
* @returns EINVAL if the strings or data parameter is NULL. |
* @returns EINVAL if the phone or count parameter is not positive (<=0). |
* @returns EINVAL if the sent array differs in size. |
* @returns ENOMEM if there is no memory left. |
* @returns Other error codes as defined for the ipc_data_read_start() function. |
*/ |
int measured_strings_reply( measured_string_ref strings, size_t count ); |
int measured_strings_return( int phone, measured_string_ref * strings, char ** data, size_t count ); |
int measured_strings_send( int phone, measured_string_ref strings, size_t count ); |
/** Sends the given measured strings array to another module. |
* This method should be used only following other IPC messages as the array size has to be negotiated in advance. |
* @param phone The other module phone. Input parameter. |
* @param strings The measured strings array to be transferred. Input parameter. |
* @param count The measured strings array size. Input parameter. |
* @returns EOK on success. |
* @returns EINVAL if the strings parameter is NULL. |
* @returns EINVAL if the phone or count parameter is not positive (<=0). |
* @returns Other error codes as defined for the ipc_data_write_start() function. |
*/ |
int measured_strings_send( int phone, const measured_string_ref strings, size_t count ); |
#endif |
/** @} |
/branches/network/uspace/srv/net/netif/device.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
Deleted: svn:mergeinfo |
/branches/network/uspace/srv/net/netif/netif.c |
---|
35,7 → 35,6 |
#include <async.h> |
#include <stdio.h> |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
//#include <sys/mman.h> |
43,53 → 42,36 |
#include "../err.h" |
#include "../messages.h" |
#include "../modules.h" |
#include "../packet.h" |
#include "device.h" |
#include "netif.h" |
#include "netif_device_id_type.h" |
#define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call ) |
#define IPC_GET_IRQ( call ) ( int ) IPC_GET_ARG2( * call ) |
#define IPC_GET_IO( call ) ( int ) IPC_GET_ARG3( * call ) |
#define IPC_GET_PHONE( call ) ( int ) IPC_GET_ARG5( * call ) |
extern netif_globals_t netif_globals; |
extern int initialize( void ); |
extern int probe_auto_message( void ); |
extern int probe_message( device_id_t device_id, int irq, int io ); |
extern int send_message( device_id_t device_id, packet_t packet ); |
extern int start_message( device_id_t device_id ); |
extern int stop_message( device_id_t device_id ); |
extern int netif_initialize( void ); |
extern void netif_print_name( void ); |
extern int netif_probe_auto_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ); |
extern int netif_probe_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ); |
extern int netif_send_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ); |
extern int netif_start_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ); |
extern int netif_stop_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ); |
DEVICE_MAP_IMPLEMENT( device_map, device_t ) |
DEVICE_MAP_IMPLEMENT( netif_device_map, netif_device_t ) |
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ); |
int netif_start_module( async_client_conn_t client_connection ); |
int register_message( device_id_t device_id, int phone ); |
int get_device_stats( device_id_t device_id, device_stats_ref * stats ); |
int netif_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 ); |
int netif_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall )); |
int find_device( device_id_t device_id, device_ref * device ){ |
* device = device_map_find( & netif_globals.device_map, device_id ); |
int netif_device_find( netif_device_id_t device_id, netif_device_ref * device ){ |
* device = netif_device_map_find( & netif_globals.netif_device_map, device_id ); |
if( ! * device ) return ENOENT; |
if(( ** device ).state == NETIF_NULL ) return EPERM; |
return EOK; |
} |
int get_device_stats( device_id_t device_id, device_stats_ref * stats ){ |
ERROR_DECLARE; |
device_ref device; |
if( ! stats ) return EINVAL; |
ERROR_PROPAGATE( find_device( device_id, & device )); |
* stats = & device->stats; |
return EOK; |
} |
void null_device_stats( device_stats_ref stats ){ |
memset( stats, 0, sizeof( device_stats_t )); |
/* stats->rx_packets = 0; |
void netif_device_stats_null( netif_device_stats_ref stats ) |
{ |
//memset( stats, 0, sizeof( netif_device_t )); |
stats->rx_packets = 0; |
stats->tx_packets = 0; |
stats->rx_bytes = 0; |
stats->tx_bytes = 0; |
112,65 → 94,58 |
stats->tx_window_errors = 0; |
stats->rx_compressed = 0; |
stats->tx_compressed = 0; |
*/ |
} |
int register_message( device_id_t device_id, int phone ){ |
int netif_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 ){ |
ERROR_DECLARE; |
device_ref device; |
ERROR_PROPAGATE( find_device( device_id, & device )); |
if( device->nil_phone ) return ELIMIT; |
device->nil_phone = phone; |
return EOK; |
} |
int netif_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
ERROR_DECLARE; |
size_t length; |
device_stats_ref stats; |
packet_t packet; |
netif_device_ref device; |
// printf( "\nNETIF message %d", method ); |
* answer_count = 0; |
switch( IPC_GET_METHOD( * call )){ |
switch( method ){ |
case IPC_M_PHONE_HUNGUP: |
return EOK; |
case NET_NETIF_PROBE_AUTO: |
return probe_auto_message(); |
return netif_probe_auto_message( arg1, arg2, arg3, result1, result2, result3 ); |
case NET_NETIF_PROBE: |
return probe_message( IPC_GET_DEVICE( call ), IPC_GET_IRQ( call ), IPC_GET_IO( call )); |
case IPC_M_CONNECT_TO_ME: |
return register_message( IPC_GET_DEVICE( call ), IPC_GET_PHONE( call )); |
return netif_probe_message( arg1, arg2, arg3, result1, result2, result3 ); |
case NET_NETIF_REGISTER: |
case NET_LL_REGISTER: |
ERROR_PROPAGATE( netif_device_find( arg1, & device )); |
device->ll_registered = connect_to_service( arg2 ); |
return EOK; |
case NET_NETIF_SEND: |
ERROR_PROPAGATE( packet_receive( & packet )); |
return send_message( IPC_GET_DEVICE( call ), packet ); |
return netif_send_message( arg1, arg2, arg3, result1, result2, result3 ); |
case NET_NETIF_START: |
return start_message( IPC_GET_DEVICE( call )); |
return netif_start_message( arg1, arg2, arg3, result1, result2, result3 ); |
case NET_NETIF_STATS: |
ERROR_PROPAGATE( ipc_data_read_receive( & callid, & length )); |
if( length < sizeof( device_stats_t )) return EOVERFLOW; |
ERROR_PROPAGATE( get_device_stats( IPC_GET_DEVICE( call ), & stats )); |
return ipc_data_read_finalize( callid, stats, sizeof( device_stats_t )); |
if( length < sizeof( netif_device_stats_t )){ |
ipc_answer_0( callid, EOVERFLOW ); |
return EOVERFLOW; |
} |
if( ERROR_OCCURED( netif_device_find( arg1, & device ))){ |
ipc_answer_0( callid, ERROR_CODE ); |
return ERROR_CODE; |
} |
return ipc_data_read_finalize( callid, & device->stats, sizeof( netif_device_stats_t )); |
case NET_NETIF_STOP: |
return stop_message( IPC_GET_DEVICE( call )); |
return netif_stop_message( arg1, arg2, arg3, result1, result2, result3 ); |
} |
return ENOTSUP; |
} |
int netif_start_module( async_client_conn_t client_connection ){ |
ERROR_DECLARE; |
int netif_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall )){ |
services_t need[ 2 ]; |
int * need_phone[ 2 ]; |
async_set_client_connection( client_connection ); |
netif_globals.networking_phone = connect_to_service( SERVICE_NETWORKING ); |
device_map_initialize( & netif_globals.device_map ); |
ERROR_PROPAGATE( initialize()); |
async_manager(); |
return EOK; |
need[ 0 ] = SERVICE_NETWORKING; |
need[ 1 ] = NULL; |
need_phone[ 0 ] = & netif_globals.networking_phone; |
need_phone[ 1 ] = NULL; |
netif_device_map_initialize( & netif_globals.netif_device_map ); |
return start_service( NULL, need, need_phone, client_connection, netif_initialize ); |
} |
/** @} |
/branches/network/uspace/srv/net/netif/lo.c |
---|
36,15 → 36,14 |
#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 "../measured_strings.h" |
#include "../messages.h" |
#include "../modules.h" |
#include "../packet.h" |
#include "netif.h" |
54,45 → 53,49 |
netif_globals_t netif_globals; |
int change_state_message( device_id_t device_id, device_state_t state ); |
int create( device_id_t device_id, device_ref * device ); |
int initialize( void ); |
void change_state( netif_device_ref device, netif_state_t state ); |
int change_state_message( netif_device_id_t device_id, netif_state_t state ); |
int netif_create( netif_device_id_t device_id, netif_device_ref * device ); |
int netif_call( ipc_callid_t callid ); |
int netif_initialize( void ); |
void netif_print_name( void ); |
int probe_auto_message( void ); |
int probe_message( device_id_t device_id, int irq, int io ); |
int send_message( device_id_t device_id, packet_t packet ); |
int start_message( device_id_t device_id ); |
int stop_message( device_id_t device_id ); |
int netif_probe_auto_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ); |
int netif_probe_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ); |
int netif_send_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ); |
int netif_start_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ); |
int netif_stop_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ); |
int change_state_message( device_id_t device_id, device_state_t state ){ |
void change_state( netif_device_ref device, netif_state_t state ){ |
device->state = state; |
ll_message( device, NET_LL_DEVICE_STATE_CHANGED, device->state, NULL, NULL, NULL, NULL ); |
} |
int change_state_message( netif_device_id_t device_id, netif_state_t state ){ |
ERROR_DECLARE; |
device_ref device; |
netif_device_ref device; |
ERROR_PROPAGATE( find_device( device_id, & device )); |
if( device->state != state ){ |
device->state = state; |
nil_message( device, NET_NIL_DEVICE_STATE, device->state, NULL, NULL, NULL, NULL ); |
} |
ERROR_PROPAGATE( netif_device_find( device_id, & device )); |
change_state( device, state ); |
return EOK; |
} |
int create( device_id_t device_id, device_ref * device ){ |
int netif_create( netif_device_id_t device_id, netif_device_ref * device ){ |
ERROR_DECLARE; |
if( device_map_count( & netif_globals.device_map ) > 0 ){ |
if( netif_device_map_count( & netif_globals.netif_device_map ) > 0 ){ |
return EXDEV; |
}else{ |
* device = ( device_ref ) malloc( sizeof( device_t )); |
* device = ( netif_device_ref ) malloc( sizeof( netif_device_t )); |
if( !( * device )) return ENOMEM; |
( ** device ).device_id = device_id; |
( ** device ).nil_phone = -1; |
( ** device ).ll_registered = -1; |
( ** device ).specific = NULL; |
null_device_stats( &(( ** device ).stats )); |
netif_device_stats_null( &(( ** device ).stats )); |
( ** device ).state = NETIF_STOPPED; |
( ** device ).flags = NULL; |
( ** device ).mtu = DEFAULT_MTU; |
if( ERROR_OCCURED( device_map_add( & netif_globals.device_map, ( ** device ).device_id, * device ))){ |
if( ERROR_OCCURED( netif_device_map_add( & netif_globals.netif_device_map, ( ** device ).device_id, * device ))){ |
free( * device ); |
* device = NULL; |
return ERROR_CODE; |
101,7 → 104,11 |
return EOK; |
} |
int initialize( void ){ |
int netif_call( ipc_callid_t callid ){ |
return EOK; |
} |
int netif_initialize( void ){ |
ipcarg_t phonehash; |
return REGISTER_ME( SERVICE_LO, & phonehash ); |
111,20 → 118,20 |
printf( NAME ); |
} |
int probe_auto_message( void ){ |
int netif_probe_auto_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){ |
/* ERROR_DECLARE; |
device_ref device; |
netif_device_ref device; |
ERROR_PROPAGATE( create( arg1, & device )); |
ipc_call_sync_3_3( netif_globals.networking_phone, NET_NET_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL ); |
ERROR_PROPAGATE( netif_create( arg1, & device )); |
ipc_call_sync_3_3( netif_globals.networking_phone, NET_NETWORKING_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL ); |
*/ return ENOTSUP; |
} |
int probe_message( device_id_t device_id, int irq, int io ){ |
int netif_probe_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){ |
ERROR_DECLARE; |
device_ref device; |
netif_device_ref device; |
aid_t message; |
ipc_call_t answer; |
measured_string_t configuration[ 1 ] = {{ "MTU", 3 }}; |
133,9 → 140,9 |
char * data; |
// create a new device |
ERROR_PROPAGATE( create( device_id, & device )); |
ERROR_PROPAGATE( netif_create( arg1, & device )); |
// get configuration |
message = async_send_2( netif_globals.networking_phone, NET_NET_GET_DEVICE_CONF, device->device_id, count, & answer ); |
message = async_send_2( netif_globals.networking_phone, NET_NETWORKING_GET_DEVICE_CONFIGURATION, device->device_id, count, & answer ); |
// send names and get settings |
if( ERROR_OCCURED( measured_strings_send( netif_globals.networking_phone, configuration, count )) |
|| ERROR_OCCURED( measured_strings_return( netif_globals.networking_phone, & settings, & data, count ))){ |
149,7 → 156,7 |
device->mtu = DEFAULT_MTU; |
} |
// print the settings |
printf("\n -MTU =\t%d", device->mtu ); |
printf("\n -MTU=%d", device->mtu ); |
free( settings ); |
free( data ); |
// end request |
157,44 → 164,31 |
return EOK; |
} |
int send_message( device_id_t device_id, packet_t packet ){ |
int netif_send_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){ |
ERROR_DECLARE; |
device_ref device; |
size_t length; |
aid_t message; |
ipc_call_t answer; |
ipcarg_t result; |
packet_t received; |
netif_device_ref device; |
ERROR_PROPAGATE( find_device( device_id, & device )); |
if( device->state != NETIF_ACTIVE ) return EPERM; |
ERROR_PROPAGATE( netif_device_find( arg1, & device )); |
if( device->state == NETIF_ACTIVE ){ |
++ device->stats.tx_packets; |
++ device->stats.rx_packets; |
length = packet_get_data_length( packet ); |
device->stats.tx_bytes += length; |
device->stats.rx_bytes += length; |
received = packet_copy( packet ); |
packet_destroy( packet ); |
if( ! received ){ |
++ device->stats.rx_dropped; |
// TODO packet size |
//device->stats->tx_bytes += ; |
//device->stats->rx_bytes += ; |
ll_message( device, NET_LL_RECEIVED, arg2, NULL, NULL, NULL, NULL ); |
return EOK; |
}else{ |
return EPERM; |
} |
message = async_send_1( device->nil_phone, NET_NIL_RECEIVED, ( device_id ), & answer ); |
if( ERROR_OCCURED( packet_send( received, device->nil_phone ))){ |
++ device->stats.rx_dropped; |
} |
async_wait_for( message, & result ); |
if( result != EOK ) ++ device->stats.rx_dropped; |
return EOK; |
} |
int start_message( device_id_t device_id ){ |
return change_state_message( device_id, NETIF_ACTIVE ); |
int netif_start_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){ |
return change_state_message( arg1, NETIF_ACTIVE ); |
} |
int stop_message( device_id_t device_id ){ |
return change_state_message( device_id, NETIF_STOPPED ); |
int netif_stop_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){ |
return change_state_message( arg1, NETIF_STOPPED ); |
} |
/** @} |
/branches/network/uspace/srv/net/netif/netif.h |
---|
37,22 → 37,67 |
#ifndef __NET_NETIF_H__ |
#define __NET_NETIF_H__ |
#include "device.h" |
#include "netif_device_id_type.h" |
#define nil_message( device, message, arg2, arg3, result1, result2, result3 ) \ |
if(( device )->nil_phone >= 0 ) async_msg_3(( device )->nil_phone, ( message ), ( device )->device_id, arg2, arg3 ) |
#define ll_message( device, message, arg2, arg3, result1, result2, result3 ) \ |
if(( device )->ll_registered >= 0 ) async_msg_3(( device )->ll_registered, ( message ), ( device )->device_id, arg2, arg3 ) |
typedef struct device device_t; |
typedef device_t * device_ref; |
typedef enum netif_state netif_state_t; |
typedef struct netif_device_stats netif_device_stats_t; |
typedef netif_device_stats_t * netif_device_stats_ref; |
typedef struct netif_device netif_device_t; |
typedef netif_device_t * netif_device_ref; |
typedef struct netif_globals netif_globals_t; |
DEVICE_MAP_DECLARE( device_map, device_t ); |
DEVICE_MAP_DECLARE( netif_device_map, netif_device_t ); |
struct device{ |
device_id_t device_id; |
int nil_phone; |
device_stats_t stats; |
device_state_t state; |
enum netif_state{ |
NETIF_NULL = 0, |
NETIF_STOPPED, |
NETIF_ACTIVE, |
NETIF_CARRIER_LOST |
}; |
// based on linux_kernel/include/linux/netdevice.h |
struct netif_device_stats{ |
unsigned long rx_packets; /* total packets received */ |
unsigned long tx_packets; /* total packets transmitted */ |
unsigned long rx_bytes; /* total bytes received */ |
unsigned long tx_bytes; /* total bytes transmitted */ |
unsigned long rx_errors; /* bad packets received */ |
unsigned long tx_errors; /* packet transmit problems */ |
unsigned long rx_dropped; /* no space in linux buffers */ |
unsigned long tx_dropped; /* no space available in linux */ |
unsigned long multicast; /* multicast packets received */ |
unsigned long collisions; |
/* detailed rx_errors: */ |
unsigned long rx_length_errors; |
unsigned long rx_over_errors; /* receiver ring buff overflow */ |
unsigned long rx_crc_errors; /* recved pkt with crc error */ |
unsigned long rx_frame_errors; /* recv'd frame alignment error */ |
unsigned long rx_fifo_errors; /* recv'r fifo overrun */ |
unsigned long rx_missed_errors; /* receiver missed packet */ |
/* detailed tx_errors */ |
unsigned long tx_aborted_errors; |
unsigned long tx_carrier_errors; |
unsigned long tx_fifo_errors; |
unsigned long tx_heartbeat_errors; |
unsigned long tx_window_errors; |
/* for cslip etc */ |
unsigned long rx_compressed; |
unsigned long tx_compressed; |
}; |
struct netif_device{ |
netif_device_id_t device_id; |
int ll_registered; |
netif_device_stats_t stats; |
netif_state_t state; |
int flags; |
size_t mtu; |
void * specific; |
60,11 → 105,11 |
struct netif_globals{ |
int networking_phone; |
device_map_t device_map; |
netif_device_map_t netif_device_map; |
}; |
int find_device( device_id_t device_id, device_ref * device ); |
void null_device_stats( device_stats_ref stats ); |
int netif_device_find( netif_device_id_t device_id, netif_device_ref * device ); |
void netif_device_stats_null( netif_device_stats_ref stats ); |
#endif |
/branches/network/uspace/srv/net/netif/Makefile |
---|
45,10 → 45,9 |
$(NETIF).c \ |
../measured_strings.h \ |
../module.c \ |
../modules.c \ |
../packet.c |
../modules.c |
DEFS += -D $(NETIF)_message=module_message -D $(NETIF)_start_module=module_start -D $(NETIF)_print_name=module_print_name |
DEFS += -D NETWORKING_$(NETWORKING) -D $(NETIF)_call=module_call -D $(NETIF)_message=module_message -D $(NETIF)_start_module=module_start -D $(NETIF)_print_name=module_print_name |
OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) |
OBJECTS += $(addsuffix .o,$(basename $(OUTPUT))) |
/branches/network/uspace/srv/net/netif/netif_device_id_type.h |
---|
0,0 → 1,51 |
/* |
* 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 |
*/ |
#include "../int_map.h" |
#ifndef __NET_NETIF_DEVICE_ID_TYPE_H__ |
#define __NET_NETIF_DEVICE_ID_TYPE_H__ |
#define DEVICE_MAP_DECLARE INT_MAP_DECLARE |
#define DEVICE_MAP_IMPLEMENT INT_MAP_IMPLEMENT |
typedef int netif_device_id_t; |
#endif |
/** @} |
*/ |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/branches/network/uspace/srv/net/ip/ip_header.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/ip/ip_module.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/ip/ip_messages.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/ip/ip.c |
---|
33,64 → 33,58 |
/** @file |
*/ |
#include <as.h> |
#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 "../measured_strings.h" |
#include "../messages.h" |
#include "../modules.h" |
#include "../packet.h" |
#include "../netif/netif_device_id_type.h" |
#include "../include/sockaddr.h" |
#include "../include/socket.h" |
#include "../netif/device.h" |
#include "ip.h" |
#include "ip_messages.h" |
#include "ip_module.h" |
#define DEFAULT_IPV 4 |
#define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call ) |
#define IPC_GET_PROTO( call ) ( int ) IPC_GET_ARG1( * call ) |
#define IPC_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG2( * call ) |
#define IPC_GET_STATE( call ) ( device_state_t ) IPC_GET_ARG2( * call ) |
#define IPC_GET_PHONE( call ) ( int ) IPC_GET_ARG5( * call ) |
ip_globals_t ip_globals; |
DEVICE_MAP_IMPLEMENT( ip_netifs, ip_netif_t ) |
INT_MAP_IMPLEMENT( ip_protos, ip_proto_t ) |
int parse_address( char * value, address_ref address ); |
int ip_register_message( int protocol, int phone ); |
int ip_state_message( device_id_t device_id, device_state_t state ); |
void ip_driver_receiver( ipc_callid_t iid, ipc_call_t * icall ); |
/** Initializes the module. |
*/ |
int ip_initialize( void ){ |
ip_netifs_initialize( & ip_globals.netifs ); |
ip_protos_initialize( & ip_globals.protos ); |
return EOK; |
} |
int ip_echo_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t * answer1, ipcarg_t * answer2, ipcarg_t * answer3, ipcarg_t * answer4, ipcarg_t * answer5 ){ |
if( answer1 ) * answer1 = arg1; |
if( answer2 ) * answer2 = arg2; |
if( answer3 ) * answer3 = arg3; |
if( answer4 ) * answer4 = arg4; |
if( answer5 ) * answer5 = arg5; |
int ip_call( ipc_callid_t callid ){ |
return EOK; |
} |
int ip_device_message( device_id_t device_id, services_t service ){ |
int parse_address( char * value, address_ref address ){ |
char * next; |
int index; |
if( ! value ){ |
( * address )[ 0 ] = ( * address )[ 1 ] = ( * address )[ 2 ] = ( * address )[ 3 ] = 0; |
return ENOENT; |
} |
next = value; |
for( index = 0; index < 4; ++ index ){ |
if(( ! next ) || ( ! * next )) return EINVAL; |
if( index ) ++ next; |
( * address )[ index ] = strtoul( next, & next, 0 ); |
} |
return EOK; |
} |
int ip_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 ){ |
ERROR_DECLARE; |
ip_netif_ref ip_netif; |
101,12 → 95,20 |
measured_string_ref settings; |
char * data; |
switch( method ){ |
case IPC_M_PHONE_HUNGUP: |
return EOK; |
case NET_IP_ECHO: |
if( result1 ) * result1 = arg1; |
if( result2 ) * result2 = arg2; |
if( result3 ) * result3 = arg3; |
return EOK; |
case NET_IL_DEVICE: |
ip_netif = ( ip_netif_ref ) malloc( sizeof( ip_netif_t )); |
if( ! ip_netif ) return ENOMEM; |
ip_netif->device_id = device_id; |
ip_netif->device_id = arg1; |
// get configuration |
// TODO mapping |
message = async_send_2( ip_globals.networking_phone, NET_NET_GET_DEVICE_CONF, ip_netif->device_id, count, & answer ); |
message = async_send_2( ip_globals.networking_phone, NET_NETWORKING_GET_DEVICE_CONFIGURATION, ip_netif->device_id, count, & answer ); |
// send names and get settings |
if( ERROR_OCCURED( measured_strings_send( ip_globals.networking_phone, configuration, count )) |
|| ERROR_OCCURED( measured_strings_return( ip_globals.networking_phone, & settings, & data, count ))){ |
125,12 → 127,12 |
free( ip_netif ); |
return ENOTSUP; |
}else if( ip_netif->ipv == 4 ){ |
if( ERROR_OCCURED( inet_pton( AF_INET, settings[ 2 ].value, ( uint8_t * ) & ip_netif->address )) |
|| ERROR_OCCURED( inet_pton( AF_INET, settings[ 3 ].value, ( uint8_t * ) & ip_netif->netmask )) |
|| ( inet_pton( AF_INET, settings[ 4 ].value, ( uint8_t * ) & ip_netif->gateway ) == EINVAL ) |
|| ( inet_pton( AF_INET, settings[ 5 ].value, ( uint8_t * ) & ip_netif->broadcast ) == EINVAL ) |
|| ( inet_pton( AF_INET, settings[ 6 ].value, ( uint8_t * ) & ip_netif->dns1 ) == EINVAL ) |
|| ( inet_pton( AF_INET, settings[ 7 ].value, ( uint8_t * ) & ip_netif->dns2 ) == EINVAL )){ |
if( ERROR_OCCURED( parse_address( settings[ 2 ].value, & ip_netif->address )) |
|| ERROR_OCCURED( parse_address( settings[ 3 ].value, & ip_netif->netmask )) |
|| ( parse_address( settings[ 4 ].value, & ip_netif->gateway ) == EINVAL ) |
|| ( parse_address( settings[ 5 ].value, & ip_netif->broadcast ) == EINVAL ) |
|| ( parse_address( settings[ 6 ].value, & ip_netif->dns1 ) == EINVAL ) |
|| ( parse_address( settings[ 7 ].value, & ip_netif->dns2 ) == EINVAL )){ |
free( ip_netif ); |
return EINVAL; |
} |
141,137 → 143,38 |
} |
// TODO ARP module |
} |
// print the settings |
printf( "\n -IPV=%d", ip_netif->ipv ); |
printf( "\n -configuration=%s", ip_netif->dhcp ? "dhcp" : "static" ); |
// TODO ipv6 |
printf( "\n -address=%d.%d.%d.%d", ip_netif->address[ 0 ], ip_netif->address[ 1 ], ip_netif->address[ 2 ], ip_netif->address[ 3 ] ); |
printf( "\n -netmask=%d.%d.%d.%d", ip_netif->netmask[ 0 ], ip_netif->netmask[ 1 ], ip_netif->netmask[ 2 ], ip_netif->netmask[ 3 ] ); |
printf( "\n -gateway=%d.%d.%d.%d", ip_netif->gateway[ 0 ], ip_netif->gateway[ 1 ], ip_netif->gateway[ 2 ], ip_netif->gateway[ 3 ] ); |
printf( "\n -broadcast=%d.%d.%d.%d", ip_netif->broadcast[ 0 ], ip_netif->broadcast[ 1 ], ip_netif->broadcast[ 2 ], ip_netif->broadcast[ 3 ] ); |
printf( "\n -dns1=%d.%d.%d.%d", ip_netif->dns1[ 0 ], ip_netif->dns1[ 1 ], ip_netif->dns1[ 2 ], ip_netif->dns1[ 3 ] ); |
printf( "\n -dns2=%d.%d.%d.%d", ip_netif->dns2[ 0 ], ip_netif->dns2[ 1 ], ip_netif->dns2[ 2 ], ip_netif->dns2[ 3 ] ); |
// TODO arp module |
free( settings ); |
free( data ); |
// end request |
// TODO mapping |
async_wait_for( message, NULL ); |
// print the settings |
printf( "\n -IPV =\t%d", ip_netif->ipv ); |
printf( "\n -configuration =\t%s", ip_netif->dhcp ? "dhcp" : "static" ); |
// TODO ipv6 |
data = malloc( INET_ADDRSTRLEN ); |
if( data ){ |
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->address, data, INET_ADDRSTRLEN ); |
printf( "\n -address =\t%s", data ); |
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->netmask, data, INET_ADDRSTRLEN ); |
printf( "\n -netmask =\t%s", data ); |
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->gateway, data, INET_ADDRSTRLEN ); |
printf( "\n -gateway =\t%s", data ); |
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->broadcast, data, INET_ADDRSTRLEN ); |
printf( "\n -broadcast =\t%s", data ); |
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns1, data, INET_ADDRSTRLEN ); |
printf( "\n -dns1 =\t%s", data ); |
inet_ntop( AF_INET, ( uint8_t * ) & ip_netif->dns2, data, INET_ADDRSTRLEN ); |
printf( "\n -dns2 =\t%s", data ); |
free( data ); |
} |
// TODO mapping |
ip_netif->phone = bind_service( service, ip_netif->device_id, SERVICE_IP, 0, ip_driver_receiver ); |
if( ERROR_OCCURED( ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif ))){ |
ip_netif->phone = connect_to_service( arg2 ); |
if( ERROR_OCCURED( async_req_2_0( ip_netif->phone, NET_LL_REGISTER, arg1, SERVICE_IP )) |
|| ERROR_OCCURED( ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif ))){ |
free( ip_netif ); |
return ERROR_CODE; |
} |
return EOK; |
} |
void ip_driver_receiver( ipc_callid_t iid, ipc_call_t * icall ){ |
ERROR_DECLARE; |
ipc_callid_t callid; |
ipc_call_t call; |
// ipc_call_t answer; |
// int count; |
int result; |
packet_t packet; |
/* |
* Accept the connection |
* - Answer the first IPC_M_CONNECT_ME_TO call. |
*/ |
ipc_answer_0( iid, EOK ); |
while( true ){ |
/* // refresh data |
count = 0; |
IPC_SET_RETVAL( answer, 0 ); |
// just to be precize |
IPC_SET_RETVAL( answer, 0 ); |
IPC_SET_ARG1( answer, 0 ); |
IPC_SET_ARG2( answer, 0 ); |
IPC_SET_ARG3( answer, 0 ); |
IPC_SET_ARG4( answer, 0 ); |
IPC_SET_ARG5( answer, 0 ); |
*/ |
callid = async_get_call( & call ); |
switch( IPC_GET_METHOD( call )){ |
case NET_IL_DEVICE_STATE: |
case NET_NIL_DEVICE_STATE: |
result = ip_state_message( IPC_GET_DEVICE( & call ), IPC_GET_STATE( & call )); |
ipc_answer_0( callid, result ); |
// TODO packer received |
case NET_IL_RECEIVED: |
case NET_NIL_RECEIVED: |
if( ERROR_OCCURED( result = packet_receive( & packet ))){ |
ipc_answer_0( callid, ERROR_CODE ); |
continue; |
} |
//result = ip_receive_message( IPC_GET_DEVICE( call ), packet ); |
packet_destroy( packet ); |
ipc_answer_0( callid, result ); |
} |
} |
} |
int ip_state_message( device_id_t device_id, device_state_t state ){ |
case NET_IL_DEVICE_STATE_CHANGED: |
case NET_LL_DEVICE_STATE_CHANGED: |
// arg1 device id |
// arg2 state |
// TODO state |
printf( "\nip - device %d changed state to %d\n", device_id, state ); |
printf( "\nip - device %d changed state to %d\n", arg1, arg2 ); |
case NET_IP_TCP_REGISTER: |
ip_globals.tcp_phone = connect_to_service( arg1 ); |
return EOK; |
} |
int ip_register_message( int protocol, int phone ){ |
ERROR_DECLARE; |
ip_proto_ref proto; |
proto = ( ip_proto_ref ) malloc( sizeof( ip_protos_t )); |
if( ! proto ) return ENOMEM; |
proto->protocol = protocol; |
proto->phone = phone; |
if( ERROR_OCCURED( ip_protos_add( & ip_globals.protos, proto->protocol, proto ))){ |
free( proto ); |
return ERROR_CODE; |
} |
return EOK; |
} |
int ip_send_message( device_id_t device_id, packet_t packet ){ |
// TODO send packet |
printf( "Packet to send via %d: %s", device_id, packet_get_data( packet )); |
return EOK; |
} |
int ip_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
ERROR_DECLARE; |
packet_t packet; |
* answer_count = 0; |
switch( IPC_GET_METHOD( * call )){ |
case IPC_M_PHONE_HUNGUP: |
return EOK; |
case NET_IP_ECHO: |
* answer_count = 5; |
return ip_echo_message( IPC_GET_ARG1( * call ), IPC_GET_ARG2( * call ), IPC_GET_ARG3( * call ), IPC_GET_ARG4( * call ), IPC_GET_ARG5( * call ), & IPC_GET_ARG1( * answer ), & IPC_GET_ARG2( * answer ), & IPC_GET_ARG3( * answer ), & IPC_GET_ARG4( * answer ), & IPC_GET_ARG5( * answer ) ); |
case NET_IL_DEVICE: |
return ip_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call )); |
case IPC_M_CONNECT_TO_ME: |
return ip_register_message( IPC_GET_PROTO( call ), IPC_GET_PHONE( call )); |
case NET_IP_SEND: |
ERROR_PROPAGATE( packet_receive( & packet )); |
return ip_send_message( IPC_GET_DEVICE( call ), packet ); |
} |
return ENOTSUP; |
} |
/branches/network/uspace/srv/net/ip/Makefile |
---|
46,11 → 46,9 |
$(NAME).c \ |
../measured_strings.c \ |
../module.c \ |
../modules.c \ |
../packet.c \ |
../sockaddr.c |
../modules.c |
DEFS += -D IP_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))) |
/branches/network/uspace/srv/net/ip/ip.h |
---|
34,51 → 34,49 |
* @file |
*/ |
#ifndef __NET_IP_H__ |
#define __NET_IP_H__ |
#ifndef __NET_IP_INTERNALS_H__ |
#define __NET_IP_INTERNALS_H__ |
#include <ipc/ipc.h> |
#include "../include/sockaddr.h" |
#include "../netif/device.h" |
#include "../netif/netif_device_id_type.h" |
#define IP_MAX_ADDRESS_LENGTH 4 |
typedef int address_t[ IP_MAX_ADDRESS_LENGTH ]; |
typedef address_t * address_ref; |
typedef struct ip_netif ip_netif_t; |
typedef ip_netif_t * ip_netif_ref; |
typedef struct ip_proto ip_proto_t; |
typedef ip_proto_t * ip_proto_ref; |
typedef struct ip_globals ip_globals_t; |
DEVICE_MAP_DECLARE( ip_netifs, ip_netif_t ) |
INT_MAP_DECLARE( ip_protos, ip_proto_t ) |
struct ip_netif{ |
device_id_t device_id; |
netif_device_id_t device_id; |
int phone; |
int ipv; |
int dhcp; |
in_addr_t address; |
in_addr_t netmask; |
in_addr_t gateway; |
in_addr_t broadcast; |
in_addr_t dns1; |
in_addr_t dns2; |
address_t address; |
address_t netmask; |
address_t gateway; |
address_t broadcast; |
address_t dns1; |
address_t dns2; |
// TODO modules |
}; |
struct ip_proto{ |
int protocol; |
int phone; |
}; |
struct ip_globals{ |
int networking_phone; |
int tcp_phone; |
ip_netifs_t netifs; |
ip_protos_t protos; |
}; |
int ip_initialize( void ); |
int ip_call( ipc_callid_t callid ); |
int ip_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/ip/ip_module.c |
---|
35,20 → 35,17 |
#include <async.h> |
#include <stdio.h> |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
#include "../err.h" |
#include "../modules.h" |
#include "ip.h" |
#include "ip_module.h" |
#define NAME "IP protocol" |
void ip_print_name( void ); |
int ip_start_module( async_client_conn_t client_connection ); |
int ip_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall )); |
extern ip_globals_t ip_globals; |
56,19 → 53,15 |
printf( NAME ); |
} |
int ip_start_module( async_client_conn_t client_connection ){ |
ERROR_DECLARE; |
int ip_start_module( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall )){ |
services_t need[ 2 ]; |
int * need_phone[ 2 ]; |
ipcarg_t phonehash; |
async_set_client_connection( client_connection ); |
ip_globals.networking_phone = connect_to_service( SERVICE_NETWORKING ); |
ERROR_PROPAGATE( ip_initialize()); |
ERROR_PROPAGATE( REGISTER_ME( SERVICE_IP, & phonehash )); |
async_manager(); |
return EOK; |
need[ 0 ] = SERVICE_NETWORKING; |
need[ 1 ] = NULL; |
need_phone[ 0 ] = & ip_globals.networking_phone; |
need_phone[ 1 ] = NULL; |
return start_service( SERVICE_IP, need, need_phone, client_connection, ip_initialize ); |
} |
/** @} |
/branches/network/uspace/srv/net/networking_startup/networking_startup.c |
---|
36,7 → 36,6 |
#include <async.h> |
#include <stdio.h> |
#include <task.h> |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
65,7 → 64,7 |
} |
// start networking |
networking_phone = connect_to_service( SERVICE_NETWORKING ); |
if( ERROR_OCCURED( ipc_call_sync_0_0( networking_phone, NET_NET_STARTUP ))){ |
if( ERROR_OCCURED( ipc_call_sync_0_0( networking_phone, NET_NETWORKING_STARTUP ))){ |
printf( "\n" NAME " - ERROR %d\n", ERROR_CODE ); |
return ERROR_CODE; |
} |
/branches/network/uspace/srv/net/Makefile |
---|
35,7 → 35,7 |
DIRS_MODULAR = ip \ |
tcp \ |
arp \ |
# arp \ |
# rarp \ |
# icmp \ |
# udp \ |
/branches/network/uspace/srv/net/packet.c |
---|
33,126 → 33,10 |
/** @file |
*/ |
#include <errno.h> |
#include <unistd.h> |
#include <string.h> |
#include <ipc/ipc.h> |
#include <sys/mman.h> |
#include "err.h" |
#include "packet.h" |
#define PACKET_MAGIC_VALUE 0x11227788 |
struct packet{ |
void * start; |
size_t length; |
size_t max_prefix; |
size_t max_content; |
size_t data_start; |
size_t data_end; |
int magic_value; |
}; |
int packet_is_valid( packet_t packet ); |
packet_t packet_create( size_t max_prefix, size_t max_content, size_t max_sufix ){ |
size_t length; |
packet_t packet; |
length = max_prefix + max_content + max_sufix; |
packet = ( packet_t ) mmap( NULL, sizeof( struct packet ) + length, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0 ); |
if( packet == MAP_FAILED ) return NULL; |
packet->length = length; |
packet->max_prefix = max_prefix; |
packet->max_content = max_content; |
packet->data_start = sizeof( struct packet ) + packet->max_prefix; |
packet->data_end = packet->data_start; |
packet->magic_value = PACKET_MAGIC_VALUE; |
return packet; |
} |
int packet_is_valid( packet_t packet ){ |
return packet && ( packet->magic_value == PACKET_MAGIC_VALUE ); |
} |
packet_t packet_copy( packet_t packet ){ |
packet_t new; |
if( ! packet_is_valid( packet )) return NULL; |
new = ( packet_t ) mmap( NULL, packet->length, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0 ); |
if( new == MAP_FAILED ) return NULL; |
memcpy( new, packet, packet->length ); |
return new; |
} |
int packet_copy_data( packet_t packet, void * data, size_t length ){ |
if( ! packet_is_valid( packet )) return EINVAL; |
if( packet->data_start + length >= (( size_t ) packet ) + packet->length ) return ENOMEM; |
memcpy( packet + packet->data_start, data, length ); |
if( packet->data_start + length > packet->data_end ){ |
packet->data_end = packet->data_start + length; |
} |
return EOK; |
} |
void * packet_prepend( packet_t packet, size_t length ){ |
if(( ! packet_is_valid( packet )) || ( packet->data_start - sizeof( struct packet ) < length )) return NULL; |
packet->data_start -= length; |
return packet + packet->data_start; |
} |
void * packet_append( packet_t packet, size_t length ){ |
if(( ! packet_is_valid( packet )) || ( packet->data_end + length >= (( size_t ) packet ) + packet->length )) return NULL; |
packet->data_end += length; |
return packet + packet->data_end - length; |
} |
int packet_trim( packet_t packet, size_t prefix, size_t sufix ){ |
if(( ! packet_is_valid( packet )) || ( prefix + sufix > packet->data_end - packet->data_start )) return EINVAL; |
packet->data_start += prefix; |
packet->data_end -= sufix; |
return EOK; |
} |
int packet_send( packet_t packet, int phone ){ |
if( ! packet_is_valid( packet )) return EINVAL; |
return ipc_share_out_start( phone, packet, PROTO_READ | PROTO_WRITE ); |
} |
int packet_receive( packet_ref packet ){ |
ERROR_DECLARE; |
ipc_callid_t callid; |
size_t size; |
int flags; |
if( ! packet ) return EINVAL; |
if( ! ipc_share_out_receive( & callid, & size, & flags )) return EINVAL; |
* packet = ( packet_t ) as_get_mappable_page( size ); |
if( !( * packet )) return ENOMEM; |
if( ERROR_OCCURED( ipc_share_out_finalize( callid, * packet ))){ |
munmap( * packet, size ); |
return ERROR_CODE; |
} |
return EOK; |
} |
int packet_destroy( packet_t packet ){ |
if( ! packet_is_valid( packet )) return EINVAL; |
return munmap( packet, sizeof( struct packet ) + packet->length ); |
} |
size_t packet_get_data_length( packet_t packet ){ |
if( ! packet_is_valid( packet )) return 0; |
return packet->data_end - packet->data_start; |
} |
void * packet_get_data( packet_t packet ){ |
if( ! packet_is_valid( packet )) return NULL; |
return packet + packet->data_start; |
} |
/** @} |
*/ |
/branches/network/uspace/srv/net/char_map.c |
---|
31,7 → 31,6 |
*/ |
/** @file |
* A character string to integer map implementation file. |
*/ |
#include <errno.h> |
41,48 → 40,21 |
#include "char_map.h" |
/** An internal magic value for a consistency check. |
*/ |
#define CHAR_MAP_MAGIC_VALUE 0x12345611 |
/** Adds the value with the key to the map. |
* Creates new nodes to map the key. |
* @param map The character string to integer map. Input/output parameter. |
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter. |
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter. |
* @param value The integral value to be stored for the key character string. Input parameter. |
* @returns EOK on success. |
* @returns ENOMEM if there is no memory left. |
* @returns EEXIST if the key character string is already used. |
*/ |
int char_map_add_item( char_map_ref map, const char * identifier, size_t length, const int value ); |
int char_map_add_item( char_map_ref map, const char * identifier, const int value ); |
char_map_ref char_map_find_node( char_map_ref map, const char * identifier ); |
int char_map_is_valid( char_map_ref map ); |
/** Returns the node assigned to the key from the map. |
* @param map The character string to integer map. Input parameter. |
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter. |
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter. |
* @returns The node holding the integral value assigned to the key character string. |
* @returns NULL if the key is not assigned a node. |
*/ |
char_map_ref char_map_find_node( const char_map_ref map, const char * identifier, const size_t length ); |
/** Checks if the map is valid. |
* @param map The character string to integer map. Input parameter. |
* @returns TRUE if the map is valid. |
* @returns FALSE otherwise. |
*/ |
int char_map_is_valid( const char_map_ref map ); |
int char_map_add( char_map_ref map, const char * identifier, size_t length, const int value ){ |
if( char_map_is_valid( map ) && ( identifier ) && (( length ) || ( * identifier ))){ |
int char_map_add( char_map_ref map, const char * identifier, const int value ){ |
if( char_map_is_valid( map ) && ( * identifier )){ |
int index; |
for( index = 0; index < map->next; ++ index ){ |
if( map->items[ index ]->c == * identifier ){ |
++ identifier; |
if( length ) -- length; |
if( length || ( * identifier )){ |
return char_map_add( map->items[ index ], identifier, length, value ); |
if( * identifier ){ |
return char_map_add( map->items[ index ], identifier, value ); |
}else{ |
if( map->items[ index ]->value != CHAR_MAP_NULL ) return EEXISTS; |
map->items[ index ]->value = value; |
90,12 → 62,12 |
} |
} |
} |
return char_map_add_item( map, identifier, length, value ); |
return char_map_add_item( map, identifier, value ); |
} |
return EINVAL; |
} |
int char_map_add_item( char_map_ref map, const char * identifier, size_t length, const int value ){ |
int char_map_add_item( char_map_ref map, const char * identifier, const int value ){ |
if( map->next == ( map->size - 1 )){ |
char_map_ref * tmp; |
111,14 → 83,13 |
char_map_initialize( map->items[ map->next ] ); |
map->items[ map->next ]->c = * identifier; |
++ identifier; |
if( length ) -- length; |
++ map->next; |
if( length || ( * identifier )){ |
map->items[ map->next - 1 ]->value = CHAR_MAP_NULL; |
return char_map_add_item( map->items[ map->next - 1 ], identifier, length, value ); |
if( * identifier ){ |
map->items[ map->next ]->value = CHAR_MAP_NULL; |
char_map_add_item( map->items[ map->next ], identifier, value ); |
}else{ |
map->items[ map->next - 1 ]->value = value; |
map->items[ map->next ]->value = value; |
} |
++ map->next; |
return EOK; |
} |
134,10 → 105,10 |
} |
} |
int char_map_exclude( char_map_ref map, const char * identifier, size_t length ){ |
int char_map_exclude( char_map_ref map, const char * identifier ){ |
char_map_ref node; |
node = char_map_find_node( map, identifier, length ); |
node = char_map_find_node( map, identifier ); |
if( node ){ |
int value; |
148,23 → 119,22 |
return CHAR_MAP_NULL; |
} |
int char_map_find( const char_map_ref map, const char * identifier, size_t length ){ |
int char_map_find( char_map_ref map, const char * identifier ){ |
char_map_ref node; |
node = char_map_find_node( map, identifier, length ); |
node = char_map_find_node( map, identifier ); |
return node ? node->value : CHAR_MAP_NULL; |
} |
char_map_ref char_map_find_node( const char_map_ref map, const char * identifier, size_t length ){ |
char_map_ref char_map_find_node( char_map_ref map, const char * identifier ){ |
if( ! char_map_is_valid( map )) return NULL; |
if( length ) -- length; |
if( length || ( * identifier )){ |
if( * identifier ){ |
int index; |
for( index = 0; index < map->next; ++ index ){ |
if( map->items[ index ]->c == * identifier ){ |
++ identifier; |
return char_map_find_node( map->items[ index ], identifier, length ); |
return char_map_find_node( map->items[ index ], identifier ); |
} |
} |
return NULL; |
172,7 → 142,7 |
return map; |
} |
int char_map_get_value( const char_map_ref map ){ |
int char_map_get_value( char_map_ref map ){ |
return char_map_is_valid( map ) ? map->value : CHAR_MAP_NULL; |
} |
189,20 → 159,20 |
return EOK; |
} |
int char_map_is_valid( const char_map_ref map ){ |
int char_map_is_valid( char_map_ref map ){ |
return map && ( map->magic == CHAR_MAP_MAGIC_VALUE ); |
} |
int char_map_update( char_map_ref map, const char * identifier, const size_t length, const int value ){ |
int char_map_update( char_map_ref map, const char * identifier, const int value ){ |
char_map_ref node; |
// if( ! char_map_is_valid( map )) return EINVAL; |
node = char_map_find_node( map, identifier, length ); |
node = char_map_find_node( map, identifier ); |
if( node ){ |
node->value = value; |
return EOK; |
}else{ |
return char_map_add( map, identifier, length, value ); |
return char_map_add( map, identifier, value ); |
} |
} |
/branches/network/uspace/srv/net/generic_char_map.h |
---|
57,28 → 57,28 |
int magic; \ |
}; \ |
\ |
int name##_add( name##_ref map, const char * name, const size_t length, type * value ); \ |
int name##_add( name##_ref map, const char * name, type * value ); \ |
int name##_count( name##_ref map ); \ |
void name##_destroy( name##_ref map ); \ |
void name##_exclude( name##_ref map, const char * name, const size_t length ); \ |
type * name##_find( name##_ref map, const char * name, const size_t length ); \ |
void name##_exclude( name##_ref map, const char * name ); \ |
type * name##_find( name##_ref map, const char * name ); \ |
type * name##_get_index( name##_ref map, int index ); \ |
int name##_initialize( name##_ref map ); \ |
int name##_is_valid( name##_ref map ); |
#define GENERIC_CHAR_MAP_IMPLEMENT( name, type ) \ |
\ |
GENERIC_FIELD_IMPLEMENT( name##_items, type ) \ |
\ |
int name##_add( name##_ref map, const char * name, const size_t length, type * value ){ \ |
int name##_add( name##_ref map, const char * name, type * value ){ \ |
ERROR_DECLARE; \ |
\ |
int index; \ |
\ |
if( ! name##_is_valid( map )) return EINVAL; \ |
index = name##_items_add( & map->values, value ); \ |
if( index < 0 ) return index; \ |
if( ERROR_OCCURED( char_map_add( & map->names, name, length, index ))){ \ |
if( ERROR_OCCURED( char_map_add( & map->names, name, index ))){ \ |
name##_items_exclude_index( & map->values, index ); \ |
return ERROR_CODE; \ |
} \ |
96,11 → 96,11 |
} \ |
} \ |
\ |
void name##_exclude( name##_ref map, const char * name, const size_t length ){ \ |
void name##_exclude( name##_ref map, const char * name ){ \ |
if( name##_is_valid( map )){ \ |
int index; \ |
\ |
index = char_map_exclude( & map->names, name, length ); \ |
index = char_map_exclude( & map->names, name ); \ |
if( index != CHAR_MAP_NULL ){ \ |
name##_items_exclude_index( & map->values, index ); \ |
} \ |
107,11 → 107,11 |
} \ |
} \ |
\ |
type * name##_find( name##_ref map, const char * name, const size_t length ){ \ |
type * name##_find( name##_ref map, const char * name ){ \ |
if( name##_is_valid( map )){ \ |
int index; \ |
\ |
index = char_map_find( & map->names, name, length ); \ |
index = char_map_find( & map->names, name ); \ |
if( index != CHAR_MAP_NULL ){ \ |
return name##_items_get_index( & map->values, index ); \ |
} \ |
/branches/network/uspace/srv/net/configuration.h |
---|
31,44 → 31,16 |
*/ |
/** @file |
* A networking subsystem compilation configuration file. |
*/ |
#ifndef __NET_CONFIGURATION_H__ |
#define __NET_CONFIGURATION_H__ |
/** An option to activate the self test. |
*/ |
#define NET_SELF_TEST 0 |
/** An option to activate the measured strings self test. |
* The option NET_SELF_TEST has to be activated. |
* @see measured_strings.h |
*/ |
#define NET_SELF_TEST_MEASURED_STRINGS 1 |
/** An option to activate the char map self test. |
* The option NET_SELF_TEST has to be activated. |
* @see char_map.h |
*/ |
#define NET_SELF_TEST_CHAR_MAP 0 |
/** An option to activate the integral map self test. |
* The option NET_SELF_TEST has to be activated. |
* @see int_map.h |
*/ |
#define NET_SELF_TEST_INT_MAP 0 |
/** An option to activate the generic field self test. |
* The option NET_SELF_TEST has to be activated. |
* @see generic_field.h |
*/ |
#define NET_SELF_TEST_GENERIC_FIELD 0 |
/** An option to activate the generic char map self test. |
* The option NET_SELF_TEST has to be activated. |
* @see generic_char_map.h |
*/ |
#define NET_SELF_TEST_GENERIC_CHAR_MAP 0 |
#endif |
/branches/network/uspace/srv/net/packet.h |
---|
33,30 → 33,7 |
/** @file |
*/ |
#ifndef __NET_PACKET_H__ |
#define __NET_PACKET_H__ |
#define PACKET_PREPEND( packet, type ) ( type * ) packet_prepend(( packet ), sizeof( type )) |
#define PACKET_APPEND( packet, type ) ( type * ) packet_append(( packet ), sizeof( type )) |
#define PACKET_TRIM( packet, prefix, sufix ) packet_trim(( packet ), sizeof( prefix ), sizeof( sufix )) |
typedef struct packet * packet_t; |
typedef packet_t * packet_ref; |
packet_t packet_create( size_t max_prefix, size_t max_content, size_t max_sufix ); |
void * packet_prepend( packet_t packet, size_t length ); |
void * packet_append( packet_t packet, size_t length ); |
packet_t packet_copy( packet_t packet ); |
int packet_copy_data( packet_t packet, void * data, size_t length ); |
// TODO protocol identification? |
int packet_send( packet_t packet, int phone ); |
int packet_receive( packet_ref packet ); |
int packet_trim( packet_t packet, size_t prefix, size_t sufix ); |
int packet_destroy( packet_t packet ); |
size_t packet_get_data_length( packet_t packet ); |
void * packet_get_data( packet_t packet ); |
#endif |
/** @} |
*/ |
/branches/network/uspace/srv/net/modules.h |
---|
33,22 → 33,13 |
/** @file |
*/ |
#include <async.h> |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
/** Converts the data length between different types. |
* @param type_from The source type. Input parameter. |
* @param type_to The destination type. Input parameter. |
* @param count The number units of the source type size. Input parameter. |
*/ |
#define CONVERT_SIZE( type_from, type_to, count ) (( sizeof( type_from ) / sizeof( type_to )) * ( count )) |
#define REGISTER_ME( me, phonehash ) ipc_connect_to_me( PHONE_NS, ( me ), 0, 0, ( phonehash )) |
int connect_to_service( services_t need ); |
int bind_service( services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver ); |
int start_service( services_t me, services_t need[], int * need_phone[], void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall ), int ( * initialize_me )( void )); |
/** @} |
*/ |
/branches/network/uspace/srv/net/char_map.h |
---|
31,124 → 31,33 |
*/ |
/** @file |
* A character string to integer map header file. |
*/ |
#ifndef __CHAR_MAP_H__ |
#define __CHAR_MAP_H__ |
/** An invalid assigned value used also if an entry does not exist. |
*/ |
#define CHAR_MAP_NULL ( -1 ) |
/** A type definition of a character string to integer map. |
* @see char_map |
*/ |
typedef struct char_map char_map_t; |
/** A type definition of a character string to integer map pointer. |
* @see char_map |
*/ |
typedef char_map_t * char_map_ref; |
/** A character string to integer map item. |
* This structure recursivelly contains itself as a character by character tree. |
* The actually mapped character string consists o fall the parent characters and the actual one. |
*/ |
struct char_map{ |
/** An actually mapped character. |
*/ |
char c; |
/** A stored integral value. |
*/ |
int value; |
/** A next character array size. |
*/ |
int size; |
/** The first free position in the next character array. |
*/ |
int next; |
/** The next character array. |
*/ |
char_map_ref * items; |
/** The consistency check magic value. |
*/ |
int magic; |
}; |
/** Adds the value with the key to the map. |
* @param map The character string to integer map. Input/output parameter. |
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter. |
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter. |
* @param value The integral value to be stored for the key character string. Input parameter. |
* @returns EOK on success. |
* @returns EINVAL if the map is not valid. |
* @returns EINVAL if the identifier parameter is NULL. |
* @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\0) character. |
* @returns EEXIST if the key character string is already used. |
* @returns Other error codes as defined for the char_map_add_item() function. |
*/ |
int char_map_add( char_map_ref map, const char * identifier, size_t length, const int value ); |
/** Clears and destroys the map. |
* @param map The character string to integer map. Input/output parameter. |
*/ |
int char_map_add( char_map_ref map, const char * identifier, const int value ); |
void char_map_destroy( char_map_ref map ); |
/** Excludes the value assigned to the key from the map. |
* The entry is cleared from the map. |
* @param map The character string to integer map. Input/output parameter. |
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter. |
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter. |
* @returns The integral value assigned to the key character string. |
* @returns CHAR_MAP_NULL if the key is not assigned a value. |
*/ |
int char_map_exclude( char_map_ref map, const char * identifier, size_t length ); |
/** Returns the value assigned to the key from the map. |
* @param map The character string to integer map. Input parameter. |
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter. |
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter. |
* @returns The integral value assigned to the key character string. |
* @returns CHAR_MAP_NULL if the key is not assigned a value. |
*/ |
int char_map_find( const char_map_ref map, const char * identifier, size_t length ); |
/** Returns the value assigned to the map. |
* @param map The character string to integer map. Input parameter. |
* @returns The integral value assigned to the map. |
* @returns CHAR_MAP_NULL if the map is not assigned a value. |
*/ |
int char_map_get_value( const char_map_ref map ); |
/** Initializes the map. |
* @param map The character string to integer map. Input/output parameter. |
* @returns EOK on success. |
* @returns EINVAL if the map parameter is NULL. |
* @returns ENOMEM if there is no memory left. |
*/ |
int char_map_exclude( char_map_ref map, const char * identifier ); |
int char_map_find( char_map_ref map, const char * identifier ); |
int char_map_get_value( char_map_ref map ); |
int char_map_initialize( char_map_ref map ); |
int char_map_update( char_map_ref map, const char * identifier, const int value ); |
/** Adds or updates the value with the key to the map. |
* @param map The character string to integer map. Input/output parameter. |
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter. |
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter. |
* @param value The integral value to be stored for the key character string. Input parameter. |
* @returns EOK on success. |
* @returns EINVAL if the map is not valid. |
* @returns EINVAL if the identifier parameter is NULL. |
* @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\0) character. |
* @returns EEXIST if the key character string is already used. |
* @returns Other error codes as defined for the char_map_add_item() function. |
*/ |
int char_map_update( char_map_ref map, const char * identifier, size_t length, const int value ); |
#endif |
/** @} |
/branches/network/uspace/srv/net/module.c |
---|
36,14 → 36,15 |
#include <async.h> |
#include <stdio.h> |
#include <task.h> |
#include <ipc/ipc.h> |
#include "err.h" |
#include "modules.h" |
extern int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ); |
extern int module_call( ipc_callid_t callid ); |
extern int module_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 ); |
extern void module_print_name( void ); |
extern int module_start( async_client_conn_t client_connection ); |
extern int module_start( void ( * client_connection )( ipc_callid_t iid, ipc_call_t * icall )); |
void client_connection( ipc_callid_t iid, ipc_call_t * icall ); |
int main( int argc, char * argv[] ); |
53,45 → 54,22 |
void client_connection( ipc_callid_t iid, ipc_call_t * icall ){ |
ipc_callid_t callid; |
ipc_call_t call; |
ipc_call_t answer; |
int count; |
ipcarg_t arg1, arg2, arg3; |
int res; |
/* |
* Accept the connection |
* - Answer the first IPC_M_CONNECT_ME_TO call. |
*/ |
/* Accept the connection */ |
ipc_answer_0( iid, EOK ); |
while( true ){ |
// refresh data |
count = 0; |
IPC_SET_RETVAL( answer, 0 ); |
// just to be precize |
IPC_SET_RETVAL( answer, 0 ); |
IPC_SET_ARG1( answer, 0 ); |
IPC_SET_ARG2( answer, 0 ); |
IPC_SET_ARG3( answer, 0 ); |
IPC_SET_ARG4( answer, 0 ); |
IPC_SET_ARG5( answer, 0 ); |
callid = async_get_call( & call ); |
res = module_message( callid, & call, & answer, & count ); |
switch( count ){ |
case 0: ipc_answer_0( callid, res ); |
continue; |
case 1: ipc_answer_1( callid, res, IPC_GET_ARG1( answer )); |
continue; |
case 2: ipc_answer_2( callid, res, IPC_GET_ARG1( answer ), IPC_GET_ARG2( answer )); |
continue; |
case 3: ipc_answer_3( callid, res, IPC_GET_ARG1( answer ), IPC_GET_ARG2( answer ), IPC_GET_ARG3( answer )); |
continue; |
case 4: ipc_answer_4( callid, res, IPC_GET_ARG1( answer ), IPC_GET_ARG2( answer ), IPC_GET_ARG3( answer ), IPC_GET_ARG4( answer )); |
continue; |
default: ipc_answer_5( callid, res, IPC_GET_ARG1( answer ), IPC_GET_ARG2( answer ), IPC_GET_ARG3( answer ), IPC_GET_ARG4( answer ), IPC_GET_ARG5( answer )); |
continue; |
arg1 = 0; |
arg2 = 0; |
arg3 = 0; |
res = module_call( callid ); |
if( res == EOK ){ |
res = module_message( callid, IPC_GET_METHOD( call ), IPC_GET_ARG1( call ), IPC_GET_ARG2( call ), IPC_GET_ARG3( call ), & arg1, & arg2, & arg3 ); |
} |
ipc_answer_2( callid, res, arg1, arg2 ); |
} |
} |
/branches/network/uspace/srv/net/self_test.c |
---|
97,39 → 97,39 |
char_map_t cm; |
printf( "\nChar map test" ); |
TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 0, 3 ), EINVAL ); |
TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 3 ), EINVAL ); |
TEST( "initialize", char_map_initialize( & cm ), EOK ); |
TEST( "get_value", char_map_get_value( & cm ), CHAR_MAP_NULL ); |
TEST( "exclude bla null", char_map_exclude( & cm, "bla", 0 ), CHAR_MAP_NULL ); |
TEST( "find bla null", char_map_find( & cm, "bla", 0 ), CHAR_MAP_NULL ); |
TEST( "add bla 1 eok", char_map_add( & cm, "bla", 0, 1 ), EOK ); |
TEST( "find bla 1", char_map_find( & cm, "bla", 0 ), 1 ); |
TEST( "add bla 10 eexists", char_map_add( & cm, "bla", 0, 10 ), EEXISTS ); |
TEST( "update bla 2 eok", char_map_update( & cm, "bla", 0, 2 ), EOK ); |
TEST( "find bla 2", char_map_find( & cm, "bla", 0 ), 2 ); |
TEST( "update ucho 2 eok", char_map_update( & cm, "ucho", 0, 2 ), EOK ); |
TEST( "exclude bla 2", char_map_exclude( & cm, "bla", 0 ), 2 ); |
TEST( "exclude bla null", char_map_exclude( & cm, "bla", 0 ), CHAR_MAP_NULL ); |
TEST( "find ucho 2", char_map_find( & cm, "ucho", 0 ), 2 ); |
TEST( "update ucho 3 eok", char_map_update( & cm, "ucho", 0, 3 ), EOK ); |
TEST( "find ucho 3", char_map_find( & cm, "ucho", 0 ), 3 ); |
TEST( "add blabla 5 eok", char_map_add( & cm, "blabla", 0, 5 ), EOK ); |
TEST( "find blabla 5", char_map_find( & cm, "blabla", 0 ), 5 ); |
TEST( "add bla 6 eok", char_map_add( & cm, "bla", 0, 6 ), EOK ); |
TEST( "find bla 6", char_map_find( & cm, "bla", 0 ), 6 ); |
TEST( "exclude bla 6", char_map_exclude( & cm, "bla", 0 ), 6 ); |
TEST( "find bla null", char_map_find( & cm, "bla", 0 ), CHAR_MAP_NULL ); |
TEST( "find blabla 5", char_map_find( & cm, "blabla", 0 ), 5 ); |
TEST( "add auto 7 eok", char_map_add( & cm, "auto", 0, 7 ), EOK ); |
TEST( "find auto 7", char_map_find( & cm, "auto", 0 ), 7 ); |
TEST( "add kara 8 eok", char_map_add( & cm, "kara", 0, 8 ), EOK ); |
TEST( "find kara 8", char_map_find( & cm, "kara", 0 ), 8 ); |
TEST( "add nic 9 eok", char_map_add( & cm, "nic", 0, 9 ), EOK ); |
TEST( "find nic 9", char_map_find( & cm, "nic", 0 ), 9 ); |
TEST( "find blabla 5", char_map_find( & cm, "blabla", 0 ), 5 ); |
TEST( "exclude bla null", char_map_exclude( & cm, "bla" ), CHAR_MAP_NULL ); |
TEST( "find bla null", char_map_find( & cm, "bla" ), CHAR_MAP_NULL ); |
TEST( "add bla 1 eok", char_map_add( & cm, "bla", 1 ), EOK ); |
TEST( "find bla 1", char_map_find( & cm, "bla" ), 1 ); |
TEST( "add bla 10 eexists", char_map_add( & cm, "bla", 10 ), EEXISTS ); |
TEST( "update bla 2 eok", char_map_update( & cm, "bla", 2 ), EOK ); |
TEST( "find bla 2", char_map_find( & cm, "bla" ), 2 ); |
TEST( "update ucho 2 eok", char_map_update( & cm, "ucho", 2 ), EOK ); |
TEST( "exclude bla 2", char_map_exclude( & cm, "bla" ), 2 ); |
TEST( "exclude bla null", char_map_exclude( & cm, "bla" ), CHAR_MAP_NULL ); |
TEST( "find ucho 2", char_map_find( & cm, "ucho" ), 2 ); |
TEST( "update ucho 3 eok", char_map_update( & cm, "ucho", 3 ), EOK ); |
TEST( "find ucho 3", char_map_find( & cm, "ucho" ), 3 ); |
TEST( "add blabla 5 eok", char_map_add( & cm, "blabla", 5 ), EOK ); |
TEST( "find blabla 5", char_map_find( & cm, "blabla" ), 5 ); |
TEST( "add bla 6 eok", char_map_add( & cm, "bla", 6 ), EOK ); |
TEST( "find bla 6", char_map_find( & cm, "bla" ), 6 ); |
TEST( "exclude bla 6", char_map_exclude( & cm, "bla" ), 6 ); |
TEST( "find bla null", char_map_find( & cm, "bla" ), CHAR_MAP_NULL ); |
TEST( "find blabla 5", char_map_find( & cm, "blabla" ), 5 ); |
TEST( "add auto 7 eok", char_map_add( & cm, "auto", 7 ), EOK ); |
TEST( "find auto 7", char_map_find( & cm, "auto" ), 7 ); |
TEST( "add kara 8 eok", char_map_add( & cm, "kara", 8 ), EOK ); |
TEST( "find kara 8", char_map_find( & cm, "kara" ), 8 ); |
TEST( "add nic 9 eok", char_map_add( & cm, "nic", 9 ), EOK ); |
TEST( "find nic 9", char_map_find( & cm, "nic" ), 9 ); |
TEST( "find blabla 5", char_map_find( & cm, "blabla" ), 5 ); |
printf( "\n\tdestroy" ); |
char_map_destroy( & cm ); |
TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 0, 3 ), EINVAL ); |
TEST( "update ucho 3 einval", char_map_update( & cm, "ucho", 3 ), EINVAL ); |
printf( "\nOK" ); |
#endif |
250,31 → 250,31 |
icm.magic = 0; |
printf( "\nGeneric char map test" ); |
TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", 0, z ), EINVAL ); |
TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", z ), EINVAL ); |
TEST( "initialize", int_char_map_initialize( & icm ), EOK ); |
printf( "\n\texclude bla null" ); |
int_char_map_exclude( & icm, "bla", 0 ); |
TEST( "find bla null", int_char_map_find( & icm, "bla", 0 ), NULL ); |
TEST( "add bla x eok", int_char_map_add( & icm, "bla", 0, x ), EOK ); |
TEST( "find bla x", int_char_map_find( & icm, "bla", 0 ), x ); |
TEST( "add bla y eexists", int_char_map_add( & icm, "bla", 0, y ), EEXISTS ); |
int_char_map_exclude( & icm, "bla" ); |
TEST( "find bla null", int_char_map_find( & icm, "bla" ), NULL ); |
TEST( "add bla x eok", int_char_map_add( & icm, "bla", x ), EOK ); |
TEST( "find bla x", int_char_map_find( & icm, "bla" ), x ); |
TEST( "add bla y eexists", int_char_map_add( & icm, "bla", y ), EEXISTS ); |
printf( "\n\texclude bla y" ); |
int_char_map_exclude( & icm, "bla", 0 ); |
int_char_map_exclude( & icm, "bla" ); |
printf( "\n\texclude bla null" ); |
int_char_map_exclude( & icm, "bla", 0 ); |
TEST( "add blabla v eok", int_char_map_add( & icm, "blabla", 0, v ), EOK ); |
TEST( "find blabla v", int_char_map_find( & icm, "blabla", 0 ), v ); |
TEST( "add bla w eok", int_char_map_add( & icm, "bla", 0, w ), EOK ); |
TEST( "find bla w", int_char_map_find( & icm, "bla", 0 ), w ); |
int_char_map_exclude( & icm, "bla" ); |
TEST( "add blabla v eok", int_char_map_add( & icm, "blabla", v ), EOK ); |
TEST( "find blabla v", int_char_map_find( & icm, "blabla" ), v ); |
TEST( "add bla w eok", int_char_map_add( & icm, "bla", w ), EOK ); |
TEST( "find bla w", int_char_map_find( & icm, "bla" ), w ); |
printf( "\n\texclude bla" ); |
int_char_map_exclude( & icm, "bla", 0 ); |
TEST( "find bla null", int_char_map_find( & icm, "bla", 0 ), NULL ); |
TEST( "find blabla v", int_char_map_find( & icm, "blabla", 0 ), v ); |
TEST( "add auto u eok", int_char_map_add( & icm, "auto", 0, u ), EOK ); |
TEST( "find auto u", int_char_map_find( & icm, "auto", 0 ), u ); |
int_char_map_exclude( & icm, "bla" ); |
TEST( "find bla null", int_char_map_find( & icm, "bla" ), NULL ); |
TEST( "find blabla v", int_char_map_find( & icm, "blabla" ), v ); |
TEST( "add auto u eok", int_char_map_add( & icm, "auto", u ), EOK ); |
TEST( "find auto u", int_char_map_find( & icm, "auto" ), u ); |
printf( "\n\tdestroy" ); |
int_char_map_destroy( & icm ); |
TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", 0, z ), EINVAL ); |
TEST( "add ucho z einval", int_char_map_add( & icm, "ucho", z ), EINVAL ); |
printf( "\nOK" ); |
#endif |
/branches/network/uspace/srv/net/int_map.h |
---|
65,7 → 65,6 |
}; \ |
\ |
int name##_add( name##_ref map, int key, type * value ); \ |
void name##_clear( name##_ref map ); \ |
int name##_count( name##_ref map ); \ |
void name##_destroy( name##_ref map ); \ |
void name##_exclude( name##_ref map, int key ); \ |
101,22 → 100,6 |
return EINVAL; \ |
} \ |
\ |
void name##_clear( name##_ref map ){ \ |
if( name##_is_valid( map )){ \ |
int index; \ |
\ |
/* map->magic = 0;*/ \ |
for( index = 0; index < map->next; ++ index ){ \ |
if( name##_item_is_valid( &( map->items[ index ] ))){ \ |
name##_item_destroy( &( map->items[ index ] )); \ |
} \ |
} \ |
map->next = 0; \ |
map->items[ map->next ].magic = 0; \ |
/* map->magic = INT_MAP_MAGIC_VALUE;*/ \ |
} \ |
} \ |
\ |
int name##_count( name##_ref map ){ \ |
return name##_is_valid( map ) ? map->next : -1; \ |
} \ |
/branches/network/uspace/srv/net/err.h |
---|
31,7 → 31,6 |
*/ |
/** @file |
* Common error processing codes and routines. |
*/ |
#ifndef __NET_ERR_H__ |
39,25 → 38,9 |
#include <errno.h> |
/** An actual stored error code. |
*/ |
#define ERROR_CODE error_check_return_value |
/** An error processing routines declaration. |
* This has to be declared in the block where the error processing is desired. |
*/ |
#define ERROR_DECLARE int ERROR_CODE |
/** Stores the value as an error code and checks if an error occured. |
* @param value The value to be checked. May be a function call. Input parameter. |
* @returns FALSE if the value indicates success (EOK). |
* @returns TRUE otherwise. |
*/ |
#define ERROR_OCCURED( value ) (( ERROR_CODE = ( value )) != EOK ) |
/** Checks if an error occured and immediatelly exits the actual function returning the error code. |
* @param value The value to be checked. May be a function call. Input parameter. |
*/ |
#define ERROR_PROPAGATE( value ) if( ERROR_OCCURED( value )) return ERROR_CODE |
#endif |
/branches/network/uspace/srv/net/arp/arp.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/arp/arp_module.c |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/arp/arp_module.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/arp/arp.c |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/arp/arp_header.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/arp/Makefile |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
/branches/network/uspace/srv/net/arp/arp_oc.h |
---|
File deleted |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |