Subversion Repositories HelenOS

Rev

Rev 4197 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4197 Rev 4243
1
/*
1
/*
2
 * Copyright (c) 2009 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:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup net
29
/** @addtogroup net
30
 *  @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
/** @file
33
/** @file
34
 */
34
 */
35
 
35
 
36
#include <async.h>
36
#include <async.h>
37
#include <ctype.h>
37
#include <ctype.h>
38
#include <ddi.h>
38
#include <ddi.h>
39
#include <errno.h>
39
#include <errno.h>
40
#include <malloc.h>
40
#include <malloc.h>
41
#include <stdio.h>
41
#include <stdio.h>
42
 
42
 
43
#include <ipc/ipc.h>
43
#include <ipc/ipc.h>
44
#include <ipc/services.h>
44
#include <ipc/services.h>
45
 
45
 
46
#include "../err.h"
46
#include "../err.h"
47
#include "../messages.h"
47
#include "../messages.h"
48
#include "../modules.h"
48
#include "../modules.h"
49
//#include "../self_test.h"
49
//#include "../self_test.h"
50
 
50
 
51
#include "../structures/char_map.h"
51
#include "../structures/char_map.h"
52
#include "../structures/generic_char_map.h"
52
#include "../structures/generic_char_map.h"
53
#include "../structures/measured_strings.h"
53
#include "../structures/measured_strings.h"
54
#include "../structures/module_map.h"
54
#include "../structures/module_map.h"
55
#include "../structures/packet/packet.h"
55
#include "../structures/packet/packet.h"
56
#include "../structures/packet/packet_server.h"
56
#include "../structures/packet/packet_server.h"
57
 
57
 
58
#include "../il/ip/ip_messages.h"
58
#include "../il/ip/ip_messages.h"
59
#include "../netif/device.h"
59
#include "../include/device.h"
-
 
60
#include "../include/netif_messages.h"
60
 
61
 
61
#if IP_BUNDLE
62
#if IP_BUNDLE
62
 
63
 
63
    #include "../ip/ip_module.h"
64
    #include "../ip/ip_module.h"
64
 
65
 
65
#endif
66
#endif
66
 
67
 
67
#if TCP_BUNDLE
68
#if TCP_BUNDLE
68
 
69
 
69
    #include "../tcp/tcp_module.h"
70
    #include "../tcp/tcp_module.h"
70
 
71
 
71
#endif
72
#endif
72
 
73
 
73
#define NAME    "Networking"
74
#define NAME    "Networking"
74
 
75
 
75
#define LO_NAME             "lo"
76
#define LO_NAME             "lo"
76
#define LO_FILENAME         "/srv/lo"
77
#define LO_FILENAME         "/srv/lo"
77
#define DP8390_NAME         "dp8390"
78
#define DP8390_NAME         "dp8390"
78
#define DP8390_FILENAME     "/srv/dp8390"
79
#define DP8390_FILENAME     "/srv/dp8390"
79
#define ETHERNET_NAME       "ethernet"
80
#define ETHERNET_NAME       "ethernet"
80
#define ETHERNET_FILENAME   "/srv/eth"
81
#define ETHERNET_FILENAME   "/srv/eth"
81
#define IP_NAME             "ip"
82
#define IP_NAME             "ip"
82
#define IP_FILENAME         "/srv/ip"
83
#define IP_FILENAME         "/srv/ip"
83
 
84
 
84
#define CONF_NAME           "NAME"
85
#define CONF_NAME           "NAME"
85
#define CONF_NETIF          "NETIF"
86
#define CONF_NETIF          "NETIF"
86
#define CONF_NIL            "NIL"
87
#define CONF_NIL            "NIL"
87
#define CONF_IL             "IL"
88
#define CONF_IL             "IL"
88
#define CONF_IRQ            "IRQ"
89
#define CONF_IRQ            "IRQ"
89
#define CONF_IO             "IO"
90
#define CONF_IO             "IO"
90
#define CONF_MTU            "MTU"
91
#define CONF_MTU            "MTU"
91
 
92
 
92
#define IPC_GET_DEVICE( call )  ( device_id_t ) IPC_GET_ARG1( * call )
93
#define IPC_GET_DEVICE( call )  ( device_id_t ) IPC_GET_ARG1( * call )
93
#define IPC_GET_COUNT( call )   ( int ) IPC_GET_ARG2( * call )
94
#define IPC_GET_COUNT( call )   ( int ) IPC_GET_ARG2( * call )
94
 
95
 
95
typedef struct netif        netif_t;
96
typedef struct netif        netif_t;
96
typedef netif_t *       netif_ref;
97
typedef netif_t *       netif_ref;
97
 
98
 
98
typedef struct networking_globals   networking_globals_t;
99
typedef struct networking_globals   networking_globals_t;
99
 
100
 
100
DEVICE_MAP_DECLARE( netifs, netif_t )
101
DEVICE_MAP_DECLARE( netifs, netif_t )
101
 
102
 
102
GENERIC_CHAR_MAP_DECLARE( measured_strings, measured_string_t )
103
GENERIC_CHAR_MAP_DECLARE( measured_strings, measured_string_t )
103
 
104
 
104
/** A present network interface device.
105
/** A present network interface device.
105
 */
106
 */
