/branches/network/uspace/srv/net/il/il_messages.h |
---|
63,7 → 63,11 |
/** Packet size message. |
* @see ip_packet_size_req() |
*/ |
NET_IL_PACKET_SPACE |
NET_IL_PACKET_SPACE, |
/** Device MTU changed message. |
* @see il_mtu_changed_msg() |
*/ |
NET_IL_MTU_CHANGED |
} il_messages; |
/** Returns the protocol number message parameter. |
/branches/network/uspace/srv/net/il/arp/arp_messages.h |
---|
57,6 → 57,10 |
* @see arp_clear_device_req() |
*/ |
NET_ARP_CLEAR_DEVICE, |
/** Clear address cache message. |
* @see arp_clear_address_msg() |
*/ |
NET_ARP_CLEAR_ADDRESS, |
/** Clean cache message. |
* @see arp_clean_cache() |
*/ |
/branches/network/uspace/srv/net/il/arp/arp.c |
---|
127,6 → 127,13 |
*/ |
void clear_device( arp_device_ref device ); |
/** Updates the device content length according to the new MTU value. |
* @param device_id The device identifier. Input parameter. |
* @param mtu The new mtu value. Input parameter. |
* @returns EOK on success. |
*/ |
int arp_mtu_changed_msg( device_id_t device_id, size_t mtu ); |
DEVICE_MAP_IMPLEMENT( arp_cache, arp_device_t ) |
INT_MAP_IMPLEMENT( arp_protos, arp_proto_t ) |
152,6 → 159,26 |
return EOK; |
} |
int arp_clear_address_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address ){ |
arp_device_ref device; |
arp_proto_ref proto; |
fibril_rwlock_write_lock( & arp_globals.lock ); |
device = arp_cache_find( & arp_globals.cache, device_id ); |
if( ! device ){ |
fibril_rwlock_write_unlock( & arp_globals.lock ); |
return ENOENT; |
} |
proto = arp_protos_find( & device->protos, protocol ); |
if( ! proto ){ |
fibril_rwlock_write_unlock( & arp_globals.lock ); |
return ENOENT; |
} |
arp_addr_exclude( & proto->addresses, address->value, address->length ); |
fibril_rwlock_write_unlock( & arp_globals.lock ); |
return EOK; |
} |
int arp_clean_cache_req( int arp_phone ){ |
int count; |
arp_device_ref device; |
465,6 → 492,21 |
return EOK; |
} |
int arp_mtu_changed_msg( device_id_t device_id, size_t mtu ){ |
arp_device_ref device; |
fibril_rwlock_write_lock( & arp_globals.lock ); |
device = arp_cache_find( & arp_globals.cache, device_id ); |
if( ! device ){ |
fibril_rwlock_write_unlock( & arp_globals.lock ); |
return ENOENT; |
} |
device->content = mtu; |
printf( "arp - device %d changed mtu to %d\n\n", device_id, mtu ); |
fibril_rwlock_write_unlock( & arp_globals.lock ); |
return EOK; |
} |
int arp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
ERROR_DECLARE; |
501,6 → 543,12 |
return ERROR_CODE; |
case NET_ARP_CLEAR_DEVICE: |
return arp_clear_device_req( 0, IPC_GET_DEVICE( call )); |
case NET_ARP_CLEAR_ADDRESS: |
ERROR_PROPAGATE( measured_strings_receive( & address, & data, 1 )); |
arp_clear_address_req( 0, IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), address ); |
free( address ); |
free( data ); |
return EOK; |
case NET_ARP_CLEAN_CACHE: |
return arp_clean_cache_req( 0 ); |
case NET_IL_DEVICE_STATE: |
518,6 → 566,8 |
fibril_rwlock_read_unlock( & arp_globals.lock ); |
} |
return ERROR_CODE; |
case NET_IL_MTU_CHANGED: |
return arp_mtu_changed_msg( IPC_GET_DEVICE( call ), IPC_GET_MTU( call )); |
} |
return ENOTSUP; |
} |
/branches/network/uspace/srv/net/il/arp/arp_remote.c |
---|
69,6 → 69,16 |
return ( int ) async_req_1_0( arp_phone, NET_ARP_CLEAR_DEVICE, ( ipcarg_t ) device_id ); |
} |
int arp_clear_address_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address ){ |
aid_t message_id; |
ipcarg_t result; |
message_id = async_send_2( arp_phone, NET_ARP_CLEAR_ADDRESS, ( ipcarg_t ) device_id, protocol, NULL ); |
measured_strings_send( arp_phone, address, 1 ); |
async_wait_for( message_id, & result ); |
return ( int ) result; |
} |
int arp_clean_cache_req( int arp_phone ){ |
return ( int ) async_req_0_0( arp_phone, NET_ARP_CLEAN_CACHE ); |
} |
/branches/network/uspace/srv/net/il/ip/ip.c |
---|
99,6 → 99,7 |
GENERIC_FIELD_IMPLEMENT( ip_routes, ip_route_t ) |
int ip_mtu_changed_msg( device_id_t device_id, size_t mtu ); |
int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ); |
int ip_register( int protocol, services_t service, int phone, tl_received_msg_t tl_received_msg ); |
int ip_netif_initialize( ip_netif_ref ip_netif ); |
222,7 → 223,7 |
int ip_netif_initialize( ip_netif_ref ip_netif ){ |
ERROR_DECLARE; |
measured_string_t names[ 9 ] = {{ "IPV", 3 }, { "IP_CONFIG", 9 }, { "IP_ADDR", 7 }, { "NETMASK", 7 }, { "GATEWAY", 7 }, { "BROADCAST", 9 }, { "DNS1", 4 }, { "DNS2", 4 }, { "ARP", 3 }}; |
measured_string_t names[] = {{ "IPV", 3 }, { "IP_CONFIG", 9 }, { "IP_ADDR", 7 }, { "NETMASK", 7 }, { "GATEWAY", 7 }, { "BROADCAST", 9 }, { "DNS1", 4 }, { "DNS2", 4 }, { "ARP", 3 }, { "IP_ROUTING", 10 }}; |
measured_string_ref configuration; |
size_t count = sizeof( names ) / sizeof( measured_string_t ); |
char * data; |
286,6 → 287,7 |
}else{ |
ip_netif->arp = NULL; |
} |
ip_netif->routing = configuration[ 9 ].value && ( configuration[ 9 ].value[ 0 ] == 'y' ); |
net_free_settings( configuration, data ); |
} |
ip_netif->phone = bind_service( ip_netif->service, ( ipcarg_t ) ip_netif->device_id, SERVICE_IP, 0, ip_globals.client_connection ); |
321,6 → 323,21 |
return EOK; |
} |
int ip_mtu_changed_msg( device_id_t device_id, size_t mtu ){ |
ip_netif_ref netif; |
fibril_rwlock_write_lock( & ip_globals.netifs_lock ); |
netif = ip_netifs_find( & ip_globals.netifs, device_id ); |
if( ! netif ){ |
fibril_rwlock_write_unlock( & ip_globals.netifs_lock ); |
return ENOENT; |
} |
netif->content = mtu; |
printf( "ip - device %d changed mtu to %d\n\n", device_id, mtu ); |
fibril_rwlock_write_unlock( & ip_globals.netifs_lock ); |
return EOK; |
} |
int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ){ |
// ERROR_DECLARE; |
584,8 → 601,6 |
return EOK; |
} |
int ip_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
ERROR_DECLARE; |
603,10 → 618,8 |
ERROR_PROPAGATE( packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
return ip_send_msg( 0, IPC_GET_DEVICE( call ), packet, 0 ); |
case NET_IL_DEVICE_STATE: |
case NET_NIL_DEVICE_STATE: |
return ip_device_state_msg( 0, IPC_GET_DEVICE( call ), IPC_GET_STATE( call )); |
case NET_IL_RECEIVED: |
case NET_NIL_RECEIVED: |
ERROR_PROPAGATE( packet_translate( ip_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
return ip_received_msg( IPC_GET_DEVICE( call ), packet ); |
case NET_IP_ADD_ROUTE: |
617,6 → 630,8 |
ERROR_PROPAGATE( ip_packet_size_req( 0, IPC_GET_DEVICE( call ), IPC_SET_ADDR( answer ), IPC_SET_PREFIX( answer ), IPC_SET_CONTENT( answer ), IPC_SET_SUFFIX( answer ))); |
* answer_count = 3; |
return EOK; |
case NET_IL_MTU_CHANGED: |
return ip_mtu_changed_msg( IPC_GET_DEVICE( call ), IPC_GET_MTU( call )); |
} |
return ENOTSUP; |
} |
926,7 → 941,15 |
// local delivery |
return ip_deliver_local( device_id, packet, header ); |
}else{ |
return ip_send_route( packet, route->netif, route, NULL, dest ); |
// only if routing enabled |
if( route->netif->routing ){ |
return ip_send_route( packet, route->netif, route, NULL, dest ); |
} |
else |
{ |
// TODO icmp unreachable? |
return ENOENT; |
} |
} |
} |
/branches/network/uspace/srv/net/il/ip/ip.h |
---|
74,6 → 74,7 |
module_ref arp; |
int ipv; |
int dhcp; |
int routing; |
device_state_t state; |
in_addr_t broadcast; |
in_addr_t dns1; |