41,6 → 41,7 |
//#include <sys/mman.h> |
|
#include "../err.h" |
#include "../measured_strings.h" |
#include "../messages.h" |
#include "../modules.h" |
|
52,8 → 53,8 |
|
netif_globals_t netif_globals; |
|
void change_status( netif_device_ref device, netif_status_t status ); |
int change_status_message( netif_device_id_t device_id, netif_status_t status ); |
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 ); |
64,18 → 65,18 |
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 ); |
|
void change_status( netif_device_ref device, netif_status_t status ){ |
device->status = status; |
ll_message( device, NET_LL_DEVICE_STATUS_CHANGED, device->status, NULL, NULL, NULL, NULL ); |
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_status_message( netif_device_id_t device_id, netif_status_t status ){ |
int change_state_message( netif_device_id_t device_id, netif_state_t state ){ |
ERROR_DECLARE; |
|
netif_device_ref device; |
|
ERROR_PROPAGATE( netif_device_find( device_id, & device )); |
change_status( device, status ); |
change_state( device, state ); |
return EOK; |
} |
|
87,11 → 88,11 |
}else{ |
* device = ( netif_device_ref ) malloc( sizeof( netif_device_t )); |
if( !( * device )) return ENOMEM; |
// ( ** device ).device_id = netif_device_id_generate( 1 ); |
( ** device ).device_id = device_id; |
( ** device ).ll_registered = NULL; |
( ** device ).ll_registered = -1; |
( ** device ).specific = NULL; |
netif_device_stats_null( &(( ** device ).stats )); |
( ** device ).status = NETIF_STOPPED; |
( ** device ).state = NETIF_STOPPED; |
( ** device ).flags = NULL; |
( ** device ).mtu = DEFAULT_MTU; |
if( ERROR_OCCURED( netif_device_map_add( & netif_globals.netif_device_map, ( ** device ).device_id, * device ))){ |
108,7 → 109,7 |
} |
|
int netif_initialize( void ){ |
int phonehash; |
ipcarg_t phonehash; |
|
return REGISTER_ME( SERVICE_LO, & phonehash ); |
} |
118,13 → 119,13 |
} |
|
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; |
/* ERROR_DECLARE; |
|
netif_device_ref device; |
|
ERROR_PROPAGATE( netif_create( arg1, & device )); |
networking_message( NET_NETWORKING_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL ); |
return EOK; |
ipc_call_sync_3_3( netif_globals.networking_phone, NET_NETWORKING_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL ); |
*/ return ENOTSUP; |
} |
|
int netif_probe_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){ |
131,8 → 132,35 |
ERROR_DECLARE; |
|
netif_device_ref device; |
aid_t message; |
ipc_call_t answer; |
measured_string_t configuration[ 1 ] = {{ "MTU", 3 }}; |
int count = 1; |
measured_string_ref settings; |
char * data; |
|
// create a new device |
ERROR_PROPAGATE( netif_create( arg1, & device )); |
// get configuration |
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 ))){ |
async_wait_for( message, NULL ); |
return ERROR_CODE; |
} |
// MTU is the first one |
if( settings && ( settings[ 0 ].value )){ |
device->mtu = strtoul( settings[ 0 ].value, NULL, 0 ); |
}else{ |
device->mtu = DEFAULT_MTU; |
} |
// print the settings |
printf("\n -MTU=%d", device->mtu ); |
free( settings ); |
free( data ); |
// end request |
async_wait_for( message, NULL ); |
return EOK; |
} |
|
142,7 → 170,7 |
netif_device_ref device; |
|
ERROR_PROPAGATE( netif_device_find( arg1, & device )); |
if( device->status == NETIF_ACTIVE ){ |
if( device->state == NETIF_ACTIVE ){ |
++ device->stats.tx_packets; |
++ device->stats.rx_packets; |
// TODO packet size |
156,11 → 184,11 |
} |
|
int netif_start_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){ |
return change_status_message( arg1, NETIF_ACTIVE ); |
return change_state_message( arg1, NETIF_ACTIVE ); |
} |
|
int netif_stop_message( ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, ipcarg_t * result1, ipcarg_t * result2, ipcarg_t * result3 ){ |
return change_status_message( arg1, NETIF_STOPPED ); |
return change_state_message( arg1, NETIF_STOPPED ); |
} |
|
/** @} |