106
struct netif{
107
struct netif{
107
    /** A system-unique network interface identifier.
108
    /** A system-unique network interface identifier.
108
     */
109
     */
109
    device_id_t     id;
110
    device_id_t     id;
110
    /** A serving network interface driver module index.
111
    /** A serving network interface driver module index.
111
     */
112
     */
112
    module_ref      driver;
113
    module_ref      driver;
113
    /** A serving link layer module index.
114
    /** A serving link layer module index.
114
     */
115
     */
115
    module_ref      nil;
116
    module_ref      nil;
116
    /** A serving internet layer module index.
117
    /** A serving internet layer module index.
117
     */
118
     */
118
    module_ref      il;
119
    module_ref      il;
119
    /** A system-unique network interface name.
120
    /** A system-unique network interface name.
120
     */
121
     */
121
    char *          name;
122
    char *          name;
122
    /** Configuration.
123
    /** Configuration.
123
     */
124
     */
124
    measured_strings_t  configuration;
125
    measured_strings_t  configuration;
125
};
126
};
126
 
127
 
127
/** A networking module global variables.
128
/** A networking module global variables.
128
 */
129
 */
129
struct networking_globals{
130
struct networking_globals{
130
    /** Present network interfaces.
131
    /** Present network interfaces.
131
     */
132
     */
132
    netifs_t        netifs;
133
    netifs_t        netifs;
133
    /** Network interface structure indices by names.
134
    /** Network interface structure indices by names.
134
     */
135
     */
135
    char_map_t      netif_names;
136
    char_map_t      netif_names;
136
    /** Available modules.
137
    /** Available modules.
137
     */
138
     */
138
    modules_t       modules;
139
    modules_t       modules;
139
    /** Global configuration.
140
    /** Global configuration.
140
     */
141
     */
141
    measured_strings_t  configuration;
142
    measured_strings_t  configuration;
142
};
143
};
143
 
144
 
144
void    networking_print_name( void );
145
void    networking_print_name( void );
145
measured_string_ref configuration_find( measured_strings_ref configuration, const char * name );
146
measured_string_ref configuration_find( measured_strings_ref configuration, const char * name );
146
int networking_start_module( async_client_conn_t client_connection );
147
int networking_start_module( async_client_conn_t client_connection );
147
int     networking_initialize( void );
148
int     networking_initialize( void );
148
int networking_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
149
int networking_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
149
int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
150
int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
150
//int       parse_line( measured_strings_ref configuration, char * line );
151
//int       parse_line( measured_strings_ref configuration, char * line );
151
int     add_configuration( measured_strings_ref configuration, const char * name, const char * value );
152
int     add_configuration( measured_strings_ref configuration, const char * name, const char * value );
152
int     read_configuration( void );
153
int     read_configuration( void );
153
int     read_netif_configuration( char * name, netif_ref netif );
154
int     read_netif_configuration( char * name, netif_ref netif );
154
int     start_device( netif_ref netif );
155
int     start_device( netif_ref netif );
155
int     startup( void );
156
int     startup( void );
156
device_id_t generate_new_device_id( void );
157
device_id_t generate_new_device_id( void );
157
 
158
 
158
static networking_globals_t networking_globals;
159
static networking_globals_t networking_globals;
159
 
160
 
160
DEVICE_MAP_IMPLEMENT( netifs, netif_t )
161
DEVICE_MAP_IMPLEMENT( netifs, netif_t )
161
 
162
 
162
GENERIC_CHAR_MAP_IMPLEMENT( measured_strings, measured_string_t )
163
GENERIC_CHAR_MAP_IMPLEMENT( measured_strings, measured_string_t )
163
 
164
 
164
void networking_print_name( void ){
165
void networking_print_name( void ){
165
    printf( "%s", NAME );
166
    printf( "%s", NAME );
166
}
167
}
167
 
168
 
168
int networking_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
169
int networking_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
169
#ifdef NETWORKING_module
170
#ifdef NETWORKING_module
170
        //TODO map to *_message
171
        //TODO map to *_message
