Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4350 → Rev 4351

/branches/network/uspace/srv/net/il/arp/arp.c
139,12 → 139,6
*/
void clear_device( arp_device_ref device );
 
/** Processes IPC messages from the registered device driver modules in an infinite loop.
* @param iid The message identifier. Input parameter.
* @param icall The message parameters. Input/output parameter.
*/
void arp_receiver( ipc_callid_t iid, ipc_call_t * icall );
 
DEVICE_MAP_IMPLEMENT( arp_cache, arp_device_t )
 
INT_MAP_IMPLEMENT( arp_protos, arp_proto_t )
222,11 → 216,12
}
}
 
int arp_initialize( void ){
int arp_initialize( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
rwlock_initialize( & arp_globals.lock );
rwlock_write_lock( & arp_globals.lock );
arp_globals.client_connection = client_connection;
ERROR_PROPAGATE( arp_cache_initialize( & arp_globals.cache ));
rwlock_write_unlock( & arp_globals.lock );
return EOK;
308,7 → 303,7
}
device->service = service;
// bind the new one
device->phone = bind_service( device->service, device->device_id, SERVICE_ARP, 0, arp_receiver );
device->phone = bind_service( device->service, device->device_id, SERVICE_ARP, 0, arp_globals.client_connection );
if( device->phone < 0 ){
rwlock_write_unlock( & arp_globals.lock );
arp_protos_destroy( & device->protos );
480,6 → 475,7
measured_string_ref address;
measured_string_ref translation;
char * data;
packet_t packet;
 
// printf( "message %d - %d\n", IPC_GET_METHOD( * call ), NET_ARP_FIRST );
* answer_count = 0;
510,35 → 506,19
return arp_clear_device_req( 0, IPC_GET_DEVICE( call ));
case NET_ARP_CLEAN_CACHE:
return arp_clean_cache_req( 0 );
case NET_IL_DEVICE_STATE:
// do nothing - keep the cache
return EOK;
case NET_IL_RECEIVED:
if( ! ERROR_OCCURRED( packet_translate( arp_globals.net_phone, & packet, IPC_GET_PACKET( call )))){
rwlock_read_lock( & arp_globals.lock );
ERROR_CODE = arp_receive_message( IPC_GET_DEVICE( call ), packet );
rwlock_read_unlock( & arp_globals.lock );
}
return ERROR_CODE;
}
return ENOTSUP;
}
 
void arp_receiver( ipc_callid_t iid, ipc_call_t * icall ){
ERROR_DECLARE;
 
packet_t packet;
 
while( true ){
switch( IPC_GET_METHOD( * icall )){
case NET_IL_DEVICE_STATE:
// do nothing - keep the cache
ipc_answer_0( iid, EOK );
break;
case NET_IL_RECEIVED:
if( ! ERROR_OCCURRED( packet_translate( arp_globals.net_phone, & packet, IPC_GET_PACKET( icall )))){
rwlock_read_lock( & arp_globals.lock );
ERROR_CODE = arp_receive_message( IPC_GET_DEVICE( icall ), packet );
rwlock_read_unlock( & arp_globals.lock );
}
ipc_answer_0( iid, ERROR_CODE );
break;
default:
ipc_answer_0( iid, ENOTSUP );
}
iid = async_get_call( icall );
}
}
 
/** @}
*/
/branches/network/uspace/srv/net/il/arp/arp.h
167,6 → 167,10
/** ARP address cache.
*/
arp_cache_t cache;
/** The client connection processing function.
* The module skeleton propagates its own one.
*/
async_client_conn_t client_connection;
};
 
