/branches/network/uspace/srv/net/nil/nil_messages.h |
---|
79,10 → 79,6 |
*/ |
#define NIL_GET_PROTO( call ) ( services_t ) IPC_GET_ARG2( * call ) |
/** Returns the maximum transmission unit message parameter. |
*/ |
#define NIL_GET_MTU( call ) ( size_t ) IPC_GET_ARG2( * call ) |
#endif |
/** @} |
/branches/network/uspace/srv/net/nil/eth/eth.c |
---|
199,7 → 199,7 |
* @returns ENOENT if the service is not known. |
* @returns ENOMEM if there is not enough memory left. |
*/ |
int nil_register_message( services_t service, int phone ); |
int eth_register_message( services_t service, int phone ); |
/** Returns the device packet dimensions for sending. |
* @param device_id The device identifier. Input parameter. |
306,6 → 306,7 |
measured_string_ref configuration; |
size_t count = sizeof( names ) / sizeof( measured_string_t ); |
char * data; |
eth_proto_ref proto; |
fibril_rwlock_write_lock( & eth_globals.devices_lock ); |
// an existing device? |
319,6 → 320,17 |
// update mtu |
device->mtu = mtu; |
printf( "Device %d already exists:\tMTU\t= %d\n", device->device_id, device->mtu ); |
fibril_rwlock_write_unlock( & eth_globals.devices_lock ); |
// notify all upper layer modules |
fibril_rwlock_read_lock( & eth_globals.protos_lock ); |
for( index = 0; index < eth_protos_count( & eth_globals.protos ); ++ index ){ |
proto = eth_protos_get_index( & eth_globals.protos, index ); |
if ( proto->phone ){ |
il_mtu_changed_msg( proto->phone, device->device_id, device->mtu, proto->service ); |
} |
} |
fibril_rwlock_read_unlock( & eth_globals.protos_lock ); |
return EOK; |
} |
}else{ |
// create a new device |
506,7 → 518,7 |
return ( * address ) ? EOK : ENOENT; |
} |
int nil_register_message( services_t service, int phone ){ |
int eth_register_message( services_t service, int phone ){ |
eth_proto_ref proto; |
int protocol; |
int index; |
648,7 → 660,7 |
case IPC_M_PHONE_HUNGUP: |
return EOK; |
case NET_NIL_DEVICE: |
return eth_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), NIL_GET_MTU( call )); |
return eth_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), IPC_GET_MTU( call )); |
case NET_NIL_SEND: |
ERROR_PROPAGATE( packet_translate( eth_globals.net_phone, & packet, IPC_GET_PACKET( call ))); |
return eth_send_message( IPC_GET_DEVICE( call ), packet, IPC_GET_SERVICE( call )); |
663,7 → 675,7 |
ERROR_PROPAGATE( eth_addr_message( IPC_GET_DEVICE( call ), ETH_BROADCAST_ADDR, & address )); |
return measured_strings_reply( address, 1 ); |
case IPC_M_CONNECT_TO_ME: |
return nil_register_message( NIL_GET_PROTO( call ), IPC_GET_PHONE( call )); |
return eth_register_message( NIL_GET_PROTO( call ), IPC_GET_PHONE( call )); |
} |
return ENOTSUP; |
} |
/branches/network/uspace/srv/net/include/arp_interface.h |
---|
86,6 → 86,16 |
*/ |
int arp_clear_device_req( int arp_phone, device_id_t device_id ); |
/** Clears the given protocol address from the cache. |
* @param arp_phone The ARP module phone used for (semi)remote calls. Input parameter. |
* @param device_id The device identifier. Input parameter. |
* @param protocol The requesting protocol service. Input parameter. |
* @param address The protocol address to be cleared. Input parameter. |
* @returns EOK on success. |
* @returns ENOENT if the mapping is not found. |
*/ |
int arp_clear_address_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address ); |
/** Cleans the cache. |
* @param arp_phone The ARP module phone used for (semi)remote calls. Input parameter. |
* @returns EOK on success. |
/branches/network/uspace/srv/net/include/il_interface.h |
---|
73,6 → 73,16 |
return generic_received_msg( il_phone, NET_IL_RECEIVED, device_id, packet_get_id( packet ), target ); |
} |
/** Notifies the internetwork layer modules about the mtu change. |
* @param il_phone The internetwork layer module phone used for (semi)remote calls. Input parameter. |
* @param device_id The device identifier. Input parameter. |
* @param mtu The new mtu value. Input parameter. |
* @returns EOK on success. |
*/ |
inline static int il_mtu_changed_msg( int il_phone, device_id_t device_id, int mtu, services_t target ){ |
return generic_device_state_msg( il_phone, NET_IL_MTU_CHANGED, device_id, mtu, target ); |
} |
#endif |
/** @} |
/branches/network/uspace/srv/net/net/net_standalone.c |
---|
76,6 → 76,7 |
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, LO_NAME, LO_FILENAME, SERVICE_LO, 0, connect_to_service )); |
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service )); |
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service )); |
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, NILDUMMY_NAME, NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service )); |
task_id = spawn( "/srv/ip" ); |
if( ! task_id ) return EINVAL; |
93,9 → 94,11 |
if( str_lcmp( name, "lo", 2 ) == 0 ){ |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", LO_NAME )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", LO_NAME )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", NILDUMMY_NAME )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ROUTING", "yes" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "15535" )); |
}else if( str_lcmp( name, "ne2k", 4 ) == 0 ){ |
111,6 → 114,7 |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "576" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "10.0.2.15" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ROUTING", "yes" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.255.255.240" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "BROADCAST", "10.0.2.255" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "GATEWAY", "10.0.2.2" )); |
/branches/network/uspace/srv/net/net/net_bundle.c |
---|
35,7 → 35,7 |
* Distributes messages and initializes all module parts. |
*/ |
#include <stdio.h> |
#include <string.h> |
#include <ipc/ipc.h> |
75,7 → 75,7 |
default: |
return EINVAL; |
} |
}else if( IS_NET_IP_MESSAGE( call ) || IS_NET_NIL_MESSAGE( call )){ |
}else if( IS_NET_IP_MESSAGE( call )){ |
return ip_message( callid, call, answer, answer_count ); |
}else if( IS_NET_ARP_MESSAGE( call )){ |
return arp_message( callid, call, answer, answer_count ); |
111,6 → 111,8 |
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, LO_NAME, LO_FILENAME, SERVICE_LO, 0, connect_to_service )); |
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service )); |
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service )); |
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, NILDUMMY_NAME, NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service )); |
ERROR_PROPAGATE( REGISTER_ME( SERVICE_IP, & phonehash )); |
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_get_id(), ip_connect_module )); |
134,9 → 136,11 |
if( str_lcmp( name, "lo", 2 ) == 0 ){ |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", LO_NAME )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", LO_NAME )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", NILDUMMY_NAME )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ROUTING", "yes" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "15535" )); |
}else if( str_lcmp( name, "ne2k", 4 ) == 0 ){ |
151,6 → 155,7 |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "1492" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "10.0.2.15" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ROUTING", "yes" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.255.255.240" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "BROADCAST", "10.0.2.255" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "GATEWAY", "10.0.2.2" )); |
/branches/network/uspace/srv/net/messages.h |
---|
50,9 → 50,9 |
#define NET_NET_COUNT 9 |
#define NET_NIL_COUNT 7 |
#define NET_ETH_COUNT 0 |
#define NET_IL_COUNT 5 |
#define NET_IL_COUNT 6 |
#define NET_IP_COUNT 2 |
#define NET_ARP_COUNT 4 |
#define NET_ARP_COUNT 5 |
#define NET_RARP_COUNT 0 |
#define NET_ICMP_COUNT 0 |
#define NET_TL_COUNT 1 |
129,6 → 129,10 |
#define IPC_GET_COUNT( call ) ( size_t ) IPC_GET_ARG2( * call ) |
#define IPC_GET_STATE( call ) ( device_state_t ) IPC_GET_ARG2( * call ) |
/** Returns the maximum transmission unit message parameter. |
*/ |
#define IPC_GET_MTU( call ) ( size_t ) IPC_GET_ARG2( * call ) |
/** Returns the device driver service message parameter. |
*/ |
#define IPC_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG3( * call ) |
/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; |