Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4306 → Rev 4307

/branches/network/uspace/srv/net/netif/lo/lo.c
48,10 → 48,11
#include "../../structures/packet/packet_client.h"
 
#include "../../include/device.h"
#include "../../include/nil_messages.h"
#include "../../include/nil_interface.h"
#include "../../include/net_interface.h"
 
#include "../netif.h"
#include "../netif_interface.h"
#include "../netif_module.h"
 
#define DEFAULT_MTU 1500
 
63,12 → 64,12
netif_globals_t netif_globals;
 
static struct lo_globals{
int mtu;
unsigned int mtu;
} lo_globals;
 
static int change_state_message( device_ref device, device_state_t state );
static int create( device_id_t device_id, device_ref * device );
void netif_print_name( void );
void module_print_name( void );
 
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
//TODO nil send message
96,7 → 97,7
static int change_state_message( device_ref device, device_state_t state ){
if( device->state != state ){
device->state = state;
printf( "\nState changed to %s", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
printf( "State changed to %s\n", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" );
return state;
}
return EOK;
136,7 → 137,7
return REGISTER_ME( SERVICE_LO, & phonehash );
}
 
void netif_print_name( void ){
void module_print_name( void ){
printf( "%s", NAME );
}
 
146,7 → 147,7
device_ref device;
 
ERROR_PROPAGATE( create( arg1, & device ));
ipc_call_sync_3_3( netif_globals.networking_phone, NET_NET_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL );
ipc_call_sync_3_3( netif_globals.net_phone, NET_NET_DEVICE, device->device_id, NULL, NULL, NULL, NULL, NULL );
*/ return ENOTSUP;
}
 
153,44 → 154,26
int netif_probe_message( device_id_t device_id, int irq, int io ){
ERROR_DECLARE;
 
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;
ipcarg_t result;
device_ref device;
measured_string_t names[ 1 ] = {{ "MTU", 3 }};
measured_string_ref configuration;
int count = 1;
char * data;
 
configuration = & names[ 0 ];
// create a new device
ERROR_PROPAGATE( create( device_id, & device ));
// get configuration
message = async_send_2( netif_globals.networking_phone, NET_NET_GET_DEVICE_CONF, device->device_id, count, & answer );
// send names and get settings
if( ERROR_OCCURRED( measured_strings_send( netif_globals.networking_phone, configuration, count ))
|| ERROR_OCCURRED( measured_strings_return( netif_globals.networking_phone, & settings, & data, count ))){
async_wait_for( message, NULL );
return ERROR_CODE;
}
// end request
async_wait_for( message, & result );
if( ERROR_OCCURRED( result )){
if( settings ){
free( settings );
free( data );
}
return ERROR_CODE;
}
ERROR_PROPAGATE( net_get_device_conf_req( netif_globals.net_phone, device->device_id, & configuration, count, & data ));
// MTU is the first one
if( settings && ( settings[ 0 ].value )){
lo_globals.mtu = strtoul( settings[ 0 ].value, NULL, 0 );
free( settings );
free( data );
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("\nNew device registered:\n\tid\t= %d\n\tMTU\t= %d", device->device_id, lo_globals.mtu );
printf("New device registered:\n\tid\t= %d\n\tMTU\t= %d\n", device->device_id, lo_globals.mtu );
return EOK;
}