171
        if( IS_NET_IL_MESSAGE( call ) || IS_NET_IP_MESSAGE( call )){
172
        if( IS_NET_IL_MESSAGE( call ) || IS_NET_IP_MESSAGE( call )){
172
            return ip_message( callid, call, answer, answer_count );
173
            return ip_message( callid, call, answer, answer_count );
173
/*      }else if( IS_NET_ARP_MESSAGE( call )){
174
/*      }else if( IS_NET_ARP_MESSAGE( call )){
174
            return arp_message( callid, call, answer, answer_count );
175
            return arp_message( callid, call, answer, answer_count );
175
*//*        }else if( IS_NET_RARP_MESSAGE( call )){
176
*//*        }else if( IS_NET_RARP_MESSAGE( call )){
176
            return rarp_message( callid, call, answer, answer_count );
177
            return rarp_message( callid, call, answer, answer_count );
177
*//*        }else if( IS_NET_ICMP_MESSAGE( call )){
178
*//*        }else if( IS_NET_ICMP_MESSAGE( call )){
178
            return icmp_message( callid, call, answer, answer_count );
179
            return icmp_message( callid, call, answer, answer_count );
179
*//*        }else if( IS_NET_UDP_MESSAGE( call )){
180
*//*        }else if( IS_NET_UDP_MESSAGE( call )){
180
            return udp_message( callid, call, answer, answer_count );
181
            return udp_message( callid, call, answer, answer_count );
181
*/      }else if( IS_NET_TCP_MESSAGE( call )){
182
*/      }else if( IS_NET_TCP_MESSAGE( call )){
182
            return tcp_message( callid, call, answer, answer_count );
183
            return tcp_message( callid, call, answer, answer_count );
183
/*      }else if( IS_NET_SOCKET_MESSAGE( call )){
184
/*      }else if( IS_NET_SOCKET_MESSAGE( call )){
184
            return socket_message( callid, call, answer, answer_count );
185
            return socket_message( callid, call, answer, answer_count );
185
*//*        }else if( IS_NET_NIL_MESSAGE( call ) || IS_NET_ETHERNET_MESSAGE( call )){
186
*//*        }else if( IS_NET_NIL_MESSAGE( call ) || IS_NET_ETHERNET_MESSAGE( call )){
186
            return ethernet_message( callid, call, answer, answer_count );
187
            return ethernet_message( callid, call, answer, answer_count );
187
*/      }else{
188
*/      }else{
188
#endif
189
#endif
189
            if( IS_NET_PACKET_MESSAGE( call )){
190
            if( IS_NET_PACKET_MESSAGE( call )){
190
                return packet_server_message( callid, call, answer, answer_count );
191
                return packet_server_message( callid, call, answer, answer_count );
191
            }else{
192
            }else{
192
                return net_message( callid, call, answer, answer_count );
193
                return net_message( callid, call, answer, answer_count );
193
            }
194
            }
194
#ifdef NETWORKING_module
195
#ifdef NETWORKING_module
195
        }
196
        }
196
#endif
197
#endif
197
}
198
}
198
 
199
 
199
int networking_start_module( async_client_conn_t client_connection ){
200
int networking_start_module( async_client_conn_t client_connection ){
200
    ERROR_DECLARE;
201
    ERROR_DECLARE;
201
 
202
 
202
    ipcarg_t    phonehash;
203
    ipcarg_t    phonehash;
203
 
204
 
204
    async_set_client_connection( client_connection );
205
    async_set_client_connection( client_connection );
205
    ERROR_PROPAGATE( pm_init());
206
    ERROR_PROPAGATE( pm_init());
206
    if( ERROR_OCCURRED( networking_initialize())
207
    if( ERROR_OCCURRED( networking_initialize())
207
    || ERROR_OCCURRED( REGISTER_ME( SERVICE_NETWORKING, & phonehash ))){
208
    || ERROR_OCCURRED( REGISTER_ME( SERVICE_NETWORKING, & phonehash ))){
208
        pm_destroy();
209
        pm_destroy();
209
        return ERROR_CODE;
210
        return ERROR_CODE;
210
    }
211
    }
211
 
212
 
212
    async_manager();
213
    async_manager();
213
 
214
 
214
    pm_destroy();
215
    pm_destroy();
215
    return EOK;
216
    return EOK;
216
}
217
}
217
 
218
 
218
int networking_initialize( void ){
219
int networking_initialize( void ){
219
    ERROR_DECLARE;
220
    ERROR_DECLARE;
220
 
221
 
221
    task_id_t   task_id;
222
    task_id_t   task_id;
222
 
223
 
223
    netifs_initialize( & networking_globals.netifs );
224
    netifs_initialize( & networking_globals.netifs );
224
    char_map_initialize( & networking_globals.netif_names );
225
    char_map_initialize( & networking_globals.netif_names );
225
    modules_initialize( & networking_globals.modules );
226
    modules_initialize( & networking_globals.modules );
226
    measured_strings_initialize( & networking_globals.configuration );
227
    measured_strings_initialize( & networking_globals.configuration );
227
 
228
 
228
    // run self tests
229
    // run self tests
229
//  ERROR_PROPAGATE( self_test());
230
//  ERROR_PROPAGATE( self_test());
230
 
231
 
231
    ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, LO_NAME, LO_FILENAME, SERVICE_LO, 0 ));
232
    ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, LO_NAME, LO_FILENAME, SERVICE_LO, 0 ));
232
    ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0 ));
233
    ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0 ));
233
    ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0 ));
234
    ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0 ));
234
 
235
 
235
#ifdef NETWORKING_modular
236
#ifdef NETWORKING_modular
236
    task_id = spawn( "/srv/ip" );
237
    task_id = spawn( "/srv/ip" );
237
    if( ! task_id ) return EINVAL;
238
    if( ! task_id ) return EINVAL;
238
    ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_id ));
239
    ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_id ));
239
//  if( ! spawn( "/srv/udp" )) return EINVAL;
240
//  if( ! spawn( "/srv/udp" )) return EINVAL;
240
//  if( ! spawn( "/srv/tcp" )) return EINVAL;
241
//  if( ! spawn( "/srv/tcp" )) return EINVAL;
241
//  if( ! spawn( "/srv/socket" )) return EINVAL;
242
//  if( ! spawn( "/srv/socket" )) return EINVAL;
242
//  not always necesssary
243
//  not always necesssary
243
//  if( ! spawn( "/srv/arp" )) return EINVAL;
244
//  if( ! spawn( "/srv/arp" )) return EINVAL;
244
//  if( ! spawn( "/srv/rarp" )) return EINVAL;
245
//  if( ! spawn( "/srv/rarp" )) return EINVAL;
245
//  if( ! spawn( "/srv/icmp" )) return EINVAL;
246
//  if( ! spawn( "/srv/icmp" )) return EINVAL;
246
 
