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; |
} |