50,28 → 50,20 |
#include "../structures/measured_strings.h" |
|
#include "../include/device.h" |
#include "../include/netif_messages.h" |
#include "../include/nil_messages.h" |
#include "../include/netif_interface.h" |
#include "../include/nil_interface.h" |
|
#include "netif.h" |
#include "netif_interface.h" |
#include "netif_wrappers.h" |
#include "netif_messages.h" |
#include "netif_module.h" |
|
#if NIL_BUNDLE |
|
#include "../nil/nil_module.h" |
|
#endif |
|
extern netif_globals_t netif_globals; |
|
DEVICE_MAP_IMPLEMENT( device_map, 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 netif_probe_wrapper( device_id_t device_id, int irq, int io ){ |
int netif_probe_req( int netif_phone, device_id_t device_id, int irq, int io ){ |
int result; |
|
rwlock_write_lock( & netif_globals.lock ); |
80,7 → 72,7 |
return result; |
} |
|
int netif_send_wrapper( device_id_t device_id, packet_t packet, services_t sender ){ |
int netif_send_msg( int netif_phone, device_id_t device_id, packet_t packet, services_t sender ){ |
int result; |
|
rwlock_write_lock( & netif_globals.lock ); |
89,7 → 81,7 |
return result; |
} |
|
int netif_start_wrapper( device_id_t device_id ){ |
int netif_start_req( int netif_phone, device_id_t device_id ){ |
ERROR_DECLARE; |
|
device_ref device; |
113,7 → 105,7 |
return result; |
} |
|
int netif_stop_wrapper( device_id_t device_id ){ |
int netif_stop_req( int netif_phone, device_id_t device_id ){ |
ERROR_DECLARE; |
|
device_ref device; |
137,7 → 129,7 |
return result; |
} |
|
int netif_get_addr_wrapper( device_id_t device_id, measured_string_ref * address, char ** data ){ |
int netif_get_addr( int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data ){ |
ERROR_DECLARE; |
|
measured_string_t translation; |
149,9 → 141,14 |
ERROR_CODE = ( * address ) ? EOK : ENOMEM; |
} |
rwlock_read_unlock( & netif_globals.lock ); |
* data = ( ** address ).value; |
return ERROR_CODE; |
} |
|
int netif_bind_service( services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver ){ |
return EOK; |
} |
|
int find_device( device_id_t device_id, device_ref * device ){ |
if( ! device ) return EBADMEM; |
* device = device_map_find( & netif_globals.device_map, device_id ); |
172,7 → 169,7 |
ERROR_PROPAGATE( find_device( device_id, & device )); |
if( device->nil_phone > 0 ) return ELIMIT; |
device->nil_phone = phone; |
printf( "\nNew receiver of the device %d registered:\n\tphone\t= %d", device->device_id, device->nil_phone ); |
printf( "New receiver of the device %d registered:\n\tphone\t= %d\n", device->device_id, device->nil_phone ); |
return EOK; |
} |
|
184,12 → 181,7 |
packet_t packet; |
measured_string_t address; |
|
// printf( "\nmessage %d - %d", IPC_GET_METHOD( * call ), NET_NETIF_FIRST ); |
#if NIL_BUNDLE |
if( IS_NET_NIL_MESSAGE( call )){ |
return nil_message( callid, call, answer, answer_count ); |
} |
#endif |
// printf( "message %d - %d\n", IPC_GET_METHOD( * call ), NET_NETIF_FIRST ); |
* answer_count = 0; |
switch( IPC_GET_METHOD( * call )){ |
case IPC_M_PHONE_HUNGUP: |
200,22 → 192,18 |
rwlock_write_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
case NET_NETIF_PROBE: |
return netif_probe_wrapper( IPC_GET_DEVICE( call ), NETIF_GET_IRQ( call ), NETIF_GET_IO( call )); |
return netif_probe_req( 0, IPC_GET_DEVICE( call ), NETIF_GET_IRQ( call ), NETIF_GET_IO( call )); |
case IPC_M_CONNECT_TO_ME: |
#if NIL_BUNDLE |
return nil_register_message( NIL_GET_PROTO( call ), IPC_GET_PHONE( call )); |
#else |
rwlock_write_lock( & netif_globals.lock ); |
ERROR_CODE = register_message( IPC_GET_DEVICE( call ), IPC_GET_PHONE( call )); |
rwlock_write_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
#endif |
case NET_NETIF_SEND: |
case NET_NIL_SEND: |
ERROR_PROPAGATE( packet_translate( netif_globals.networking_phone, & packet, IPC_GET_PACKET( call ))); |
return netif_send_wrapper( IPC_GET_DEVICE( call ), packet, IPC_GET_SENDER( call )); |
ERROR_PROPAGATE( packet_translate( netif_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
return netif_send_msg( 0, IPC_GET_DEVICE( call ), packet, IPC_GET_SENDER( call )); |
case NET_NETIF_START: |
return netif_start_wrapper( IPC_GET_DEVICE( call )); |
return netif_start_req( 0, IPC_GET_DEVICE( call )); |
case NET_NETIF_STATS: |
rwlock_read_lock( & netif_globals.lock ); |
if( ! ERROR_OCCURRED( ipc_data_read_receive( & callid, & length ))){ |
230,7 → 218,7 |
rwlock_read_unlock( & netif_globals.lock ); |
return ERROR_CODE; |
case NET_NETIF_STOP: |
return netif_stop_wrapper( IPC_GET_DEVICE( call )); |
return netif_stop_req( 0, IPC_GET_DEVICE( call )); |
case NET_NETIF_GET_ADDR: |
case NET_NIL_ADDR: |
rwlock_read_lock( & netif_globals.lock ); |
243,11 → 231,11 |
return netif_specific_message( callid, call, answer, answer_count ); |
} |
|
int netif_start_module( async_client_conn_t client_connection ){ |
int netif_init_module( async_client_conn_t client_connection ){ |
ERROR_DECLARE; |
|
async_set_client_connection( client_connection ); |
netif_globals.networking_phone = connect_to_service( SERVICE_NETWORKING ); |
netif_globals.net_phone = connect_to_service( SERVICE_NETWORKING ); |
device_map_initialize( & netif_globals.device_map ); |
ERROR_PROPAGATE( pm_init()); |
rwlock_initialize( & netif_globals.lock ); |
255,13 → 243,10 |
pm_destroy(); |
return ERROR_CODE; |
} |
#if NIL_BUNDLE |
if( ERROR_OCCURRED( nil_initialize( netif_globals.networking_phone ))){ |
pm_destroy(); |
return ERROR_CODE; |
} |
#endif |
return EOK; |
} |
|
int netif_run_module( void ){ |
async_manager(); |
|
pm_destroy(); |
269,11 → 254,11 |
} |
|
void netif_pq_release( packet_id_t packet_id ){ |
pq_release( netif_globals.networking_phone, packet_id ); |
pq_release( netif_globals.net_phone, packet_id ); |
} |
|
packet_t netif_packet_get_1( size_t content ){ |
return packet_get_1( netif_globals.networking_phone, content ); |
return packet_get_1( netif_globals.net_phone, content ); |
} |
|
/** @} |