247
 
247
#else
248
#else
248
#ifdef NETWORKING_module
249
#ifdef NETWORKING_module
249
    ipcarg_t    phonehash;
250
    ipcarg_t    phonehash;
250
 
251
 
251
    ERROR_PROPAGATE( REGISTER_ME( SERVICE_IP, & phonehash ));
252
    ERROR_PROPAGATE( REGISTER_ME( SERVICE_IP, & phonehash ));
252
    ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_get_id()));
253
    ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_get_id()));
253
    ERROR_PROPAGATE( ip_initialize());
254
    ERROR_PROPAGATE( ip_initialize());
254
//  ERROR_PROPAGATE( REGISTER_ME( SERVICE_ARP, & phonehash ));
255
//  ERROR_PROPAGATE( REGISTER_ME( SERVICE_ARP, & phonehash ));
255
//  ERROR_PROPAGATE( arp_initialize());
256
//  ERROR_PROPAGATE( arp_initialize());
256
//  ERROR_PROPAGATE( REGISTER_ME( SERVICE_RARP, & phonehash ));
257
//  ERROR_PROPAGATE( REGISTER_ME( SERVICE_RARP, & phonehash ));
257
//  ERROR_PROPAGATE( rarp_initialize());
258
//  ERROR_PROPAGATE( rarp_initialize());
258
//  ERROR_PROPAGATE( REGISTER_ME( SERVICE_ICMP, & phonehash ));
259
//  ERROR_PROPAGATE( REGISTER_ME( SERVICE_ICMP, & phonehash ));
259
//  ERROR_PROPAGATE( icmp_initialize());
260
//  ERROR_PROPAGATE( icmp_initialize());
260
//  ERROR_PROPAGATE( REGISTER_ME( SERVICE_UDP, & phonehash ));
261
//  ERROR_PROPAGATE( REGISTER_ME( SERVICE_UDP, & phonehash ));
261
//  ERROR_PROPAGATE( udp_initialize());
262
//  ERROR_PROPAGATE( udp_initialize());
262
    ERROR_PROPAGATE( REGISTER_ME( SERVICE_TCP, & phonehash ));
263
    ERROR_PROPAGATE( REGISTER_ME( SERVICE_TCP, & phonehash ));
263
    ERROR_PROPAGATE( tcp_initialize());
264
    ERROR_PROPAGATE( tcp_initialize());
264
//  ERROR_PROPAGATE( REGISTER_ME( SERVICE_SOCKET, & phonehash ));
265
//  ERROR_PROPAGATE( REGISTER_ME( SERVICE_SOCKET, & phonehash ));
265
//  ERROR_PROPAGATE( socket_initialize());
266
//  ERROR_PROPAGATE( socket_initialize());
266
//  ERROR_PROPAGATE( REGISTER_ME( SERVICE_ETHERNET, & phonehash ));
267
//  ERROR_PROPAGATE( REGISTER_ME( SERVICE_ETHERNET, & phonehash ));
267
//  ERROR_PROPAGATE( ethernet_initialize());
268
//  ERROR_PROPAGATE( ethernet_initialize());
268
#endif
269
#endif
269
#endif
270
#endif
270
 
271
 
271
    return EOK;
272
    return EOK;
272
}
273
}
273
 
274
 
274
//TODO as ip.c
275
//TODO as ip.c
275
int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
276
int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
276
    ERROR_DECLARE;
277
    ERROR_DECLARE;
277
 
278
 
278
    measured_string_ref strings;
279
    measured_string_ref strings;
279
    char *          data;
280
    char *          data;
280
    int         index;
281
    int         index;
281
    measured_string_ref setting;
282
    measured_string_ref setting;
282
    measured_strings_ref    configuration;
283
    measured_strings_ref    configuration;
283
    netif_ref       netif;
284
    netif_ref       netif;
284
 
285
 
285
    * answer_count = 0;
286
    * answer_count = 0;
286
    switch( IPC_GET_METHOD( * call )){
287
    switch( IPC_GET_METHOD( * call )){
287
        case IPC_M_PHONE_HUNGUP:
288
        case IPC_M_PHONE_HUNGUP:
288
            return EOK;
289
            return EOK;
289
        case NET_NET_DEVICE:
290
        case NET_NET_DEVICE:
290
            // TODO configure, register
291
            // TODO configure, register
291
            printf( "\nNetworking: new netif %d", IPC_GET_DEVICE( call ));
292
            printf( "\nNetworking: new netif %d", IPC_GET_DEVICE( call ));
292
            return EOK;
293
            return EOK;
293
        case NET_NET_GET_DEVICE_CONF:
294
        case NET_NET_GET_DEVICE_CONF:
294
            ERROR_PROPAGATE( measured_strings_receive( & strings, & data, IPC_GET_COUNT( call )));
295
            ERROR_PROPAGATE( measured_strings_receive( & strings, & data, IPC_GET_COUNT( call )));
295
            netif = netifs_find( & networking_globals.netifs, IPC_GET_DEVICE( call ));
296
            netif = netifs_find( & networking_globals.netifs, IPC_GET_DEVICE( call ));
296
            if( netif ){
297
            if( netif ){
297
                configuration = & netif->configuration;
298
                configuration = & netif->configuration;
298
            }else{
299
            }else{
299
                configuration = NULL;
300
                configuration = NULL;
300
            }
301
            }
301
            for( index = 0; index < IPC_GET_COUNT( call ); ++ index ){
302
            for( index = 0; index < IPC_GET_COUNT( call ); ++ index ){
302
                setting = measured_strings_find( configuration, strings[ index ].value, 0 );
303
                setting = measured_strings_find( configuration, strings[ index ].value, 0 );
303
                if( ! setting ){
304
                if( ! setting ){
304
                    setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value, 0 );
305
                    setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value, 0 );
305
                }
306
                }
306
                if( setting ){
307
                if( setting ){
307
                    strings[ index ].length = setting->length;
308
                    strings[ index ].length = setting->length;
308
                    strings[ index ].value = setting->value;
309
                    strings[ index ].value = setting->value;
309
                }else{
310
                }else{
310
                    strings[ index ].length = 0;
311
                    strings[ index ].length = 0;
311
                    strings[ index ].value = NULL;
312
                    strings[ index ].value = NULL;
312
                }
313
                }
313
            }
314
            }
