47,7 → 47,6 |
#include "../../include/sockaddr.h" |
#include "../../include/socket.h" |
#include "../../include/device.h" |
#include "../../include/arp_messages.h" |
#include "../../include/nil_messages.h" |
#include "../../structures/measured_strings.h" |
#include "../../structures/module_map.h" |
186,12 → 185,18 |
return ip_netif->phone; |
} |
if( ip_netif->arp ){ |
message = async_send_3( ip_netif->arp->phone, NET_ARP_DEVICE, ip_netif->device_id, SERVICE_IP, service, & answer ); |
configuration[ 0 ].value = ( char * ) & ip_netif->address; |
configuration[ 0 ].length = CONVERT_SIZE( in_addr_t, char, 1 ); |
if( ERROR_OCCURRED( arp_device_req( ip_netif->arp->phone, ip_netif->device_id, SERVICE_IP, service, & configuration[ 0 ] ))){ |
if( ERROR_OCCURRED( measured_strings_send( ip_netif->arp->phone, & configuration[ 0 ], 1 ))){ |
free( ip_netif ); |
return ERROR_CODE; |
} |
async_wait_for( message, & result ); |
if( ERROR_OCCURRED( result )){ |
free( ip_netif ); |
return ERROR_CODE; |
} |
} |
index = ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif ); |
if( index < 0 ){ |
272,9 → 277,12 |
|
ip_netif_ref netif; |
|
aid_t message; |
ipc_call_t answer; |
measured_string_t address; |
measured_string_ref translation; |
char * data; |
ipcarg_t result; |
|
netif = ip_netifs_find( & ip_globals.netifs, device_id ); |
if( ! netif ) return ENOENT; |
281,12 → 289,21 |
// TODO state |
printf( "\nip - device %d changed state to %d\n", device_id, state ); |
if( netif->arp ){ |
message = async_send_2( netif->arp->phone, NET_ARP_TRANSLATE, netif->device_id, SERVICE_IP, & answer ); |
address.value = ( char * ) & netif->gateway; |
address.length = CONVERT_SIZE( in_addr_t, char, 1 ); |
ERROR_PROPAGATE( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & address, & translation, & data )); |
printf( "\n\tgateway translated to\t= %X:%X:%X:%X:%X:%X", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] ); |
if( ERROR_OCCURRED( measured_strings_send( netif->arp->phone, & address, 1 )) |
|| ERROR_OCCURRED( measured_strings_return( netif->arp->phone, & translation, & data, 1 ))){ |
async_wait_for( message, & result ); |
return result; |
} |
async_wait_for( message, & result ); |
if( ! ERROR_OCCURRED( result )){ |
printf( "\n\tgateway translated to\t= %X:%X:%X:%X:%X:%X", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] ); |
} |
free( translation ); |
free( data ); |
return result; |
} |
return EOK; |
} |