Rev 4243 | Rev 4271 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4243 | Rev 4261 | ||
---|---|---|---|
Line 56... | Line 56... | ||
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 "../include/device.h" |
59 | #include "../include/device.h" |
60 | #include "../include/netif_messages.h" |
60 | #include "../include/netif_messages.h" |
- | 61 | #include "../include/nil_messages.h" |
|
61 | 62 | /* |
|
62 | #if IP_BUNDLE |
63 | #if IP_BUNDLE |
63 | 64 | ||
64 | #include "../ip/ip_module.h" |
65 | #include "../ip/ip_module.h" |
65 | 66 | ||
66 | #endif |
67 | #endif |
Line 68... | Line 69... | ||
68 | #if TCP_BUNDLE |
69 | #if TCP_BUNDLE |
69 | 70 | ||
70 | #include "../tcp/tcp_module.h" |
71 | #include "../tcp/tcp_module.h" |
71 | 72 | ||
72 | #endif |
73 | #endif |
73 | 74 | */ |
|
74 | #define NAME "Networking" |
75 | #define NAME "Networking" |
75 | 76 | ||
76 | #define LO_NAME "lo" |
77 | #define LO_NAME "lo" |
77 | #define LO_FILENAME "/srv/lo" |
78 | #define LO_FILENAME "/srv/lo" |
78 | #define DP8390_NAME "dp8390" |
79 | #define DP8390_NAME "dp8390" |
Line 165... | Line 166... | ||
165 | void networking_print_name( void ){ |
166 | void networking_print_name( void ){ |
166 | printf( "%s", NAME ); |
167 | printf( "%s", NAME ); |
167 | } |
168 | } |
168 | 169 | ||
169 | int networking_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
170 | int networking_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
170 | #ifdef NETWORKING_module |
171 | /*#ifdef NETWORKING_module |
171 | //TODO map to *_message |
172 | //TODO map to *_message |
172 | if( IS_NET_IL_MESSAGE( call ) || IS_NET_IP_MESSAGE( call )){ |
173 | if( IS_NET_IL_MESSAGE( call ) || IS_NET_IP_MESSAGE( call )){ |
173 | return ip_message( callid, call, answer, answer_count ); |
174 | return ip_message( callid, call, answer, answer_count ); |
174 | /* }else if( IS_NET_ARP_MESSAGE( call )){ |
175 | *//* }else if( IS_NET_ARP_MESSAGE( call )){ |
175 | return arp_message( callid, call, answer, answer_count ); |
176 | return arp_message( callid, call, answer, answer_count ); |
176 | *//* }else if( IS_NET_RARP_MESSAGE( call )){ |
177 | *//* }else if( IS_NET_RARP_MESSAGE( call )){ |
177 | return rarp_message( callid, call, answer, answer_count ); |
178 | return rarp_message( callid, call, answer, answer_count ); |
178 | *//* }else if( IS_NET_ICMP_MESSAGE( call )){ |
179 | *//* }else if( IS_NET_ICMP_MESSAGE( call )){ |
179 | return icmp_message( callid, call, answer, answer_count ); |
180 | return icmp_message( callid, call, answer, answer_count ); |
180 | *//* }else if( IS_NET_UDP_MESSAGE( call )){ |
181 | *//* }else if( IS_NET_UDP_MESSAGE( call )){ |
181 | return udp_message( callid, call, answer, answer_count ); |
182 | return udp_message( callid, call, answer, answer_count ); |
182 | */ }else if( IS_NET_TCP_MESSAGE( call )){ |
183 | *//* }else if( IS_NET_TCP_MESSAGE( call )){ |
183 | return tcp_message( callid, call, answer, answer_count ); |
184 | return tcp_message( callid, call, answer, answer_count ); |
184 | /* }else if( IS_NET_SOCKET_MESSAGE( call )){ |
185 | *//* }else if( IS_NET_SOCKET_MESSAGE( call )){ |
185 | return socket_message( callid, call, answer, answer_count ); |
186 | return socket_message( callid, call, answer, answer_count ); |
186 | *//* }else if( IS_NET_NIL_MESSAGE( call ) || IS_NET_ETHERNET_MESSAGE( call )){ |
187 | *//* }else if( IS_NET_NIL_MESSAGE( call ) || IS_NET_ETHERNET_MESSAGE( call )){ |
187 | return ethernet_message( callid, call, answer, answer_count ); |
188 | return ethernet_message( callid, call, answer, answer_count ); |
188 | */ }else{ |
189 | *//* }else{ |
189 | #endif |
190 | #endif |
190 | if( IS_NET_PACKET_MESSAGE( call )){ |
191 | */ if( IS_NET_PACKET_MESSAGE( call )){ |
191 | return packet_server_message( callid, call, answer, answer_count ); |
192 | return packet_server_message( callid, call, answer, answer_count ); |
192 | }else{ |
193 | }else{ |
193 | return net_message( callid, call, answer, answer_count ); |
194 | return net_message( callid, call, answer, answer_count ); |
194 | } |
195 | } |
195 | #ifdef NETWORKING_module |
196 | /*#ifdef NETWORKING_module |
196 | } |
197 | } |
197 | #endif |
198 | #endif |
- | 199 | */ |
|
198 | } |
200 | } |
199 | 201 | ||
200 | int networking_start_module( async_client_conn_t client_connection ){ |
202 | int networking_start_module( async_client_conn_t client_connection ){ |
201 | ERROR_DECLARE; |
203 | ERROR_DECLARE; |
202 | 204 | ||
Line 231... | Line 233... | ||
231 | 233 | ||
232 | ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, LO_NAME, LO_FILENAME, SERVICE_LO, 0 )); |
234 | ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, LO_NAME, LO_FILENAME, SERVICE_LO, 0 )); |
233 | ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0 )); |
235 | ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, DP8390_NAME, DP8390_FILENAME, SERVICE_DP8390, 0 )); |
234 | ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0 )); |
236 | ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, ETHERNET_NAME, ETHERNET_FILENAME, SERVICE_ETHERNET, 0 )); |
235 | 237 | ||
236 | #ifdef NETWORKING_modular |
238 | //#ifdef NETWORKING_modular |
237 | task_id = spawn( "/srv/ip" ); |
239 | task_id = spawn( "/srv/ip" ); |
238 | if( ! task_id ) return EINVAL; |
240 | if( ! task_id ) return EINVAL; |
239 | ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_id )); |
241 | ERROR_PROPAGATE( add_module( NULL, & networking_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_id )); |
240 | // if( ! spawn( "/srv/udp" )) return EINVAL; |
242 | // if( ! spawn( "/srv/udp" )) return EINVAL; |
241 | // if( ! spawn( "/srv/tcp" )) return EINVAL; |
243 | // if( ! spawn( "/srv/tcp" )) return EINVAL; |
242 | // if( ! spawn( "/srv/socket" )) return EINVAL; |
244 | // if( ! spawn( "/srv/socket" )) return EINVAL; |
243 | // not always necesssary |
245 | // not always necesssary |
244 | // if( ! spawn( "/srv/arp" )) return EINVAL; |
246 | // if( ! spawn( "/srv/arp" )) return EINVAL; |
245 | // if( ! spawn( "/srv/rarp" )) return EINVAL; |
247 | // if( ! spawn( "/srv/rarp" )) return EINVAL; |
246 | // if( ! spawn( "/srv/icmp" )) return EINVAL; |
248 | // if( ! spawn( "/srv/icmp" )) return EINVAL; |
247 | 249 | /* |
|
248 | #else |
250 | #else |
249 | #ifdef NETWORKING_module |
251 | #ifdef NETWORKING_module |
250 | ipcarg_t phonehash; |
252 | ipcarg_t phonehash; |
251 | 253 | ||
252 | ERROR_PROPAGATE( REGISTER_ME( SERVICE_IP, & phonehash )); |
254 | ERROR_PROPAGATE( REGISTER_ME( SERVICE_IP, & phonehash )); |
Line 266... | Line 268... | ||
266 | // ERROR_PROPAGATE( socket_initialize()); |
268 | // ERROR_PROPAGATE( socket_initialize()); |
267 | // ERROR_PROPAGATE( REGISTER_ME( SERVICE_ETHERNET, & phonehash )); |
269 | // ERROR_PROPAGATE( REGISTER_ME( SERVICE_ETHERNET, & phonehash )); |
268 | // ERROR_PROPAGATE( ethernet_initialize()); |
270 | // ERROR_PROPAGATE( ethernet_initialize()); |
269 | #endif |
271 | #endif |
270 | #endif |
272 | #endif |
271 | 273 | */ |
|
272 | return EOK; |
274 | return EOK; |
273 | } |
275 | } |
274 | 276 | ||
275 | //TODO as ip.c |
277 | //TODO as ip.c |
276 | int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
278 | int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){ |
Line 427... | Line 429... | ||
427 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" )); |
429 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" )); |
428 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" )); |
430 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" )); |
429 | }else if( strncmp( name, "ne2k", 4 ) == 0 ){ |
431 | }else if( strncmp( name, "ne2k", 4 ) == 0 ){ |
430 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", "eth0" )); |
432 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "NAME", "eth0" )); |
431 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", DP8390_NAME )); |
433 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "NETIF", DP8390_NAME )); |
- | 434 | #ifdef NETWORKING_module |
|
- | 435 | // ethernet bundled in dp8390 |
|
- | 436 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", DP8390_NAME )); |
|
- | 437 | #else |
|
- | 438 | // standalone ethernet |
|
432 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", ETHERNET_NAME )); |
439 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "NIL", ETHERNET_NAME )); |
- | 440 | #endif |
|
433 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME )); |
441 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "IL", IP_NAME )); |
434 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "IRQ", "9" )); |
442 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "IRQ", "9" )); |
435 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "IO", "300" )); |
443 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "IO", "300" )); |
436 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "1492" )); |
444 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "MTU", "1492" )); |
437 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" )); |
445 | ERROR_PROPAGATE( add_configuration( & netif->configuration, "IP_CONFIG", "static" )); |
Line 491... | Line 499... | ||
491 | setting = measured_strings_find( & netif->configuration, CONF_MTU, 0 ); |
499 | setting = measured_strings_find( & netif->configuration, CONF_MTU, 0 ); |
492 | if( ! setting ){ |
500 | if( ! setting ){ |
493 | setting = measured_strings_find( & networking_globals.configuration, CONF_MTU, 0 ); |
501 | setting = measured_strings_find( & networking_globals.configuration, CONF_MTU, 0 ); |
494 | } |
502 | } |
495 | mtu = setting ? strtol( setting->value, NULL, 10 ) : 0; |
503 | mtu = setting ? strtol( setting->value, NULL, 10 ) : 0; |
496 | ERROR_PROPAGATE( async_req_3_0( netif->nil->phone, NET_NIL_DEVICE, netif->id, mtu, netif->driver->service )); |
504 | ERROR_PROPAGATE( nil_device_req( netif->nil->phone, netif->id, mtu, netif->driver->service )); |
497 | internet_service = netif->nil->service; |
505 | internet_service = netif->nil->service; |
498 | }else{ |
506 | }else{ |
499 | internet_service = netif->driver->service; |
507 | internet_service = netif->driver->service; |
500 | } |
508 | } |
501 | // TODO IL_BUNDLE |
509 | // TODO IL_BUNDLE |
502 | ERROR_PROPAGATE( async_req_2_0( netif->il->phone, NET_IL_DEVICE, netif->id, internet_service )); |
510 | ERROR_PROPAGATE( async_req_3_0( netif->il->phone, NET_IL_DEVICE, netif->id, 0, internet_service )); |
503 | ERROR_PROPAGATE( netif_start_req( netif->driver->phone, netif->id )); |
511 | ERROR_PROPAGATE( netif_start_req( netif->driver->phone, netif->id )); |
504 | return EOK; |
512 | return EOK; |
505 | } |
513 | } |
506 | 514 | ||
507 | int startup( void ){ |
515 | int startup( void ){ |