Rev 4505 | Rev 4558 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4505 | Rev 4506 | ||
|---|---|---|---|
| Line 219... | Line 219... | ||
| 219 | char * data; |
219 | char * data; |
| 220 | int index; |
220 | int index; |
| 221 | ip_route_ref route; |
221 | ip_route_ref route; |
| 222 | in_addr_t gateway; |
222 | in_addr_t gateway; |
| 223 | 223 | ||
| - | 224 | ip_netif->arp = 0; |
|
| - | 225 | route = NULL; |
|
| 224 | configuration = & names[ 0 ]; |
226 | configuration = & names[ 0 ]; |
| 225 | // get configuration |
227 | // get configuration |
| 226 | ERROR_PROPAGATE( net_get_device_conf_req( ip_globals.net_phone, ip_netif->device_id, & configuration, count, & data )); |
228 | ERROR_PROPAGATE( net_get_device_conf_req( ip_globals.net_phone, ip_netif->device_id, & configuration, count, & data )); |
| 227 | if( configuration ){ |
229 | if( configuration ){ |
| 228 | if( configuration[ 0 ].value ){ |
230 | if( configuration[ 0 ].value ){ |
| Line 282... | Line 284... | ||
| 282 | printf( "Failed to contact the nil service %d\n", ip_netif->service ); |
284 | printf( "Failed to contact the nil service %d\n", ip_netif->service ); |
| 283 | return ip_netif->phone; |
285 | return ip_netif->phone; |
| 284 | } |
286 | } |
| 285 | // MUST BE AFTER the bind_service up there! |
287 | // MUST BE AFTER the bind_service up there! |
| 286 | if( ip_netif->arp ){ |
288 | if( ip_netif->arp ){ |
| - | 289 | if( route ){ |
|
| 287 | configuration[ 0 ].value = ( char * ) & route->address.s_addr; |
290 | configuration[ 0 ].value = ( char * ) & route->address.s_addr; |
| 288 | configuration[ 0 ].length = CONVERT_SIZE( in_addr_t, char, 1 ); |
291 | configuration[ 0 ].length = CONVERT_SIZE( in_addr_t, char, 1 ); |
| 289 | ERROR_PROPAGATE( arp_device_req( ip_netif->arp->phone, ip_netif->device_id, SERVICE_IP, ip_netif->service, & configuration[ 0 ] )); |
292 | ERROR_PROPAGATE( arp_device_req( ip_netif->arp->phone, ip_netif->device_id, SERVICE_IP, ip_netif->service, & configuration[ 0 ] )); |
| - | 293 | }else{ |
|
| - | 294 | ip_netif->arp = 0; |
|
| - | 295 | } |
|
| 290 | } |
296 | } |
| 291 | // get packet dimensions |
297 | // get packet dimensions |
| 292 | ERROR_PROPAGATE( nil_packet_size_req( ip_netif->phone, ip_netif->device_id, & ip_netif->addr_len, & ip_netif->prefix, & ip_netif->content, & ip_netif->suffix )); |
298 | ERROR_PROPAGATE( nil_packet_size_req( ip_netif->phone, ip_netif->device_id, & ip_netif->addr_len, & ip_netif->prefix, & ip_netif->content, & ip_netif->suffix )); |
| 293 | if( ip_netif->content < IP_MIN_CONTENT ){ |
299 | if( ip_netif->content < IP_MIN_CONTENT ){ |
| 294 | printf( "Maximum transmission unit %d bytes is too small, at least %d bytes are needed\n", ip_netif->content, IP_MIN_CONTENT ); |
300 | printf( "Maximum transmission unit %d bytes is too small, at least %d bytes are needed\n", ip_netif->content, IP_MIN_CONTENT ); |
| Line 305... | Line 311... | ||
| 305 | } |
311 | } |
| 306 | return EOK; |
312 | return EOK; |
| 307 | } |
313 | } |
| 308 | 314 | ||
| 309 | int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ){ |
315 | int ip_device_state_msg( int il_phone, device_id_t device_id, device_state_t state ){ |
| 310 | ERROR_DECLARE; |
316 | // ERROR_DECLARE; |
| 311 | 317 | ||
| 312 | /* measured_string_t address; |
318 | /* measured_string_t address; |
| 313 | measured_string_ref translation; |
319 | measured_string_ref translation; |
| 314 | char * data; |
320 | char * data; |
| 315 | */ |
321 | */ |
| 316 | packet_t packet; |
322 | /* packet_t packet; |
| 317 | in_addr_t destination; |
323 | in_addr_t destination; |
| 318 | 324 | */ |
|
| 319 | ip_netif_ref netif; |
325 | ip_netif_ref netif; |
| 320 | 326 | ||
| 321 | netif = ip_netifs_find( & ip_globals.netifs, device_id ); |
327 | netif = ip_netifs_find( & ip_globals.netifs, device_id ); |
| 322 | if( ! netif ) return ENOENT; |
328 | if( ! netif ) return ENOENT; |
| 323 | netif->state = state; |
329 | netif->state = state; |
| 324 | // TODO state |
330 | // TODO state |
| 325 | printf( "ip - device %d changed state to %d\n\n", device_id, state ); |
331 | printf( "ip - device %d changed state to %d\n\n", device_id, state ); |
| 326 | if( netif->arp ){ |
332 | // if( netif->arp ){ |
| 327 | /* address.value = ( char * ) & ip_globals.gateway.gateway.s_addr; |
333 | /* address.value = ( char * ) & ip_globals.gateway.gateway.s_addr; |
| 328 | address.length = CONVERT_SIZE( ip_globals.gateway.gateway.s_addr, char, 1 ); |
334 | address.length = CONVERT_SIZE( ip_globals.gateway.gateway.s_addr, char, 1 ); |
| 329 | if( ERROR_OCCURRED( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & address, & translation, & data ))){ |
335 | if( ERROR_OCCURRED( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & address, & translation, & data ))){ |
| 330 | ERROR_PROPAGATE( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & address, & translation, & data )); |
336 | ERROR_PROPAGATE( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & address, & translation, & data )); |
| 331 | } |
337 | } |
| Line 339... | Line 345... | ||
| 339 | ERROR_PROPAGATE( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & address, & translation, & data )); |
345 | ERROR_PROPAGATE( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & address, & translation, & data )); |
| 340 | } |
346 | } |
| 341 | printf( "\tgateway translated to\t= %X:%X:%X:%X:%X:%X\n", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] ); |
347 | printf( "\tgateway translated to\t= %X:%X:%X:%X:%X:%X\n", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] ); |
| 342 | free( translation ); |
348 | free( translation ); |
| 343 | free( data ); |
349 | free( data ); |
| 344 | */ printf( "IP - testing to send packet:\n" ); |
350 | *//* printf( "IP - testing to send packet:\n" ); |
| 345 | ERROR_PROPAGATE( inet_pton( AF_INET, "90.182.101.18", ( uint8_t * ) & destination.s_addr )); |
351 | ERROR_PROPAGATE( inet_pton( AF_INET, "90.182.101.18", ( uint8_t * ) & destination.s_addr )); |
| 346 | packet = packet_get_4( ip_globals.net_phone, 30, netif->addr_len, netif->prefix + sizeof( ip_header_t ), netif->suffix ); |
352 | packet = packet_get_4( ip_globals.net_phone, 30, netif->addr_len, netif->prefix + sizeof( ip_header_t ), netif->suffix ); |
| 347 | if( ! packet ) return ENOMEM; |
353 | if( ! packet ) return ENOMEM; |
| 348 | pq_release( ip_globals.net_phone, packet_get_id( packet )); |
354 | pq_release( ip_globals.net_phone, packet_get_id( packet )); |
| 349 | packet = packet_get_4( ip_globals.net_phone, 30, netif->addr_len, netif->prefix + sizeof( ip_header_t ), netif->suffix ); |
355 | packet = packet_get_4( ip_globals.net_phone, 30, netif->addr_len, netif->prefix + sizeof( ip_header_t ), netif->suffix ); |
| Line 362... | Line 368... | ||
| 362 | pq_release( ip_globals.net_phone, packet_get_id( packet )); |
368 | pq_release( ip_globals.net_phone, packet_get_id( packet )); |
| 363 | } |
369 | } |
| 364 | ERROR_CODE = ip_send_msg( 0, 0, packet, SERVICE_IP ); |
370 | ERROR_CODE = ip_send_msg( 0, 0, packet, SERVICE_IP ); |
| 365 | printf( "send returned %d\n", ERROR_CODE ); |
371 | printf( "send returned %d\n", ERROR_CODE ); |
| 366 | } |
372 | } |
| 367 | return EOK; |
373 | */ return EOK; |
| 368 | } |
374 | } |
| 369 | 375 | ||
| 370 | int ip_connect_module( services_t service ){ |
376 | int ip_connect_module( services_t service ){ |
| 371 | return EOK; |
377 | return EOK; |
| 372 | } |
378 | } |