314
            // strings should not contain received data anymore
315
            // strings should not contain received data anymore
315
            free( data );
316
            free( data );
316
            ERROR_CODE = measured_strings_reply( strings, IPC_GET_COUNT( call ));
317
            ERROR_CODE = measured_strings_reply( strings, IPC_GET_COUNT( call ));
317
            free( strings );
318
            free( strings );
318
            return ERROR_CODE;
319
            return ERROR_CODE;
319
        case NET_NET_GET_CONF:
320
        case NET_NET_GET_CONF:
320
            // arg1 = count
321
            // arg1 = count
321
            ERROR_PROPAGATE( measured_strings_receive( & strings, & data, IPC_GET_COUNT( call )));
322
            ERROR_PROPAGATE( measured_strings_receive( & strings, & data, IPC_GET_COUNT( call )));
322
            for( index = 0; index < IPC_GET_COUNT( call ); ++ index ){
323
            for( index = 0; index < IPC_GET_COUNT( call ); ++ index ){
323
                setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value, 0 );
324
                setting = measured_strings_find( & networking_globals.configuration, strings[ index ].value, 0 );
324
                if( setting ){
325
                if( setting ){
325
                    strings[ index ].length = setting->length;
326
                    strings[ index ].length = setting->length;
326
                    strings[ index ].value = setting->value;
327
                    strings[ index ].value = setting->value;
327
                }else{
328
                }else{
328
                    strings[ index ].length = 0;
329
                    strings[ index ].length = 0;
329
                    strings[ index ].value = NULL;
330
                    strings[ index ].value = NULL;
330
                }
331
                }
331
            }
332
            }
332
            // strings should not contain received data anymore
333
            // strings should not contain received data anymore
333
            free( data );
334
            free( data );
334
            ERROR_CODE = measured_strings_reply( strings, IPC_GET_COUNT( call ));
335
            ERROR_CODE = measured_strings_reply( strings, IPC_GET_COUNT( call ));
335
            free( strings );
336
            free( strings );
336
            return ERROR_CODE;
337
            return ERROR_CODE;
337
        case NET_NET_STARTUP:
338
        case NET_NET_STARTUP:
338
            return startup();
339
            return startup();
339
    }
340
    }
340
    return ENOTSUP;
341
    return ENOTSUP;
341
}
342
}
342
 
343
 
343
/*
344
/*
344
int parse_line( measured_strings_ref configuration, char * line ){
345
int parse_line( measured_strings_ref configuration, char * line ){
345
    ERROR_DECLARE;
346
    ERROR_DECLARE;
346
 
347
 
347
    measured_string_ref setting;
348
    measured_string_ref setting;
348
    char *          name;
349
    char *          name;
349
    char *          value;
350
    char *          value;
350
 
351
 
351
    // from the beginning
352
    // from the beginning
352
    name = line;
353
    name = line;
353
    // skip spaces
354
    // skip spaces
354
    while( isspace( * name )) ++ name;
355
    while( isspace( * name )) ++ name;
355
    // remember the name start
356
    // remember the name start
356
    value = name;
357
    value = name;
357
    // skip the name
358
    // skip the name
358
    while( isalnum( * value ) || ( * value == '_' )){
359
    while( isalnum( * value ) || ( * value == '_' )){
359
        // make uppercase
360
        // make uppercase
360
//      * value = toupper( * value );
361
//      * value = toupper( * value );
361
        ++ value;
362
        ++ value;
362
    }
363
    }
363
    if( * value == '=' ){
364
    if( * value == '=' ){
364
        // terminate the name
365
        // terminate the name
365
        * value = '\0';
366
        * value = '\0';
366
    }else{
367
    }else{
367
        // terminate the name
368
        // terminate the name
368
        * value = '\0';
369
        * value = '\0';
369
        // skip until '='
370
        // skip until '='
370
        ++ value;
371
        ++ value;
371
        while(( * value ) && ( * value != '=' )) ++ value;
372
        while(( * value ) && ( * value != '=' )) ++ value;
372
        // not found?
373
        // not found?
373
        if( * value != '=' ) return EINVAL;
374
        if( * value != '=' ) return EINVAL;
374
    }
375
    }
375
    ++ value;
376
    ++ value;
376
    // skip spaces
377
    // skip spaces
377
    while( isspace( * value )) ++ value;
378
    while( isspace( * value )) ++ value;
378
    // create a bulk measured string till the end
379
    // create a bulk measured string till the end
379
    setting = measured_string_create_bulk( value, -1 );
380
    setting = measured_string_create_bulk( value, -1 );
380
    if( ! setting ) return ENOMEM;
381
    if( ! setting ) return ENOMEM;
381
    // add the configuration setting
382
    // add the configuration setting
382
    if( ERROR_OCCURRED( measured_strings_add( configuration, name, 0, setting ))){
383
    if( ERROR_OCCURRED( measured_strings_add( configuration, name, 0, setting ))){
383
        free( setting );
384
        free( setting );
384
        return ERROR_CODE;
385
        return ERROR_CODE;
385
    }
386
    }
386
    return EOK;
387
    return EOK;
387
}
388
}
388
*/
389
*/
389
 
