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 );
}
}
 
/** @}
*/