Subversion Repositories HelenOS

Rev

Rev 4719 | Rev 4722 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4719 Rev 4720
Line 127... Line 127...
127
 *  @param data The found configuration settings data. Output parameter.
127
 *  @param data The found configuration settings data. Output parameter.
128
 *  @returns EOK.
128
 *  @returns EOK.
129
 */
129
 */
130
int net_get_conf( measured_strings_ref netif_conf, measured_string_ref configuration, size_t count, char ** data );
130
int net_get_conf( measured_strings_ref netif_conf, measured_string_ref configuration, size_t count, char ** data );
131
 
131
 
-
 
132
/** Initializes the networking module.
-
 
133
 *  @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
-
 
134
 *  @returns EOK on success.
-
 
135
 *  @returns ENOMEM if there is not enough memory left.
-
 
136
 */
-
 
137
int net_initialize( async_client_conn_t client_connection );
-
 
138
 
-
 
139
/** Reads the network interface specific configuration.
-
 
140
 *  @param name The network interface name. Input parameter.
-
 
141
 *  @param netif The network interface structure. Input/output parameter.
-
 
142
 *  @returns EOK on success.
-
 
143
 *  @returns Other error codes as defined for the add_configuration() function.
-
 
144
 */
-
 
145
int read_netif_configuration( char * name, netif_ref netif );
-
 
146
 
132
/** Networking module global data.
147
/** Networking module global data.
133
 */
148
 */
134
net_globals_t   net_globals;
149
net_globals_t   net_globals;
135
 
150
 
136
DEVICE_MAP_IMPLEMENT( netifs, netif_t )
151
DEVICE_MAP_IMPLEMENT( netifs, netif_t )
Line 158... Line 173...
158
 
173
 
159
    pm_destroy();
174
    pm_destroy();
160
    return EOK;
175
    return EOK;
161
}
176
}
162
 
177
 
-
 
178
int net_initialize( async_client_conn_t client_connection ){
-
 
179
    ERROR_DECLARE;
-
 
180
 
-
 
181
    netifs_initialize( & net_globals.netifs );
-
 
182
    char_map_initialize( & net_globals.netif_names );
-
 
183
    modules_initialize( & net_globals.modules );
-
 
184
    measured_strings_initialize( & net_globals.configuration );
-
 
185
 
-
 
186
    // TODO dynamic configuration
-
 
187
    ERROR_PROPAGATE( read_configuration());
-
 
188
 
-
 
189
    ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, LO_NAME, LO_FILENAME, SERVICE_LO, 0, connect_to_service ));
-
 
190
    ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service ));
-
 
191
    ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service ));
-
 
192
    ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, NILDUMMY_NAME, NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service ));
-
 
193
 
-
 
194
    // build specific initialization
-
 
195
    return net_initialize_build( client_connection );
-
 
196
}
-
 
197
 
163
int net_get_device_conf_req( int net_phone, device_id_t device_id, measured_string_ref * configuration, size_t count, char ** data ){
198
int net_get_device_conf_req( int net_phone, device_id_t device_id, measured_string_ref * configuration, size_t count, char ** data ){
164
    netif_ref   netif;
199
    netif_ref   netif;
165
 
200
 
166
    if( !( configuration && ( count > 0 ))) return EINVAL;
201
    if( !( configuration && ( count > 0 ))) return EINVAL;
167
    netif = netifs_find( & net_globals.netifs, device_id );
202
    netif = netifs_find( & net_globals.netifs, device_id );
Line 311... Line 346...
311
    ERROR_DECLARE;
346
    ERROR_DECLARE;
312
 
347
 
313
    // read general configuration
348
    // read general configuration
314
    ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "IPV", "4" ));
349
    ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "IPV", "4" ));
315
    ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "MTU", "1500" ));
350
    ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "MTU", "1500" ));
-
 
351
    ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "ICMP_ERROR_REPORTING", "yes" ));  //anything else not starting with 'y'
-
 
352
    ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "ICMP_ECHO_REPLYING", "yes" ));  //anything else not starting with 'y'
316
    return EOK;
353
    return EOK;
317
}
354
}
318
 
355
 
-
 
356
int 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_ROUTING", "yes" ));
-
 
366
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" ));
-
 
367
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "15535" ));
-
 
368
    }else if( str_lcmp( name, "ne2k", 4 ) == 0 ){
-
 
369
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", "eth0" ));
-
 
370
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", DP8390_NAME ));
-
 
371
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "ETH_MODE", "DIX" )); //8023_2_LSAP( not supported ), 8023_2_SNAP
-
 
372
//      ERROR_PROPAGATE( add_configuration( & netif->configuration, "ETH_DUMMY", "yes" )); //anything else not starting with 'y'
-
 
373
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME ));
-
 
374
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IRQ", "9" ));
-
 
375
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IO", "300" ));
-
 
376
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "576" ));
-
 
377
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
-
 
378
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "10.0.2.15" ));
-
 
379
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ROUTING", "yes" ));
-
 
380
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.255.255.240" ));
-
 
381
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "BROADCAST", "10.0.2.255" ));
-
 
382
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "GATEWAY", "10.0.2.2" ));
-
 
383
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS1", "10.0.2.2" ));
-
 
384
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS2", "10.0.2.2" ));
-
 
385
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "ARP", "arp" ));
-
 
386
    }
-
 
387
    return read_netif_configuration_build( name, netif );
-
 
388
}
-
 
389
 
319
int start_device( netif_ref netif ){
390
int start_device( netif_ref netif ){
320
    ERROR_DECLARE;
391
    ERROR_DECLARE;
321
 
392
 
322
    measured_string_ref setting;
393
    measured_string_ref setting;
323
    services_t          internet_service;
394
    services_t          internet_service;
Line 387... Line 458...
387
    int         index;
458
    int         index;
388
    netif_ref   netif;
459
    netif_ref   netif;
389
    int         i;
460
    int         i;
390
    measured_string_ref setting;
461
    measured_string_ref setting;
391
 
462
 
392
    // TODO dynamic configuration
-
 
393
    ERROR_PROPAGATE( read_configuration());
-
 
394
 
-
 
395
    for( i = 0; i < count; ++ i ){
463
    for( i = 0; i < count; ++ i ){
396
        netif = ( netif_ref ) malloc( sizeof( netif_t ));
464
        netif = ( netif_ref ) malloc( sizeof( netif_t ));
397
        if( ! netif ) return ENOMEM;
465
        if( ! netif ) return ENOMEM;
398
 
466
 
399
        netif->id = generate_new_device_id();
467
        netif->id = generate_new_device_id();