58,10 → 58,6 |
#include "../netif.h" |
#include "../netif_module.h" |
|
/** Default maximum transmission unit. |
*/ |
#define DEFAULT_MTU 1500 |
|
/** Default hardware address. |
*/ |
#define DEFAULT_ADDR "\0\0\0\0\0\0" |
78,12 → 74,6 |
*/ |
netif_globals_t netif_globals; |
|
/** Loopback module global data. |
*/ |
static struct lo_globals{ |
unsigned int mtu; |
} lo_globals; |
|
/** Changes the loopback state. |
* @param device The device structure. Input parameter. |
* @param state The new device state. Input parameter. |
107,17 → 97,7 |
void module_print_name( void ); |
|
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
switch( IPC_GET_METHOD( * call )){ |
case NET_NIL_PACKET_SPACE: |
* IPC_SET_ADDR( answer ) = 0; |
* IPC_SET_PREFIX( answer ) = 0; |
* IPC_SET_CONTENT( answer ) = lo_globals.mtu; |
* IPC_SET_SUFFIX( answer ) = 0; |
* answer_count = 4; |
return EOK; |
default: |
return ENOTSUP; |
} |
return ENOTSUP; |
} |
|
int netif_get_addr_message( device_id_t device_id, measured_string_ref address ){ |
199,25 → 179,11 |
ERROR_DECLARE; |
|
device_ref device; |
measured_string_t names[ 1 ] = {{ "MTU", 3 }}; |
measured_string_ref configuration; |
size_t count = sizeof( names ) / sizeof( measured_string_t ); |
char * data; |
|
configuration = & names[ 0 ]; |
// create a new device |
ERROR_PROPAGATE( create( device_id, & device )); |
// get configuration |
ERROR_PROPAGATE( net_get_device_conf_req( netif_globals.net_phone, device->device_id, & configuration, count, & data )); |
// MTU is the first one |
if( configuration && configuration[ 0 ].value ){ |
lo_globals.mtu = strtoul( configuration[ 0 ].value, NULL, 0 ); |
net_free_settings( configuration, data ); |
}else{ |
lo_globals.mtu = DEFAULT_MTU; |
} |
// print the settings |
printf("New device registered:\n\tid\t= %d\n\tMTU\t= %d\n", device->device_id, lo_globals.mtu ); |
printf("New device created:\n\tid\t= %d\n", device->device_id ); |
return EOK; |
} |
|