Rev 3901 | Rev 3914 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3901 | Rev 3912 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | * Copyright (c) 2008 Lukas Mejdrech |
2 | * Copyright (c) 2009 Lukas Mejdrech |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
Line 185... | Line 185... | ||
185 | tmp_module->phone = 0; |
185 | tmp_module->phone = 0; |
186 | tmp_module->usage = 0; |
186 | tmp_module->usage = 0; |
187 | tmp_module->name = name; |
187 | tmp_module->name = name; |
188 | tmp_module->filename = filename; |
188 | tmp_module->filename = filename; |
189 | tmp_module->service = service; |
189 | tmp_module->service = service; |
190 | if( ERROR_OCCURED( modules_add( modules, tmp_module->name, 0, tmp_module ))){ |
190 | if( ERROR_OCCURRED( modules_add( modules, tmp_module->name, 0, tmp_module ))){ |
191 | free( tmp_module ); |
191 | free( tmp_module ); |
192 | return ERROR_CODE; |
192 | return ERROR_CODE; |
193 | } |
193 | } |
194 | if( module ) * module = tmp_module; |
194 | if( module ) * module = tmp_module; |
195 | return EOK; |
195 | return EOK; |
Line 402... | Line 402... | ||
402 | while( isspace( * value )) ++ value; |
402 | while( isspace( * value )) ++ value; |
403 | // create a bulk measured string till the end |
403 | // create a bulk measured string till the end |
404 | setting = measured_string_create_bulk( value, -1 ); |
404 | setting = measured_string_create_bulk( value, -1 ); |
405 | if( ! setting ) return ENOMEM; |
405 | if( ! setting ) return ENOMEM; |
406 | // add the configuration setting |
406 | // add the configuration setting |
407 | if( ERROR_OCCURED( measured_strings_add( configuration, name, 0, setting ))){ |
407 | if( ERROR_OCCURRED( measured_strings_add( configuration, name, 0, setting ))){ |
408 | free( setting ); |
408 | free( setting ); |
409 | return ERROR_CODE; |
409 | return ERROR_CODE; |
410 | } |
410 | } |
411 | return EOK; |
411 | return EOK; |
412 | } |
412 | } |
Line 418... | Line 418... | ||
418 | measured_string_ref setting; |
418 | measured_string_ref setting; |
419 | 419 | ||
420 | setting = measured_string_create_bulk( value, 0 ); |
420 | setting = measured_string_create_bulk( value, 0 ); |
421 | if( ! setting ) return ENOMEM; |
421 | if( ! setting ) return ENOMEM; |
422 | // add the configuration setting |
422 | // add the configuration setting |
423 | if( ERROR_OCCURED( measured_strings_add( configuration, name, 0, setting ))){ |
423 | if( ERROR_OCCURRED( measured_strings_add( configuration, name, 0, setting ))){ |
424 | free( setting ); |
424 | free( setting ); |
425 | return ERROR_CODE; |
425 | return ERROR_CODE; |
426 | } |
426 | } |
427 | return EOK; |
427 | return EOK; |
428 | } |
428 | } |
Line 448... | Line 448... | ||
448 | // printf( "\nloopback initialization" ); |
448 | // printf( "\nloopback initialization" ); |
449 | netif = ( netif_ref ) malloc( sizeof( netif_t )); |
449 | netif = ( netif_ref ) malloc( sizeof( netif_t )); |
450 | if( ! netif ) return ENOMEM; |
450 | if( ! netif ) return ENOMEM; |
451 | netif->id = generate_new_device_id(); |
451 | netif->id = generate_new_device_id(); |
452 | ERROR_PROPAGATE( measured_strings_initialize( & netif->configuration )); |
452 | ERROR_PROPAGATE( measured_strings_initialize( & netif->configuration )); |
453 | if( ERROR_OCCURED( add_configuration( & netif->configuration, "NAME", LO_NAME )) |
453 | if( ERROR_OCCURRED( add_configuration( & netif->configuration, "NAME", LO_NAME )) |
454 | || ERROR_OCCURED( add_configuration( & netif->configuration, "NETIF", LO_NAME )) |
454 | || ERROR_OCCURRED( add_configuration( & netif->configuration, "NETIF", LO_NAME )) |
455 | || ERROR_OCCURED( add_configuration( & netif->configuration, "IL", IP_NAME )) |
455 | || ERROR_OCCURRED( add_configuration( & netif->configuration, "IL", IP_NAME )) |
456 | || ERROR_OCCURED( add_configuration( & netif->configuration, "MTU", "1500" )) |
456 | || ERROR_OCCURRED( add_configuration( & netif->configuration, "MTU", "1500" )) |
457 | || ERROR_OCCURED( add_configuration( & netif->configuration, "IP_CONFIG", "STATIC" )) |
457 | || ERROR_OCCURRED( add_configuration( & netif->configuration, "IP_CONFIG", "STATIC" )) |
458 | || ERROR_OCCURED( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" )) |
458 | || ERROR_OCCURRED( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" )) |
459 | || ERROR_OCCURED( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" ))){ |
459 | || ERROR_OCCURRED( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" ))){ |
460 | measured_strings_destroy( & netif->configuration ); |
460 | measured_strings_destroy( & netif->configuration ); |
461 | free( netif ); |
461 | free( netif ); |
462 | return ERROR_CODE; |
462 | return ERROR_CODE; |
463 | } |
463 | } |
464 | // mandatory name |
464 | // mandatory name |
Line 557... | Line 557... | ||
557 | index = netifs_add( & networking_globals.netifs, netif->id, netif ); |
557 | index = netifs_add( & networking_globals.netifs, netif->id, netif ); |
558 | if( index < 0 ){ |
558 | if( index < 0 ){ |
559 | free( netif ); |
559 | free( netif ); |
560 | return ERROR_CODE; |
560 | return ERROR_CODE; |
561 | } |
561 | } |
562 | if( ERROR_OCCURED( char_map_add( & networking_globals.netif_names, netif->name, 0, index ))){ |
562 | if( ERROR_OCCURRED( char_map_add( & networking_globals.netif_names, netif->name, 0, index ))){ |
563 | netifs_exclude_index( & networking_globals.netifs, index ); |
563 | netifs_exclude_index( & networking_globals.netifs, index ); |
564 | return ERROR_CODE; |
564 | return ERROR_CODE; |
565 | } |
565 | } |
566 | // printf( "\nloopback OK" ); |
566 | // printf( "\nloopback OK" ); |
567 | // end of the static loopback initialization |
567 | // end of the static loopback initialization |
Line 616... | Line 616... | ||
616 | 616 | ||
617 | int startup( void ){ |
617 | int startup( void ){ |
618 | ERROR_DECLARE; |
618 | ERROR_DECLARE; |
619 | 619 | ||
620 | // read configuration files |
620 | // read configuration files |
621 | if( ERROR_OCCURED( read_configuration())) return ERROR_CODE; |
621 | if( ERROR_OCCURRED( read_configuration())) return ERROR_CODE; |
622 | 622 | ||
623 | // start network interfaces and needed modules |
623 | // start network interfaces and needed modules |
624 | // start_device( "/sbin/lo", "/sbin/dummy_link_layer" ); |
624 | // start_device( "/sbin/lo", "/sbin/dummy_link_layer" ); |
625 | return EOK; |
625 | return EOK; |
626 | } |
626 | } |