Rev 4261 | Rev 4327 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4261 | Rev 4271 | ||
---|---|---|---|
Line 45... | Line 45... | ||
45 | #include "../../modules.h" |
45 | #include "../../modules.h" |
46 | 46 | ||
47 | #include "../../include/sockaddr.h" |
47 | #include "../../include/sockaddr.h" |
48 | #include "../../include/socket.h" |
48 | #include "../../include/socket.h" |
49 | #include "../../include/device.h" |
49 | #include "../../include/device.h" |
- | 50 | #include "../../include/arp_messages.h" |
|
50 | #include "../../include/nil_messages.h" |
51 | #include "../../include/nil_messages.h" |
51 | #include "../../structures/measured_strings.h" |
52 | #include "../../structures/measured_strings.h" |
52 | #include "../../structures/module_map.h" |
53 | #include "../../structures/module_map.h" |
53 | #include "../../structures/packet/packet_client.h" |
54 | #include "../../structures/packet/packet_client.h" |
54 | 55 | ||
Line 183... | Line 184... | ||
183 | printf( "\nFailed to contact the nil service %d", service ); |
184 | printf( "\nFailed to contact the nil service %d", service ); |
184 | free( ip_netif ); |
185 | free( ip_netif ); |
185 | return ip_netif->phone; |
186 | return ip_netif->phone; |
186 | } |
187 | } |
187 | if( ip_netif->arp ){ |
188 | if( ip_netif->arp ){ |
188 | message = async_send_3( ip_netif->arp->phone, NET_ARP_DEVICE, ip_netif->device_id, SERVICE_IP, service, & answer ); |
- | |
189 | configuration[ 0 ].value = ( char * ) & ip_netif->address; |
189 | configuration[ 0 ].value = ( char * ) & ip_netif->address; |
190 | configuration[ 0 ].length = CONVERT_SIZE( in_addr_t, char, 1 ); |
190 | configuration[ 0 ].length = CONVERT_SIZE( in_addr_t, char, 1 ); |
191 | if( ERROR_OCCURRED( measured_strings_send( ip_netif->arp->phone, & configuration[ 0 ], 1 ))){ |
191 | if( ERROR_OCCURRED( arp_device_req( ip_netif->arp->phone, ip_netif->device_id, SERVICE_IP, service, & configuration[ 0 ] ))){ |
192 | free( ip_netif ); |
- | |
193 | return ERROR_CODE; |
- | |
194 | } |
- | |
195 | async_wait_for( message, & result ); |
- | |
196 | if( ERROR_OCCURRED( result )){ |
- | |
197 | free( ip_netif ); |
192 | free( ip_netif ); |
198 | return ERROR_CODE; |
193 | return ERROR_CODE; |
199 | } |
194 | } |
200 | } |
195 | } |
201 | index = ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif ); |
196 | index = ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif ); |
Line 275... | Line 270... | ||
275 | int ip_state_message( device_id_t device_id, device_state_t state ){ |
270 | int ip_state_message( device_id_t device_id, device_state_t state ){ |
276 | ERROR_DECLARE; |
271 | ERROR_DECLARE; |
277 | 272 | ||
278 | ip_netif_ref netif; |
273 | ip_netif_ref netif; |
279 | 274 | ||
280 | aid_t message; |
- | |
281 | ipc_call_t answer; |
- | |
282 | measured_string_t address; |
275 | measured_string_t address; |
283 | measured_string_ref translation; |
276 | measured_string_ref translation; |
284 | char * data; |
277 | char * data; |
285 | ipcarg_t result; |
- | |
286 | 278 | ||
287 | netif = ip_netifs_find( & ip_globals.netifs, device_id ); |
279 | netif = ip_netifs_find( & ip_globals.netifs, device_id ); |
288 | if( ! netif ) return ENOENT; |
280 | if( ! netif ) return ENOENT; |
289 | // TODO state |
281 | // TODO state |
290 | printf( "\nip - device %d changed state to %d\n", device_id, state ); |
282 | printf( "\nip - device %d changed state to %d\n", device_id, state ); |
291 | if( netif->arp ){ |
283 | if( netif->arp ){ |
292 | message = async_send_2( netif->arp->phone, NET_ARP_TRANSLATE, netif->device_id, SERVICE_IP, & answer ); |
- | |
293 | address.value = ( char * ) & netif->gateway; |
284 | address.value = ( char * ) & netif->gateway; |
294 | address.length = CONVERT_SIZE( in_addr_t, char, 1 ); |
285 | address.length = CONVERT_SIZE( in_addr_t, char, 1 ); |
295 | if( ERROR_OCCURRED( measured_strings_send( netif->arp->phone, & address, 1 )) |
- | |
296 | || ERROR_OCCURRED( measured_strings_return( netif->arp->phone, & translation, & data, 1 ))){ |
286 | ERROR_PROPAGATE( arp_translate_req( netif->arp->phone, netif->device_id, SERVICE_IP, & address, & translation, & data )); |
297 | async_wait_for( message, & result ); |
- | |
298 | return result; |
- | |
299 | } |
- | |
300 | async_wait_for( message, & result ); |
- | |
301 | if( ! ERROR_OCCURRED( result )){ |
- | |
302 | printf( "\n\tgateway translated to\t= %X:%X:%X:%X:%X:%X", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] ); |
287 | printf( "\n\tgateway translated to\t= %X:%X:%X:%X:%X:%X", data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] ); |
303 | } |
- | |
304 | free( translation ); |
288 | free( translation ); |
305 | free( data ); |
289 | free( data ); |
306 | return result; |
- | |
307 | } |
290 | } |
308 | return EOK; |
291 | return EOK; |
309 | } |
292 | } |
310 | 293 | ||
311 | int ip_register_message( int protocol, int phone ){ |
294 | int ip_register_message( int protocol, int phone ){ |