#endif
/branches/network/uspace/srv/net/il/arp/arp_module.c
97,7 → 97,7
async_set_client_connection( client_connection );
arp_globals.net_phone = net_connect_module( SERVICE_NETWORKING );
ERROR_PROPAGATE( pm_init());
if( ERROR_OCCURRED( arp_initialize())
if( ERROR_OCCURRED( arp_initialize( client_connection ))
|| ERROR_OCCURRED( REGISTER_ME( SERVICE_ARP, & phonehash ))){
pm_destroy();
return ERROR_CODE;
/branches/network/uspace/srv/net/il/arp/arp_module.h
41,10 → 41,11
#include <ipc/ipc.h>
 
/** Initializes the ARP module.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
int arp_initialize( void );
int arp_initialize( async_client_conn_t client_connection );
 
/** Processes the ARP message.
* @param callid The message identifier. Input parameter.
/branches/network/uspace/srv/net/il/ip/ip_module.h
38,7 → 38,7
 
#include <ipc/ipc.h>
 
int ip_initialize( void );
int ip_initialize( async_client_conn_t client_connection );
int ip_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
 
#endif
/branches/network/uspace/srv/net/il/ip/ip.c
75,17 → 75,17
 
INT_MAP_IMPLEMENT( ip_protos, ip_proto_t )
 
void ip_driver_receiver( ipc_callid_t iid, ipc_call_t * icall );
int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state );
int ip_register( int il_phone, int protocol, int phone );
 
/** Initializes the module.
*/
int ip_initialize( void ){
int ip_initialize( async_client_conn_t client_connection ){
ERROR_DECLARE;
 
ERROR_PROPAGATE( ip_netifs_initialize( & ip_globals.netifs ));
ERROR_PROPAGATE( ip_protos_initialize( & ip_globals.protos ));
ip_globals.client_connection = client_connection;
ERROR_PROPAGATE( modules_initialize( & ip_globals.modules ));
ERROR_PROPAGATE( add_module( NULL, & ip_globals.modules, ARP_NAME, ARP_FILENAME, SERVICE_ARP, arp_task_get_id(), arp_connect_module ));
return EOK;
149,7 → 149,7
}
net_free_settings( configuration, data );
}
ip_netif->phone = bind_service( netif, ip_netif->device_id, SERVICE_IP, 0, ip_driver_receiver );
ip_netif->phone = bind_service( netif, ip_netif->device_id, SERVICE_IP, 0, ip_globals.client_connection );
if( ip_netif->phone < 0 ){
printf( "Failed to contact the nil service %d\n", netif );
free( ip_netif );
192,53 → 192,6
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_device_state_msg( 0, IPC_GET_DEVICE( & call ), IPC_GET_STATE( & call ));
ipc_answer_0( callid, result );
break;
// TODO packer received
case NET_IL_RECEIVED:
case NET_NIL_RECEIVED:
if( ! ERROR_OCCURRED( result = packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( & call )))){
//result = il_receive_msg( 0, IPC_GET_DEVICE( call ), packet );
}
ipc_answer_0( callid, result );
break;
}
}
}
 
int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ){
// ERROR_DECLARE;
 
315,6 → 268,14
case NET_IL_SEND:
ERROR_PROPAGATE( packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( call )));
return ip_send_msg( 0, IPC_GET_DEVICE( call ), packet, 0 );
case NET_IL_DEVICE_STATE:
case NET_NIL_DEVICE_STATE:
return ip_device_state_msg( 0, IPC_GET_DEVICE( call ), IPC_GET_STATE( call ));
// TODO packet received
case NET_IL_RECEIVED:
case NET_NIL_RECEIVED:
ERROR_PROPAGATE( packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( call )));
//return il_receive_msg( 0, IPC_GET_DEVICE( call ), packet );
}
return ENOTSUP;
}
/branches/network/uspace/srv/net/il/ip/ip.h
81,6 → 81,7
ip_netifs_t netifs;
ip_protos_t protos;
modules_t modules;
async_client_conn_t client_connection;
};
 
#endif
/branches/network/uspace/srv/net/il/ip/ip_module.c
69,7 → 69,7
async_set_client_connection( client_connection );
ip_globals.net_phone = net_connect_module( SERVICE_NETWORKING );
ERROR_PROPAGATE( pm_init());
if( ERROR_OCCURRED( ip_initialize())
if( ERROR_OCCURRED( ip_initialize( client_connection ))
|| ERROR_OCCURRED( REGISTER_ME( SERVICE_IP, & phonehash ))){
pm_destroy();
return ERROR_CODE;