390
 
390
int add_configuration( measured_strings_ref configuration, const char * name, const char * value ){
391
int add_configuration( measured_strings_ref configuration, const char * name, const char * value ){
391
    ERROR_DECLARE;
392
    ERROR_DECLARE;
392
 
393
 
393
    measured_string_ref setting;
394
    measured_string_ref setting;
394
 
395
 
395
    setting = measured_string_create_bulk( value, 0 );
396
    setting = measured_string_create_bulk( value, 0 );
396
    if( ! setting ) return ENOMEM;
397
    if( ! setting ) return ENOMEM;
397
    // add the configuration setting
398
    // add the configuration setting
398
    if( ERROR_OCCURRED( measured_strings_add( configuration, name, 0, setting ))){
399
    if( ERROR_OCCURRED( measured_strings_add( configuration, name, 0, setting ))){
399
        free( setting );
400
        free( setting );
400
        return ERROR_CODE;
401
        return ERROR_CODE;
401
    }
402
    }
402
    return EOK;
403
    return EOK;
403
}
404
}
404
 
405
 
405
device_id_t generate_new_device_id( void ){
406
device_id_t generate_new_device_id( void ){
406
    return device_assign_devno();
407
    return device_assign_devno();
407
}
408
}
408
 
409
 
409
int read_configuration( void ){
410
int read_configuration( void ){
410
    ERROR_DECLARE;
411
    ERROR_DECLARE;
411
 
412
 
412
    // read general configuration
413
    // read general configuration
413
    ERROR_PROPAGATE( add_configuration( & networking_globals.configuration, "IPV", "4" ));
414
    ERROR_PROPAGATE( add_configuration( & networking_globals.configuration, "IPV", "4" ));
414
    ERROR_PROPAGATE( add_configuration( & networking_globals.configuration, "MTU", "1500" ));
415
    ERROR_PROPAGATE( add_configuration( & networking_globals.configuration, "MTU", "1500" ));
415
    return EOK;
416
    return EOK;
416
}
417
}
417
 
418
 
418
int read_netif_configuration( char * name, netif_ref netif ){
419
int read_netif_configuration( char * name, netif_ref netif ){
419
    ERROR_DECLARE;
420
    ERROR_DECLARE;
420
 
421
 
421
    if( strncmp( name, "lo", 2 ) == 0 ){
422
    if( strncmp( name, "lo", 2 ) == 0 ){
422
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", LO_NAME ));
423
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", LO_NAME ));
423
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", LO_NAME ));
424
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", LO_NAME ));
424
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME ));
425
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME ));
425
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
426
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
426
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" ));
427
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" ));
427
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" ));
428
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" ));
428
    }else if( strncmp( name, "ne2k", 4 ) == 0 ){
429
    }else if( strncmp( name, "ne2k", 4 ) == 0 ){
429
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", "eth0" ));
430
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", "eth0" ));
430
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", DP8390_NAME ));
431
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", DP8390_NAME ));
431
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", ETHERNET_NAME ));
432
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", ETHERNET_NAME ));
432
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME ));
433
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME ));
433
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IRQ", "9" ));
434
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IRQ", "9" ));
434
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IO", "300" ));
435
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IO", "300" ));
-
 
436
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "1492" ));
435
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
437
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" ));
436
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "10.0.2.5" ));
438
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "10.0.2.5" ));
437
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.255.255.0" ));
439
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.255.255.0" ));
438
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "BROADCAST", "10.0.2.255" ));
440
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "BROADCAST", "10.0.2.255" ));
439
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "GATEWAY", "10.0.2.2" ));
441
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "GATEWAY", "10.0.2.2" ));
440
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS1", "10.0.2.2" ));
442
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS1", "10.0.2.2" ));
441
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS2", "10.0.2.2" ));
443
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "DNS2", "10.0.2.2" ));
442
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "ARP", "arp" ));
444
        ERROR_PROPAGATE( add_configuration( & netif->configuration, "ARP", "arp" ));
443
    }
445
    }
444
    return EOK;
446
    return EOK;
445
}
447
}
446
 
448
 
