48,6 → 48,7 |
#include "../../structures/packet/packet_client.h" |
|
#include "../../include/device.h" |
#include "../../include/nil_messages.h" |
|
#include "../netif.h" |
#include "../netif_interface.h" |
65,7 → 66,7 |
int mtu; |
} lo_globals; |
|
static int change_state_message( device_id_t device_id, device_state_t state ); |
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 ); |
|
92,16 → 93,11 |
return EOK; |
} |
|
static int change_state_message( device_id_t device_id, device_state_t state ){ |
ERROR_DECLARE; |
|
device_ref device; |
|
ERROR_PROPAGATE( find_device( device_id, & device )); |
static int change_state_message( device_ref device, device_state_t state ){ |
if( device->state != state ){ |
device->state = state; |
nil_message( device, NET_NIL_DEVICE_STATE, device->state, NULL ); |
printf( "\nState changed to %s", ( state == NETIF_ACTIVE ) ? "ACTIVE" : "STOPPED" ); |
return state; |
} |
return EOK; |
} |
198,12 → 194,13 |
return EOK; |
} |
|
int netif_send_message( device_id_t device_id, packet_t packet ){ |
int netif_send_message( device_id_t device_id, packet_t packet, services_t sender ){ |
ERROR_DECLARE; |
|
device_ref device; |
size_t length; |
packet_t next; |
int phone; |
|
ERROR_PROPAGATE( find_device( device_id, & device )); |
if( device->state != NETIF_ACTIVE ) return EPERM; |
216,16 → 213,19 |
(( device_stats_ref ) device->specific )->rx_bytes += length; |
next = pq_next( next ); |
}while( next ); |
nil_message( device, NET_NIL_RECEIVED, packet_get_id( packet ), PACKET_SELF ); |
phone = device->nil_phone; |
rwlock_write_unlock( & netif_globals.lock ); |
nil_received_msg( phone, device_id, packet, sender ); |
rwlock_write_lock( & netif_globals.lock ); |
return EOK; |
} |
|
int netif_start_message( device_id_t device_id ){ |
return change_state_message( device_id, NETIF_ACTIVE ); |
int netif_start_message( device_ref device ){ |
return change_state_message( device, NETIF_ACTIVE ); |
} |
|
int netif_stop_message( device_id_t device_id ){ |
return change_state_message( device_id, NETIF_STOPPED ); |
int netif_stop_message( device_ref device ){ |
return change_state_message( device, NETIF_STOPPED ); |
} |
|
/** @} |