129,6 → 129,21 |
*/ |
int net_get_conf( measured_strings_ref netif_conf, measured_string_ref configuration, size_t count, char ** data ); |
|
/** Initializes the networking module. |
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter. |
* @returns EOK on success. |
* @returns ENOMEM if there is not enough memory left. |
*/ |
int net_initialize( async_client_conn_t client_connection ); |
|
/** Reads the network interface specific configuration. |
* @param name The network interface name. Input parameter. |
* @param netif The network interface structure. Input/output parameter. |
* @returns EOK on success. |
* @returns Other error codes as defined for the add_configuration() function. |
*/ |
int read_netif_configuration( char * name, netif_ref netif ); |
|
/** Networking module global data. |
*/ |
net_globals_t net_globals; |
160,6 → 175,26 |
return EOK; |
} |
|
int net_initialize( async_client_conn_t client_connection ){ |
ERROR_DECLARE; |
|
netifs_initialize( & net_globals.netifs ); |
char_map_initialize( & net_globals.netif_names ); |
modules_initialize( & net_globals.modules ); |
measured_strings_initialize( & net_globals.configuration ); |
|
// TODO dynamic configuration |
ERROR_PROPAGATE( read_configuration()); |
|
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, LO_NAME, LO_FILENAME, SERVICE_LO, 0, connect_to_service )); |
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0, connect_to_service )); |
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0, connect_to_service )); |
ERROR_PROPAGATE( add_module( NULL, & net_globals.modules, NILDUMMY_NAME, NILDUMMY_FILENAME, SERVICE_NILDUMMY, 0, connect_to_service )); |
|
// build specific initialization |
return net_initialize_build( client_connection ); |
} |
|
int net_get_device_conf_req( int net_phone, device_id_t device_id, measured_string_ref * configuration, size_t count, char ** data ){ |
netif_ref netif; |
|
313,9 → 348,45 |
// read general configuration |
ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "IPV", "4" )); |
ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "MTU", "1500" )); |
ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "ICMP_ERROR_REPORTING", "yes" )); //anything else not starting with 'y' |
ERROR_PROPAGATE( add_configuration( & net_globals.configuration, "ICMP_ECHO_REPLYING", "yes" )); //anything else not starting with 'y' |
return EOK; |
} |
|
int read_netif_configuration( char * name, netif_ref netif ){ |
ERROR_DECLARE; |
|
if( str_lcmp( name, "lo", 2 ) == 0 ){ |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", LO_NAME )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", LO_NAME )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ROUTING", "yes" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "15535" )); |
}else if( str_lcmp( name, "ne2k", 4 ) == 0 ){ |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", "eth0" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", DP8390_NAME )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "ETH_MODE", "DIX" )); //8023_2_LSAP( not supported ), 8023_2_SNAP |
// ERROR_PROPAGATE( add_configuration( & netif->configuration, "ETH_DUMMY", "yes" )); //anything else not starting with 'y' |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IRQ", "9" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IO", "300" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "576" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "10.0.2.15" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ROUTING", "yes" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.255.255.240" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "BROADCAST", "10.0.2.255" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "GATEWAY", "10.0.2.2" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS1", "10.0.2.2" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS2", "10.0.2.2" )); |
ERROR_PROPAGATE( add_configuration( & netif->configuration, "ARP", "arp" )); |
} |
return read_netif_configuration_build( name, netif ); |
} |
|
int start_device( netif_ref netif ){ |
ERROR_DECLARE; |
|
389,9 → 460,6 |
int i; |
measured_string_ref setting; |
|
// TODO dynamic configuration |
ERROR_PROPAGATE( read_configuration()); |
|
for( i = 0; i < count; ++ i ){ |
netif = ( netif_ref ) malloc( sizeof( netif_t )); |
if( ! netif ) return ENOMEM; |