Rev 4307 | Rev 4351 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4307 | Rev 4350 | ||
|---|---|---|---|
| Line 29... | Line 29... | ||
| 29 | /** @addtogroup net |
29 | /** @addtogroup net |
| 30 | * @{ |
30 | * @{ |
| 31 | */ |
31 | */ |
| 32 | 32 | ||
| 33 | /** @file |
33 | /** @file |
| - | 34 | * Networking subsystem central module implementation. |
|
| 34 | */ |
35 | */ |
| 35 | 36 | ||
| 36 | #include <async.h> |
37 | #include <async.h> |
| 37 | #include <ctype.h> |
38 | #include <ctype.h> |
| 38 | #include <ddi.h> |
39 | #include <ddi.h> |
| Line 61... | Line 62... | ||
| 61 | #include "../include/net_interface.h" |
62 | #include "../include/net_interface.h" |
| 62 | #include "../include/ip_interface.h" |
63 | #include "../include/ip_interface.h" |
| 63 | 64 | ||
| 64 | #include "net.h" |
65 | #include "net.h" |
| 65 | 66 | ||
| - | 67 | /** Networking module name. |
|
| - | 68 | */ |
|
| 66 | #define NAME "Networking" |
69 | #define NAME "Networking" |
| 67 | 70 | ||
| - | 71 | /** Prints the module name. |
|
| - | 72 | * @see NAME |
|
| - | 73 | */ |
|
| 68 | void module_print_name( void ); |
74 | void module_print_name( void ); |
| - | 75 | ||
| - | 76 | /** Starts the networking module. |
|
| - | 77 | * Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop. |
|
| - | 78 | * @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter. |
|
| - | 79 | * @returns EOK on successful module termination. |
|
| 69 | measured_string_ref configuration_find( measured_strings_ref configuration, const char * name ); |
80 | * @returns Other error codes as defined for the net_initialize() function. |
| - | 81 | * @returns Other error codes as defined for the REGISTER_ME() macro function. |
|
| - | 82 | */ |
|
| 70 | int module_start( async_client_conn_t client_connection ); |
83 | int module_start( async_client_conn_t client_connection ); |
| - | 84 | ||
| 71 | //int parse_line( measured_strings_ref configuration, char * line ); |
85 | //int parse_line( measured_strings_ref configuration, char * line ); |
| - | 86 | ||
| - | 87 | /** Reads the networking subsystem global configuration. |
|
| - | 88 | * @returns EOK on success. |
|
| - | 89 | * @returns Other error codes as defined for the add_configuration() function. |
|
| - | 90 | */ |
|
| 72 | int read_configuration( void ); |
91 | int read_configuration( void ); |
| - | 92 | ||
| - | 93 | /** Starts the network interface according to its configuration. |
|
| - | 94 | * Registers the network interface with the subsystem modules. |
|
| - | 95 | * Starts the needed subsystem modules. |
|
| - | 96 | * @param netif The network interface specific data. |
|
| - | 97 | * @returns EOK on success. |
|
| - | 98 | * @returns EINVAL if there are some settings missing. |
|
| - | 99 | * @returns ENOENT if the internet protocol module is not known. |
|
| - | 100 | * @returns Other error codes as defined for the netif_probe_req() function. |
|
| - | 101 | * @returns Other error codes as defined for the nil_device_req() function. |
|
| - | 102 | * @returns Other error codes as defined for the needed internet layer registering function. |
|
| - | 103 | */ |
|
| 73 | int start_device( netif_ref netif ); |
104 | int start_device( netif_ref netif ); |
| - | 105 | ||
| - | 106 | /** Reads the configuration and starts all network interfaces. |
|
| - | 107 | * @returns EOK on success. |
|
| - | 108 | * @returns EXDEV if there is no available system-unique device identifier. |
|
| - | 109 | * @returns EINVAL if any of the network interface names are not configured. |
|
| - | 110 | * @returns ENOMEM if there is not enough memory left. |
|
| - | 111 | * @returns Other error codes as defined for the read_configuration() function. |
|
| - | 112 | * @returns Other error codes as defined for the read_netif_configuration() function. |
|
| - | 113 | * @returns Other error codes as defined for the start_device() function. |
|
| - | 114 | */ |
|
| 74 | int startup( void ); |
115 | int startup( void ); |
| - | 116 | ||
| - | 117 | /** Generates new system-unique device identifier. |
|
| - | 118 | * @returns The system-unique devic identifier. |
|
| - | 119 | */ |
|
| 75 | device_id_t generate_new_device_id( void ); |
120 | device_id_t generate_new_device_id( void ); |
| 76 | int net_get_conf( measured_strings_ref device_conf, measured_string_ref configuration, int count, char ** data ); |
- | |
| 77 | 121 | ||
| - | 122 | /** Returns the configured values. |
|
| - | 123 | * The network interface configuration is searched first. |
|
| - | 124 | * @param netif_conf The network interface configuration setting. Input parameter. |
|
| - | 125 | * @param configuration The found configured values. Output parameter. |
|
| - | 126 | * @param count The desired settings count. Input parameter. |
|
| - | 127 | * @param data The found configuration settings data. Output parameter. |
|
| - | 128 | * @returns EOK. |
|
| - | 129 | */ |
|
| - | 130 | int net_get_conf( measured_strings_ref netif_conf, measured_string_ref configuration, int count, char ** data ); |
|
| - | 131 | ||
| - | 132 | /** Networking module global data. |
|
| - | 133 | */ |
|
| 78 | net_globals_t net_globals; |
134 | net_globals_t net_globals; |
| 79 | 135 | ||
| 80 | DEVICE_MAP_IMPLEMENT( netifs, netif_t ) |
136 | DEVICE_MAP_IMPLEMENT( netifs, netif_t ) |
| 81 | 137 | ||
| 82 | GENERIC_CHAR_MAP_IMPLEMENT( measured_strings, measured_string_t ) |
138 | GENERIC_CHAR_MAP_IMPLEMENT( measured_strings, measured_string_t ) |
| Line 119... | Line 175... | ||
| 119 | int net_get_conf_req( int net_phone, measured_string_ref * configuration, int count, char ** data ){ |
175 | int net_get_conf_req( int net_phone, measured_string_ref * configuration, int count, char ** data ){ |
| 120 | if( !( configuration && ( count > 0 ))) return EINVAL; |
176 | if( !( configuration && ( count > 0 ))) return EINVAL; |
| 121 | return net_get_conf( NULL, * configuration, count, data ); |
177 | return net_get_conf( NULL, * configuration, count, data ); |
| 122 | } |
178 | } |
| 123 | 179 | ||
| 124 | int net_get_conf( measured_strings_ref device_conf, measured_string_ref configuration, int count, char ** data ){ |
180 | int net_get_conf( measured_strings_ref netif_conf, measured_string_ref configuration, int count, char ** data ){ |
| 125 | measured_string_ref setting; |
181 | measured_string_ref setting; |
| 126 | int index; |
182 | int index; |
| 127 | 183 | ||
| 128 | if( data ) * data = NULL; |
184 | if( data ) * data = NULL; |
| 129 | for( index = 0; index < count; ++ index ){ |
185 | for( index = 0; index < count; ++ index ){ |
| 130 | setting = measured_strings_find( device_conf, configuration[ index ].value, 0 ); |
186 | setting = measured_strings_find( netif_conf, configuration[ index ].value, 0 ); |
| 131 | if( ! setting ){ |
187 | if( ! setting ){ |
| 132 | setting = measured_strings_find( & net_globals.configuration, configuration[ index ].value, 0 ); |
188 | setting = measured_strings_find( & net_globals.configuration, configuration[ index ].value, 0 ); |
| 133 | } |
189 | } |
| 134 | if( setting ){ |
190 | if( setting ){ |
| 135 | configuration[ index ].length = setting->length; |
191 | configuration[ index ].length = setting->length; |