31,6 → 31,7 |
*/ |
|
/** @file |
* Loopback network interface implementation. |
*/ |
|
#include <async.h> |
54,21 → 55,52 |
#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" |
|
/** Default address length. |
*/ |
#define DEFAULT_ADDR_LEN ( sizeof( DEFAULT_ADDR ) / sizeof( char )) |
|
/** Loopback module name. |
*/ |
#define NAME "lo - loopback interface" |
|
/** Network interface global data. |
*/ |
netif_globals_t netif_globals; |
|
/** Loopback module global data. |
*/ |
static struct lo_globals{ |
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 ); |
/** Changes the loopback state. |
* @param device The device structure. Input parameter. |
* @param state The new device state. Input parameter. |
* @returns The new state if changed. |
* @returns EOK otherwise. |
*/ |
int change_state_message( device_ref device, device_state_t state ); |
|
/** Creates and returns the loopback network interface structure. |
* @param device_id The new devce identifier. Input parameter. |
* @param device The device structure. Output parameter. |
* @returns EOK on success. |
* @returns EXDEV if one loopback network interface already exists. |
* @returns ENOMEM if there is not enough memory left. |
*/ |
int create( device_id_t device_id, device_ref * device ); |
|
/** Prints the module name. |
* @see NAME |
*/ |
void module_print_name( void ); |
|
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
94,7 → 126,7 |
return EOK; |
} |
|
static int change_state_message( device_ref device, device_state_t state ){ |
int change_state_message( device_ref device, device_state_t state ){ |
if( device->state != state ){ |
device->state = state; |
printf( "State changed to %s\n", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" ); |
103,7 → 135,7 |
return EOK; |
} |
|
static int create( device_id_t device_id, device_ref * device ){ |
int create( device_id_t device_id, device_ref * device ){ |
int index; |
|
if( device_map_count( & netif_globals.device_map ) > 0 ){ |