447
int start_device( netif_ref netif ){
449
int start_device( netif_ref netif ){
448
    ERROR_DECLARE;
450
    ERROR_DECLARE;
449
 
451
 
450
    measured_string_ref setting;
452
    measured_string_ref setting;
451
    services_t          internet_service;
453
    services_t          internet_service;
452
    int                 irq;
454
    int                 irq;
453
    int                 io;
455
    int                 io;
454
    int                 mtu;
456
    int                 mtu;
455
 
457
 
456
    // mandatory netif
458
    // mandatory netif
457
    setting = measured_strings_find( & netif->configuration, CONF_NETIF, 0 );
459
    setting = measured_strings_find( & netif->configuration, CONF_NETIF, 0 );
458
    netif->driver = get_running_module( & networking_globals.modules, setting->value );
460
    netif->driver = get_running_module( & networking_globals.modules, setting->value );
459
    if( ! netif->driver ){
461
    if( ! netif->driver ){
460
        printf( "\nFailed to start the network interface driver %s", setting->value );
462
        printf( "\nFailed to start the network interface driver %s", setting->value );
461
        return EINVAL;
463
        return EINVAL;
462
    }
464
    }
463
    // optional network interface layer
465
    // optional network interface layer
464
    setting = measured_strings_find( & netif->configuration, CONF_NIL, 0 );
466
    setting = measured_strings_find( & netif->configuration, CONF_NIL, 0 );
465
    if( setting ){
467
    if( setting ){
466
        netif->nil = get_running_module( & networking_globals.modules, setting->value );
468
        netif->nil = get_running_module( & networking_globals.modules, setting->value );
467
        if( ! netif->nil ){
469
        if( ! netif->nil ){
468
            printf( "\nFailed to start the network interface layer %s", setting->value );
470
            printf( "\nFailed to start the network interface layer %s", setting->value );
469
            return EINVAL;
471
            return EINVAL;
470
        }
472
        }
471
    }else{
473
    }else{
472
        netif->nil = NULL;
474
        netif->nil = NULL;
473
    }
475
    }
474
    // mandatory internet layer
476
    // mandatory internet layer
475
    setting = measured_strings_find( & netif->configuration, CONF_IL, 0 );
477
    setting = measured_strings_find( & netif->configuration, CONF_IL, 0 );
476
    netif->il = get_running_module( & networking_globals.modules, setting->value );
478
    netif->il = get_running_module( & networking_globals.modules, setting->value );
477
    if( ! netif->il ){
479
    if( ! netif->il ){
478
        printf( "\nFailed to start the internet layer %s", setting->value );
480
        printf( "\nFailed to start the internet layer %s", setting->value );
479
        return EINVAL;
481
        return EINVAL;
480
    }
482
    }
481
    // end of the static loopback initialization
483
    // end of the static loopback initialization
482
    // startup the loopback interface
484
    // startup the loopback interface
483
    setting = measured_strings_find( & netif->configuration, CONF_IRQ, 0 );
485
    setting = measured_strings_find( & netif->configuration, CONF_IRQ, 0 );
484
    irq = setting ? strtol( setting->value, NULL, 10 ) : 0;
486
    irq = setting ? strtol( setting->value, NULL, 10 ) : 0;
485
    setting = measured_strings_find( & netif->configuration, CONF_IO, 0 );
487
    setting = measured_strings_find( & netif->configuration, CONF_IO, 0 );
486
    io = setting ? strtol( setting->value, NULL, 16 ) : 0;
488
    io = setting ? strtol( setting->value, NULL, 16 ) : 0;
487
    ERROR_PROPAGATE( async_req_3_0( netif->driver->phone, NET_NETIF_PROBE, netif->id, irq, io ));
489
    ERROR_PROPAGATE( netif_probe_req( netif->driver->phone, netif->id, irq, io ));
488
    if( netif->nil ){
490
    if( netif->nil ){
489
        setting = measured_strings_find( & netif->configuration, CONF_MTU, 0 );
491
        setting = measured_strings_find( & netif->configuration, CONF_MTU, 0 );
490
        if( ! setting ){
492
        if( ! setting ){
491
            setting = measured_strings_find( & networking_globals.configuration, CONF_MTU, 0 );
493
            setting = measured_strings_find( & networking_globals.configuration, CONF_MTU, 0 );
492
        }
494
        }
493
        mtu = setting ? strtol( setting->value, NULL, 10 ) : 0;
495
        mtu = setting ? strtol( setting->value, NULL, 10 ) : 0;
494
        ERROR_PROPAGATE( async_req_3_0( netif->nil->phone, NET_NIL_DEVICE, netif->id, netif->driver->service, mtu ));
496
        ERROR_PROPAGATE( async_req_3_0( netif->nil->phone, NET_NIL_DEVICE, netif->id, mtu, netif->driver->service ));
495
        internet_service = netif->nil->service;
497
        internet_service = netif->nil->service;
496
    }else{
498
    }else{
497
        internet_service = netif->driver->service;
499
        internet_service = netif->driver->service;
498
    }
500
    }
499
    // TODO IL_BUNDLE
501
    // TODO IL_BUNDLE
500
    ERROR_PROPAGATE( async_req_2_0( netif->il->phone, NET_IL_DEVICE, netif->id, internet_service ));
502
    ERROR_PROPAGATE( async_req_2_0( netif->il->phone, NET_IL_DEVICE, netif->id, internet_service ));
501
    ERROR_PROPAGATE( async_req_1_0( netif->driver->phone, NET_NETIF_START, netif->id ));
503
    ERROR_PROPAGATE( netif_start_req( netif->driver->phone, netif->id ));
502
    return EOK;
504
    return EOK;
503
}
505
}
504
 
