184,6 → 184,7 |
int res; |
|
/* Accept the connection */ |
// printf( "\nNET-%d got %d on %x from %x", fibril_get_id(), IPC_GET_METHOD( * icall ), icall->in_phone_hash, iid ); |
ipc_answer_0( iid, EOK ); |
|
while( true ){ |
191,6 → 192,7 |
arg1 = 0; |
arg2 = 0; |
arg3 = 0; |
// printf( "\nNET-%d got %d on %x from %x", fibril_get_id(), IPC_GET_METHOD( call ), call.in_phone_hash, callid ); |
#ifdef NETWORKING_module |
if( IS_NET_IL_MESSAGE( call ) || IS_NET_IP_MESSAGE( call )){ |
res = ip_call( callid ); |
247,7 → 249,7 |
|
int main( int argc, char * argv[] ){ |
|
printf("\nTask %d - Networking: HelenOS Networking subsystem\n", task_get_id()); |
printf("\nTask %d - HelenOS Networking subsystem", task_get_id()); |
|
return start_service( SERVICE_NETWORKING, NULL, NULL, client_connection, networking_initialize ); |
} |
322,9 → 324,7 |
measured_strings_ref configuration; |
netif_ref netif; |
|
// printf( "\nNetworking message: %d\n", method ); |
switch( method ){ |
// case IPC_M_CONNECT_ME_TO: |
case IPC_M_PHONE_HUNGUP: |
return EOK; |
case NET_NETWORKING_DEVICE: |
456,6 → 456,7 |
netif_ref netif; |
measured_string_ref setting; |
services_t internet_service; |
int index; |
|
// read general configuration |
ERROR_PROPAGATE( add_configuration( & networking_globals.configuration, "IPV", "4" )); |
463,24 → 464,24 |
// read network interfaces configuration |
|
// static loopback initialization |
printf( "\nloopback initialization" ); |
// printf( "\nloopback initialization" ); |
netif = ( netif_ref ) malloc( sizeof( netif_t )); |
if( ! netif ) return ENOMEM; |
netif->id = generate_new_device_id(); |
ERROR_PROPAGATE( measured_strings_initialize( & netif->configuration )); |
if( ERROR_OCCURED( add_configuration( & netif->configuration, "NAME", LO_NAME )) |
|| ERROR_OCCURED( add_configuration( & netif->configuration, "NETIF", LO_NAME )) |
|| ERROR_OCCURED( add_configuration( & netif->configuration, "IL", IP_NAME )) |
|| ERROR_OCCURED( add_configuration( & netif->configuration, "IP_CONFIG", "STATIC" )) |
|| ERROR_OCCURED( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" )) |
|| ERROR_OCCURED( add_configuration( & netif->configuration, "NETMASK", "255.255.255.255" )) |
){ |
|| ERROR_OCCURED( add_configuration( & netif->configuration, "NETIF", LO_NAME )) |
|| ERROR_OCCURED( add_configuration( & netif->configuration, "IL", IP_NAME )) |
|| ERROR_OCCURED( add_configuration( & netif->configuration, "MTU", "1500" )) |
|| ERROR_OCCURED( add_configuration( & netif->configuration, "IP_CONFIG", "STATIC" )) |
|| ERROR_OCCURED( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" )) |
|| ERROR_OCCURED( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" ))){ |
measured_strings_destroy( & netif->configuration ); |
free( netif ); |
return ERROR_CODE; |
} |
// mandatory name |
printf( "\n\tname" ); |
// printf( "\n\tname" ); |
setting = measured_strings_find( & netif->configuration, "NAME" ); |
if( ! setting ){ |
measured_strings_destroy( & netif->configuration ); |
488,12 → 489,12 |
return EINVAL; |
} |
netif->name = setting->value; |
printf( " %s OK", netif->name ); |
// printf( " %s OK", netif->name ); |
// mandatory netif |
printf( "\n\tnetif" ); |
// printf( "\n\tnetif" ); |
setting = measured_strings_find( & netif->configuration, "NETIF" ); |
if( ! setting ){ |
printf( " unknown" ); |
// printf( " unknown" ); |
measured_strings_destroy( & netif->configuration ); |
free( netif ); |
return EINVAL; |
501,13 → 502,13 |
// printf( " find %s in %d?", setting->value, modules_count( & networking_globals.modules )); |
netif->driver_module = modules_find( & networking_globals.modules, setting->value ); |
if( ! netif->driver_module ){ |
printf( " not found" ); |
// printf( " not found" ); |
// TODO register the unknown one |
measured_strings_destroy( & netif->configuration ); |
free( netif ); |
return EINVAL; |
} |
printf( " found" ); |
// printf( " found" ); |
if( ! netif->driver_module->task_id ){ |
netif->driver_module->task_id = spawn( netif->driver_module->filename ); |
if( ! netif->driver_module->task_id ){ |
516,20 → 517,9 |
return EINVAL; |
} |
} |
if( ! netif->driver_module->phone ){ |
printf( " connect?" ); |
netif->driver_module->phone = connect_to_service( netif->driver_module->service ); |
} |
printf( " connected" ); |
if( ERROR_OCCURED( ipc_call_sync_1_0( netif->driver_module->phone, NET_NETIF_PROBE, netif->id ))){ |
measured_strings_destroy( & netif->configuration ); |
free( netif ); |
return ERROR_CODE; |
} |
++ netif->driver_module->usage; |
printf( " OK" ); |
// printf( " OK" ); |
// optional link layer |
printf( "\n\tlink layer" ); |
// printf( "\n\tlink layer" ); |
setting = measured_strings_find( & netif->configuration, "LL" ); |
if( setting ){ |
netif->link_layer_module = modules_find( & networking_globals.modules, setting->value ); |
549,24 → 539,11 |
return EINVAL; |
} |
} |
if( ! netif->link_layer_module->phone ){ |
netif->link_layer_module->phone = connect_to_service( netif->link_layer_module->service ); |
} |
if( ERROR_OCCURED( ipc_call_sync_2_0( netif->link_layer_module->phone, NET_LL_DEVICE, netif->id, netif->driver_module->service ))){ |
-- netif->driver_module->usage; |
measured_strings_destroy( & netif->configuration ); |
free( netif ); |
return ERROR_CODE; |
} |
++ netif->link_layer_module->usage; |
internet_service = netif->link_layer_module->service; |
printf( " OK" ); |
}else{ |
internet_service = netif->driver_module->service; |
printf( " none" ); |
netif->link_layer_module = NULL; |
} |
// mandatory internet layer |
printf( "\n\tinternet layer" ); |
// printf( "\n\tinternet layer" ); |
setting = measured_strings_find( & netif->configuration, "IL" ); |
if( ! setting ){ |
-- netif->driver_module->usage; |
575,7 → 552,7 |
free( netif ); |
return EINVAL; |
} |
printf( " set %s", setting->value ); |
// printf( " set %s", setting->value ); |
netif->internet_layer_module = modules_find( & networking_globals.modules, setting->value ); |
if( ! netif->internet_layer_module ){ |
// TODO register the unknown one |
585,7 → 562,7 |
free( netif ); |
return EINVAL; |
} |
printf( " found" ); |
// printf( " found" ); |
if( ! netif->internet_layer_module->task_id ){ |
netif->internet_layer_module->task_id = spawn( netif->internet_layer_module->filename ); |
if( ! netif->internet_layer_module->task_id ){ |
596,23 → 573,45 |
return EINVAL; |
} |
} |
if( ! netif->internet_layer_module->phone ){ |
printf( " connect" ); |
netif->internet_layer_module->phone = connect_to_service( netif->internet_layer_module->service ); |
} |
if( ERROR_OCCURED( ipc_call_sync_2_0( netif->internet_layer_module->phone, NET_IL_DEVICE, netif->id, internet_service ))){ |
measured_strings_destroy( & netif->configuration ); |
index = netifs_add( & networking_globals.netifs, netif->id, netif ); |
if( index < 0 ){ |
free( netif ); |
return ERROR_CODE; |
} |
++ netif->internet_layer_module->usage; |
printf( " OK" ); |
if( ERROR_OCCURED( netifs_add( & networking_globals.netifs, netif->id, netif ))){ |
free( netif ); |
if( ERROR_OCCURED( char_map_add( & networking_globals.netif_names, netif->name, index ))){ |
netifs_exclude_index( & networking_globals.netifs, index ); |
return ERROR_CODE; |
} |
printf( "\nloopback OK" ); |
// end of static loopback initialization |
// printf( "\nloopback OK" ); |
// end of the static loopback initialization |
// startup the loopback interface |
if( ! netif->driver_module->phone ){ |
// printf( " connect?" ); |
netif->driver_module->phone = connect_to_service( netif->driver_module->service ); |
} |
// printf( " connected" ); |
ERROR_PROPAGATE( async_req_1_0( netif->driver_module->phone, NET_NETIF_PROBE, netif->id )); |
++ netif->driver_module->usage; |
if( netif->link_layer_module ){ |
if( ! netif->link_layer_module->phone ){ |
netif->link_layer_module->phone = connect_to_service( netif->link_layer_module->service ); |
} |
ERROR_PROPAGATE( async_req_2_0( netif->link_layer_module->phone, NET_LL_DEVICE, netif->id, netif->driver_module->service )); |
++ netif->link_layer_module->usage; |
internet_service = netif->link_layer_module->service; |
// printf( " OK" ); |
}else{ |
internet_service = netif->driver_module->service; |
// printf( " none" ); |
} |
if( ! netif->internet_layer_module->phone ){ |
// printf( " connect" ); |
netif->internet_layer_module->phone = connect_to_service( netif->internet_layer_module->service ); |
} |
ERROR_PROPAGATE( async_req_2_0( netif->internet_layer_module->phone, NET_IL_DEVICE, netif->id, internet_service )); |
++ netif->internet_layer_module->usage; |
ERROR_PROPAGATE( async_req_1_0( netif->driver_module->phone, NET_NETIF_START, netif->id )); |
// printf( "\n LO OK" ); |
return EOK; |
} |
|