Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4694 → Rev 4695

/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;
}
}
}