506
 
505
int startup( void ){
507
int startup( void ){
506
    ERROR_DECLARE;
508
    ERROR_DECLARE;
507
 
509
 
508
    char *      conf_files[] = { "lo", "ne2k" };
510
    char *      conf_files[] = { "lo", "ne2k" };
509
    int         count = sizeof( conf_files ) / sizeof( char * );
511
    int         count = sizeof( conf_files ) / sizeof( char * );
510
    int         index;
512
    int         index;
511
    netif_ref   netif;
513
    netif_ref   netif;
512
    int         i;
514
    int         i;
513
    measured_string_ref setting;
515
    measured_string_ref setting;
514
 
516
 
515
    // TODO dynamic configuration
517
    // TODO dynamic configuration
516
    ERROR_PROPAGATE( read_configuration());
518
    ERROR_PROPAGATE( read_configuration());
517
 
519
 
518
    for( i = 0; i < count; ++ i ){
520
    for( i = 0; i < count; ++ i ){
519
        netif = ( netif_ref ) malloc( sizeof( netif_t ));
521
        netif = ( netif_ref ) malloc( sizeof( netif_t ));
520
        if( ! netif ) return ENOMEM;
522
        if( ! netif ) return ENOMEM;
521
 
523
 
522
        netif->id = generate_new_device_id();
524
        netif->id = generate_new_device_id();
523
        if( ! netif->id ) return EXDEV;
525
        if( ! netif->id ) return EXDEV;
524
        ERROR_PROPAGATE( measured_strings_initialize( & netif->configuration ));
526
        ERROR_PROPAGATE( measured_strings_initialize( & netif->configuration ));
525
        // read configuration files
527
        // read configuration files
526
        if( ERROR_OCCURRED( read_netif_configuration( conf_files[ i ], netif ))){
528
        if( ERROR_OCCURRED( read_netif_configuration( conf_files[ i ], netif ))){
527
            measured_strings_destroy( & netif->configuration );
529
            measured_strings_destroy( & netif->configuration );
528
            free( netif );
530
            free( netif );
529
            return ERROR_CODE;
531
            return ERROR_CODE;
530
        }
532
        }
531
        // mandatory name
533
        // mandatory name
532
        setting = measured_strings_find( & netif->configuration, CONF_NAME, 0 );
534
        setting = measured_strings_find( & netif->configuration, CONF_NAME, 0 );
533
        if( ! setting ){
535
        if( ! setting ){
534
            printf( "\nThe name is missing" );
536
            printf( "\nThe name is missing" );
535
            measured_strings_destroy( & netif->configuration );
537
            measured_strings_destroy( & netif->configuration );
536
            free( netif );
538
            free( netif );
537
            return EINVAL;
539
            return EINVAL;
538
        }
540
        }
539
        netif->name = setting->value;
541
        netif->name = setting->value;
540
        // add to the netifs map
542
        // add to the netifs map
541
        index = netifs_add( & networking_globals.netifs, netif->id, netif );
543
        index = netifs_add( & networking_globals.netifs, netif->id, netif );
542
        if( index < 0 ){
544
        if( index < 0 ){
543
            measured_strings_destroy( & netif->configuration );
545
            measured_strings_destroy( & netif->configuration );
544
            free( netif );
546
            free( netif );
545
            return index;
547
            return index;
546
        }
548
        }
547
        // add to the netif names map
549
        // add to the netif names map
548
        if( ERROR_OCCURRED( char_map_add( & networking_globals.netif_names, netif->name, 0, index ))
550
        if( ERROR_OCCURRED( char_map_add( & networking_globals.netif_names, netif->name, 0, index ))
549
        // start network interfaces and needed modules
551
        // start network interfaces and needed modules
550
        || ERROR_OCCURRED( start_device( netif ))){
552
        || ERROR_OCCURRED( start_device( netif ))){
551
            measured_strings_destroy( & netif->configuration );
553
            measured_strings_destroy( & netif->configuration );
552
            netifs_exclude_index( & networking_globals.netifs, index );
554
            netifs_exclude_index( & networking_globals.netifs, index );
553
            return ERROR_CODE;
555
            return ERROR_CODE;
554
        }
556
        }
555
        // increment modules' usage
557
        // increment modules' usage
556
        ++ netif->driver->usage;
558
        ++ netif->driver->usage;
557
        if( netif->nil ) ++ netif->nil->usage;
559
        if( netif->nil ) ++ netif->nil->usage;
558
        ++ netif->il->usage;
560
        ++ netif->il->usage;
559
        printf( "\nNew network interface started:\n\tname\t= %s\n\tid\t= %d\n\tdriver\t= %s\n\tnil\t= %s\n\til\t= %s", netif->name, netif->id, netif->driver->name, netif->nil ? netif->nil->name : NULL, netif->il->name );
561
        printf( "\nNew network interface started:\n\tname\t= %s\n\tid\t= %d\n\tdriver\t= %s\n\tnil\t= %s\n\til\t= %s", netif->name, netif->id, netif->driver->name, netif->nil ? netif->nil->name : NULL, netif->il->name );
560
    }
562
    }
561
    return EOK;
563
    return EOK;
562
}
564
}
563
 
565
 
564
/** @}
566
/** @}
565
 */
567
 */
566
 
568