Changeset 01a9ef5 in mainline


Ignore:
Timestamp:
2010-02-16T18:11:00Z (14 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
209faf9, bfd7aac
Parents:
80ce111
Message:

+ net configuration files

Files:
6 added
16 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    r80ce111 r01a9ef5  
    8686endif
    8787
     88CFG =
     89
    8890NET_SRVS = \
    8991        $(USPACEDIR)/srv/net/net/net \
     
    100102        $(USPACEDIR)/srv/net/app/nettest2/nettest2
    101103
     104NET_CFG = \
     105        $(USPACEDIR)/srv/net/cfg/$(NETWORKING)/general \
     106        $(USPACEDIR)/srv/net/cfg/$(NETWORKING)/lo \
     107        $(USPACEDIR)/srv/net/cfg/$(NETWORKING)/ne2k
     108
    102109ifeq ($(NETWORKING), module)
    103110        RD_APPS +=      $(NET_APPS)
    104111
    105112        RD_SRVS +=      $(NET_SRVS)
     113
     114        CFG             +=      $(NET_CFG)
    106115else
    107116ifeq ($(NETWORKING), modular)
     
    115124                        $(USPACEDIR)/srv/net/tl/tcp/tcp \
    116125                        $(USPACEDIR)/srv/net/tl/icmp/icmp
     126
     127        CFG             +=      $(NET_CFG)
    117128endif
    118129endif
  • boot/arch/amd64/Makefile.inc

    • Property mode changed from 100644 to 100755
    r80ce111 r01a9ef5  
    3939build: $(BASE)/image.iso
    4040
    41 $(BASE)/image.iso: arch/$(BARCH)/grub/stage2_eltorito $(KERNELDIR)/kernel.bin $(INIT_TASKS) $(RD_SRVS) $(RD_APPS)
     41$(BASE)/image.iso: arch/$(BARCH)/grub/stage2_eltorito $(KERNELDIR)/kernel.bin $(INIT_TASKS) $(RD_SRVS) $(RD_APPS) $(CFG)
    4242        mkdir -p $(TMP)/boot/grub
    4343        cp arch/$(BARCH)/grub/stage2_eltorito $(TMP)/boot/grub/
     
    5656        done
    5757       
     58        rm -f $(USPACEDIR)/dist/srv/*
     59        rm -f $(USPACEDIR)/dist/app/*
     60        rm -f $(USPACEDIR)/dist/cfg/net/*
     61       
    5862        cp $(KERNELDIR)/kernel.bin $(TMP)/boot/
    5963        for task in $(INIT_TASKS) ; do \
     
    6569        for file in $(RD_APPS) ; do \
    6670                cp $$file $(USPACEDIR)/dist/app/ ; \
     71        done
     72        for file in $(NET_CFG) ; do \
     73                cp $$file $(USPACEDIR)/dist/cfg/net/ ; \
    6774        done
    6875       
     
    7885
    7986clean:
     87        rm -f $(USPACEDIR)/dist/srv/*
     88        rm -f $(USPACEDIR)/dist/app/*
     89        rm -f $(USPACEDIR)/dist/cfg/net/*
     90
    8091        for file in $(RD_SRVS) ; do \
    8192                rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
     
    8495                rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
    8596        done
     97        for file in $(NET_CFG) ; do \
     98                rm -f $(USPACEDIR)/dist/cfg/net/`basename $$file` ; \
     99        done
    86100        rm -fr $(TMP)
    87101        rm -f $(BASE)/image.iso
  • boot/arch/arm32/loader/Makefile

    r80ce111 r01a9ef5  
    3737
    3838clean:
     39        rm -f $(USPACEDIR)/dist/srv/*
     40        rm -f $(USPACEDIR)/dist/app/*
     41        rm -f $(USPACEDIR)/dist/cfg/net/*
     42
    3943        for file in $(RD_SRVS) ; do \
    4044                rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
     
    4347                rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
    4448        done
     49        for file in $(NET_CFG) ; do \
     50                rm -f $(USPACEDIR)/dist/cfg/net/`basename $$file` ; \
     51        done
    4552        rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(COMPS).h $(COMPS).c $(LINK) $(INITRD).img $(INITRD).fs
    4653        find . -name '*.o' -follow -exec rm \{\} \;
  • boot/arch/arm32/loader/Makefile.build

    r80ce111 r01a9ef5  
    7676
    7777$(DEPEND):
     78        rm -f $(USPACEDIR)/dist/srv/*
     79        rm -f $(USPACEDIR)/dist/app/*
     80        rm -f $(USPACEDIR)/dist/cfg/net/*
     81
    7882        for file in $(RD_SRVS) ; do \
    7983                cp $$file $(USPACEDIR)/dist/srv/ ; \
     
    8185        for file in $(RD_APPS) ; do \
    8286                cp $$file $(USPACEDIR)/dist/app/ ; \
     87        done
     88        for file in $(NET_CFG) ; do \
     89                cp $$file $(USPACEDIR)/dist/cfg/net/ ; \
    8390        done
    8491ifeq ($(RDFMT),tmpfs)
  • boot/arch/ia64/loader/Makefile

    r80ce111 r01a9ef5  
    4040        $(MAKE) -C gefi clean
    4141        $(MAKE) -C gefi/HelenOS clean
     42
     43        rm -f $(USPACEDIR)/dist/srv/*
     44        rm -f $(USPACEDIR)/dist/app/*
     45        rm -f $(USPACEDIR)/dist/cfg/net/*
     46
    4247        for file in $(RD_SRVS) ; do \
    4348                rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
     
    4651                rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
    4752        done
     53        for file in $(NET_CFG) ; do \
     54                rm -f $(USPACEDIR)/dist/cfg/net/`basename $$file` ; \
     55        done
    4856        rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(HELLO) $(COMPS).h $(COMPS).c $(LINK) $(INITRD).img $(INITRD).fs
    4957        find . -name '*.o' -follow -exec rm \{\} \;
  • boot/arch/ia64/loader/Makefile.build

    r80ce111 r01a9ef5  
    7777
    7878$(DEPEND):
     79        rm -f $(USPACEDIR)/dist/srv/*
     80        rm -f $(USPACEDIR)/dist/app/*
     81        rm -f $(USPACEDIR)/dist/cfg/net/*
     82
    7983        for file in $(RD_SRVS) ; do \
    8084                cp $$file $(USPACEDIR)/dist/srv/ ; \
     
    8286        for file in $(RD_APPS) ; do \
    8387                cp $$file $(USPACEDIR)/dist/app/ ; \
     88        done
     89        for file in $(NET_CFG) ; do \
     90                cp $$file $(USPACEDIR)/dist/cfg/net/ ; \
    8491        done
    8592ifeq ($(RDFMT),tmpfs)
  • boot/arch/mips32/loader/Makefile

    r80ce111 r01a9ef5  
    3737
    3838clean:
     39        rm -f $(USPACEDIR)/dist/srv/*
     40        rm -f $(USPACEDIR)/dist/app/*
     41        rm -f $(USPACEDIR)/dist/cfg/net/*
     42
    3943        for file in $(RD_SRVS) ; do \
    4044                rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
     
    4347                rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
    4448        done
     49        for file in $(NET_CFG) ; do \
     50                rm -f $(USPACEDIR)/dist/cfg/net/`basename $$file` ; \
     51        done
    4552        rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(RAW) $(COMPS).h $(COMPS).c $(LINK) $(INITRD).img $(INITRD).fs
    4653        find . -name '*.o' -follow -exec rm \{\} \;
  • boot/arch/mips32/loader/Makefile.build

    r80ce111 r01a9ef5  
    7777
    7878$(DEPEND):
     79        rm -f $(USPACEDIR)/dist/srv/*
     80        rm -f $(USPACEDIR)/dist/app/*
     81        rm -f $(USPACEDIR)/dist/cfg/net/*
     82
    7983        for file in $(RD_SRVS) ; do \
    8084                cp $$file $(USPACEDIR)/dist/srv/ ; \
     
    8286        for file in $(RD_APPS) ; do \
    8387                cp $$file $(USPACEDIR)/dist/app/ ; \
     88        done
     89        for file in $(NET_CFG) ; do \
     90                cp $$file $(USPACEDIR)/dist/cfg/net/ ; \
    8491        done
    8592ifeq ($(RDFMT),tmpfs)
  • boot/arch/ppc32/loader/Makefile

    r80ce111 r01a9ef5  
    3737
    3838clean:
     39        rm -f $(USPACEDIR)/dist/srv/*
     40        rm -f $(USPACEDIR)/dist/app/*
     41        rm -f $(USPACEDIR)/dist/cfg/net/*
     42
    3943        for file in $(RD_SRVS) ; do \
    4044                rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
     
    4347                rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
    4448        done
     49        for file in $(NET_CFG) ; do \
     50                rm -f $(USPACEDIR)/dist/cfg/net/`basename $$file` ; \
     51        done
    4552        rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(COMPS).h $(COMPS).c $(LINK) $(INITRD).img $(INITRD).fs
    4653        find . -name '*.o' -follow -exec rm \{\} \;
  • boot/arch/ppc32/loader/Makefile.build

    r80ce111 r01a9ef5  
    7777
    7878$(DEPEND):
     79        rm -f $(USPACEDIR)/dist/srv/*
     80        rm -f $(USPACEDIR)/dist/app/*
     81        rm -f $(USPACEDIR)/dist/cfg/net/*
     82
    7983        for file in $(RD_SRVS) ; do \
    8084                cp $$file $(USPACEDIR)/dist/srv/ ; \
     
    8286        for file in $(RD_APPS) ; do \
    8387                cp $$file $(USPACEDIR)/dist/app/ ; \
     88        done
     89        for file in $(NET_CFG) ; do \
     90                cp $$file $(USPACEDIR)/dist/cfg/net/ ; \
    8491        done
    8592ifeq ($(RDFMT),tmpfs)
  • boot/arch/sparc64/loader/Makefile

    r80ce111 r01a9ef5  
    3737
    3838clean:
     39        rm -f $(USPACEDIR)/dist/srv/*
     40        rm -f $(USPACEDIR)/dist/app/*
     41        rm -f $(USPACEDIR)/dist/cfg/net/*
     42
    3943        for file in $(RD_SRVS) $(RD_SRVS_GENERIC) ; do \
    4044                rm -f $(USPACEDIR)/dist/srv/`basename $$file` ; \
     
    4347                rm -f $(USPACEDIR)/dist/app/`basename $$file` ; \
    4448        done
     49        for file in $(NET_CFG) ; do \
     50                rm -f $(USPACEDIR)/dist/cfg/net/`basename $$file` ; \
     51        done
    4552        rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(COMPS).h $(COMPS).c $(LINK) $(INITRD).img $(INITRD).fs
    4653        find . -name '*.o' -follow -exec rm \{\} \;
  • boot/arch/sparc64/loader/Makefile.build

    r80ce111 r01a9ef5  
    8888
    8989$(DEPEND):
     90        rm -f $(USPACEDIR)/dist/srv/*
     91        rm -f $(USPACEDIR)/dist/app/*
     92        rm -f $(USPACEDIR)/dist/cfg/net/*
     93
    9094        for file in $(RD_SRVS) ; do \
    9195                cp $$file $(USPACEDIR)/dist/srv/ ; \
     
    9397        for file in $(RD_APPS) ; do \
    9498                cp $$file $(USPACEDIR)/dist/app/ ; \
     99        done
     100        for file in $(NET_CFG) ; do \
     101                cp $$file $(USPACEDIR)/dist/cfg/net/ ; \
    95102        done
    96103ifeq ($(RDFMT),tmpfs)
  • uspace/srv/net/net/net.c

    r80ce111 r01a9ef5  
    7070#define NAME    "Networking"
    7171
     72/** File read buffer size.
     73 */
     74#define BUFFER_SIZE     256
     75
    7276/** Prints the module name.
    7377 *  @see NAME
     
    8488int module_start( async_client_conn_t client_connection );
    8589
    86 //int           parse_line( measured_strings_ref configuration, char * line );
     90/** \todo
     91 */
     92int     read_configuration_file( const char * directory, const char * filename, measured_strings_ref configuration );
     93
     94/** \todo
     95 */
     96int     parse_line( measured_strings_ref configuration, char * line );
    8797
    8898/** Reads the networking subsystem global configuration.
     
    274284}
    275285
    276 /*
     286int read_configuration_file( const char * directory, const char * filename, measured_strings_ref configuration ){
     287        ERROR_DECLARE;
     288
     289        size_t  index = 0;
     290        char    line[ BUFFER_SIZE ];
     291        FILE *  cfg;
     292        int             read;
     293        int             line_number = 0;
     294
     295        // construct the full filename
     296        printf( "Reading file %s/%s\n", directory, filename );
     297        if( snprintf( line, BUFFER_SIZE, "%s/%s", directory, filename ) > BUFFER_SIZE ){
     298                return EOVERFLOW;
     299        }
     300        // open the file
     301        cfg = fopen( line, "r" );
     302        if( ! cfg ){
     303                return ENOENT;
     304        }
     305
     306        // read the configuration line by line
     307        // until an error or the end of file
     308        while(( ! ferror( cfg )) && ( ! feof( cfg ))){
     309                read = fgetc( cfg );
     310                if(( read > 0 ) && ( read != '\n' ) && ( read != '\r' )){
     311                        if( index >= BUFFER_SIZE ){
     312                                line[ BUFFER_SIZE - 1 ] = '\0';
     313                                printf( "line %d too long: %s\n", line_number, line );
     314                                // no space left in the line buffer
     315                                return EOVERFLOW;
     316                        }else{
     317                                // append the character
     318                                line[ index ] = (char) read;
     319                                ++ index;
     320                        }
     321                }else{
     322                        // on error or new line
     323                        line[ index ] = '\0';
     324                        ++ line_number;
     325                        if( ERROR_OCCURRED( parse_line( configuration, line ))){
     326                                printf( "error on line %d: %s\n", line_number, line );
     327                                //fclose( cfg );
     328                                //return ERROR_CODE;
     329                        }
     330                        index = 0;
     331                }
     332        }
     333        fclose( cfg );
     334        return EOK;
     335}
     336
    277337int parse_line( measured_strings_ref configuration, char * line ){
    278338        ERROR_DECLARE;
    279339
    280340        measured_string_ref     setting;
    281         char *                  name;
    282         char *                  value;
     341        char *                          name;
     342        char *                          value;
    283343
    284344        // from the beginning
    285345        name = line;
     346
     347        // skip comments and blank lines
     348        if(( * name == '#' ) || ( * name == '\0' )){
     349                return EOK;
     350        }
    286351        // skip spaces
    287352        while( isspace( * name )) ++ name;
     353
    288354        // remember the name start
    289355        value = name;
     
    294360                ++ value;
    295361        }
     362
    296363        if( * value == '=' ){
    297364                // terminate the name
     
    306373                if( * value != '=' ) return EINVAL;
    307374        }
     375
    308376        ++ value;
    309377        // skip spaces
    310378        while( isspace( * value )) ++ value;
    311379        // create a bulk measured string till the end
    312         setting = measured_string_create_bulk( value, -1 );
     380        setting = measured_string_create_bulk( value, 0 );
    313381        if( ! setting ) return ENOMEM;
     382
    314383        // add the configuration setting
    315384        if( ERROR_OCCURRED( measured_strings_add( configuration, name, 0, setting ))){
     
    319388        return EOK;
    320389}
    321 */
    322390
    323391int add_configuration( measured_strings_ref configuration, const char * name, const char * value ){
     
    341409
    342410int read_configuration( void ){
    343         ERROR_DECLARE;
    344 
    345         // read general configuration
    346         ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "IPV", "4" ));
    347         ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "IP_ROUTING", "no" ));
    348         ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "MTU", "1500" ));
    349         ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "ICMP_ERROR_REPORTING", "yes" ));  //anything else not starting with 'y'
    350         ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "ICMP_ECHO_REPLYING", "yes" ));  //anything else not starting with 'y'
    351         ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "UDP_CHECKSUM_COMPUTING", "yes" ));  //anything else not starting with 'y'
    352         ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "UDP_AUTOBINDING", "yes" ));  //anything else not starting with 'y'
    353         return EOK;
     411        // read the general configuration file
     412        return read_configuration_file( CONF_DIR, CONF_GENERAL_FILE, & net_globals.configuration );
    354413}
    355414
    356415int read_netif_configuration( char * name, netif_ref netif ){
    357         ERROR_DECLARE;
    358 
    359         if( str_lcmp( name, "lo", 2 ) == 0 ){
    360                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", LO_NAME ));
    361                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", LO_NAME ));
    362                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME ));
    363                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
    364                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" ));
    365                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_NETMASK", "255.0.0.0" ));
    366                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "15535" ));
    367         }else if( str_lcmp( name, "ne2k", 4 ) == 0 ){
    368                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", "eth0" ));
    369                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", DP8390_NAME ));
    370                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "ETH_MODE", "DIX" )); //8023_2_LSAP( not supported ), 8023_2_SNAP
    371 //              ERROR_PROPAGATE( add_configuration( & netif->configuration, "ETH_DUMMY", "yes" )); //anything else not starting with 'y'
    372                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME ));
    373                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "IRQ", "9" ));
    374                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "IO", "300" ));
    375                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "1492" ));
    376                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
    377                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "10.0.2.15" ));
    378                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ROUTING", "yes" ));
    379                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_NETMASK", "255.255.255.240" ));
    380                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_BROADCAST", "10.0.2.255" ));
    381                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_GATEWAY", "10.0.2.2" ));
    382                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "ARP", "arp" ));
    383         }
    384         return read_netif_configuration_build( name, netif );
     416        // read the netif configuration file
     417        return read_configuration_file( CONF_DIR, name, & netif->configuration );
    385418}
    386419
     
    451484        ERROR_DECLARE;
    452485
     486#ifdef CONFIG_NETIF_DP8390
    453487        char *          conf_files[] = { "lo", "ne2k" };
     488#else
     489        char *          conf_files[] = { "lo" };
     490#endif
     491
    454492        int                     count = sizeof( conf_files ) / sizeof( char * );
    455493        int                     index;
  • uspace/srv/net/net/net.h

    r80ce111 r01a9ef5  
    128128/*@}*/
    129129
     130/** Configuration directory.
     131 */
     132#define CONF_DIR                        "/cfg/net"
     133
     134/** General configuration file.
     135 */
     136#define CONF_GENERAL_FILE       "general"
     137
    130138/** Type definition of the network interface specific data.
    131139 *  @see netif
     
    235243int     module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
    236244
    237 /** Reads the network interface specific configuration for the chosen subsystem build type.
    238  *  @param[in] name The network interface name.
    239  *  @param[in,out] netif The network interface structure.
    240  *  @returns EOK on success.
    241  *  @returns Other error codes as defined for the add_configuration() function.
    242  */
    243 int     read_netif_configuration_build( char * name, netif_ref netif );
    244 
    245245#endif
    246246
  • uspace/srv/net/net/net_bundle.c

    r80ce111 r01a9ef5  
    117117}
    118118
    119 int read_netif_configuration_build( char * name, netif_ref netif ){
    120         ERROR_DECLARE;
    121 
    122         if( str_lcmp( name, "lo", 2 ) == 0 ){
    123                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", LO_NAME ));
    124         }else if( str_lcmp( name, "ne2k", 4 ) == 0 ){
    125                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", DP8390_NAME ));
    126         }
    127         return EOK;
    128 }
    129 
    130119/** @}
    131120 */
  • uspace/srv/net/net/net_standalone.c

    r80ce111 r01a9ef5  
    7575}
    7676
    77 int read_netif_configuration_build( char * name, netif_ref netif ){
    78         ERROR_DECLARE;
    79 
    80         if( str_lcmp( name, "lo", 2 ) == 0 ){
    81                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", NILDUMMY_NAME ));
    82         }else if( str_lcmp( name, "ne2k", 4 ) == 0 ){
    83                 ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", ETHERNET_NAME ));
    84         }
    85         return EOK;
    86 }
    87 
    8877/** @}
    8978 */
Note: See TracChangeset for help on using the changeset viewer.