Rev 4350 | Rev 4394 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4350 | Rev 4351 | ||
---|---|---|---|
Line 137... | Line 137... | ||
137 | /** Clears the device specific data. |
137 | /** Clears the device specific data. |
138 | * @param device The device specific data. |
138 | * @param device The device specific data. |
139 | */ |
139 | */ |
140 | void clear_device( arp_device_ref device ); |
140 | void clear_device( arp_device_ref device ); |
141 | 141 | ||
142 | /** Processes IPC messages from the registered device driver modules in an infinite loop. |
- | |
143 | * @param iid The message identifier. Input parameter. |
- | |
144 | * @param icall The message parameters. Input/output parameter. |
- | |
145 | */ |
- | |
146 | void arp_receiver( ipc_callid_t iid, ipc_call_t * icall ); |
- | |
147 | - | ||
148 | DEVICE_MAP_IMPLEMENT( arp_cache, arp_device_t ) |
142 | DEVICE_MAP_IMPLEMENT( arp_cache, arp_device_t ) |
149 | 143 | ||
150 | INT_MAP_IMPLEMENT( arp_protos, arp_proto_t ) |
144 | INT_MAP_IMPLEMENT( arp_protos, arp_proto_t ) |
151 | 145 | ||
152 | GENERIC_CHAR_MAP_IMPLEMENT( arp_addr, measured_string_t ) |
146 | GENERIC_CHAR_MAP_IMPLEMENT( arp_addr, measured_string_t ) |
Line 220... | Line 214... | ||
220 | rwlock_read_unlock( & arp_globals.lock ); |
214 | rwlock_read_unlock( & arp_globals.lock ); |
221 | return ENOENT; |
215 | return ENOENT; |
222 | } |
216 | } |
223 | } |
217 | } |
224 | 218 | ||
225 | int arp_initialize( void ){ |
219 | int arp_initialize( async_client_conn_t client_connection ){ |
226 | ERROR_DECLARE; |
220 | ERROR_DECLARE; |
227 | 221 | ||
228 | rwlock_initialize( & arp_globals.lock ); |
222 | rwlock_initialize( & arp_globals.lock ); |
229 | rwlock_write_lock( & arp_globals.lock ); |
223 | rwlock_write_lock( & arp_globals.lock ); |
- | 224 | arp_globals.client_connection = client_connection; |
|
230 | ERROR_PROPAGATE( arp_cache_initialize( & arp_globals.cache )); |
225 | ERROR_PROPAGATE( arp_cache_initialize( & arp_globals.cache )); |
231 | rwlock_write_unlock( & arp_globals.lock ); |
226 | rwlock_write_unlock( & arp_globals.lock ); |
232 | return EOK; |
227 | return EOK; |
233 | } |
228 | } |
234 | 229 | ||
Line 306... | Line 301... | ||
306 | free( device ); |
301 | free( device ); |
307 | return index; |
302 | return index; |
308 | } |
303 | } |
309 | device->service = service; |
304 | device->service = service; |
310 | // bind the new one |
305 | // bind the new one |
311 | device->phone = bind_service( device->service, device->device_id, SERVICE_ARP, 0, arp_receiver ); |
306 | device->phone = bind_service( device->service, device->device_id, SERVICE_ARP, 0, arp_globals.client_connection ); |
312 | if( device->phone < 0 ){ |
307 | if( device->phone < 0 ){ |
313 | rwlock_write_unlock( & arp_globals.lock ); |
308 | rwlock_write_unlock( & arp_globals.lock ); |
314 | arp_protos_destroy( & device->protos ); |
309 | arp_protos_destroy( & device->protos ); |
315 | free( device ); |
310 | free( device ); |
316 | return EREFUSED; |
311 | return EREFUSED; |
Line 478... | Line 473... | ||
478 | ERROR_DECLARE; |
473 | ERROR_DECLARE; |
479 | 474 | ||
480 | measured_string_ref address; |
475 | measured_string_ref address; |
481 | measured_string_ref translation; |
476 | measured_string_ref translation; |
482 | char * data; |
477 | char * data; |
- | 478 | packet_t packet; |
|
483 | 479 | ||
484 | // printf( "message %d - %d\n", IPC_GET_METHOD( * call ), NET_ARP_FIRST ); |
480 | // printf( "message %d - %d\n", IPC_GET_METHOD( * call ), NET_ARP_FIRST ); |
485 | * answer_count = 0; |
481 | * answer_count = 0; |
486 | switch( IPC_GET_METHOD( * call )){ |
482 | switch( IPC_GET_METHOD( * call )){ |
487 | case IPC_M_PHONE_HUNGUP: |
483 | case IPC_M_PHONE_HUNGUP: |
Line 508... | Line 504... | ||
508 | return ERROR_CODE; |
504 | return ERROR_CODE; |
509 | case NET_ARP_CLEAR_DEVICE: |
505 | case NET_ARP_CLEAR_DEVICE: |
510 | return arp_clear_device_req( 0, IPC_GET_DEVICE( call )); |
506 | return arp_clear_device_req( 0, IPC_GET_DEVICE( call )); |
511 | case NET_ARP_CLEAN_CACHE: |
507 | case NET_ARP_CLEAN_CACHE: |
512 | return arp_clean_cache_req( 0 ); |
508 | return arp_clean_cache_req( 0 ); |
- | 509 | case NET_IL_DEVICE_STATE: |
|
- | 510 | // do nothing - keep the cache |
|
- | 511 | return EOK; |
|
- | 512 | case NET_IL_RECEIVED: |
|
- | 513 | if( ! ERROR_OCCURRED( packet_translate( arp_globals.net_phone, & packet, IPC_GET_PACKET( call )))){ |
|
- | 514 | rwlock_read_lock( & arp_globals.lock ); |
|
- | 515 | ERROR_CODE = arp_receive_message( IPC_GET_DEVICE( call ), packet ); |
|
- | 516 | rwlock_read_unlock( & arp_globals.lock ); |
|
- | 517 | } |
|
- | 518 | return ERROR_CODE; |
|
513 | } |
519 | } |
514 | return ENOTSUP; |
520 | return ENOTSUP; |
515 | } |
521 | } |
516 | 522 | ||
517 | void arp_receiver( ipc_callid_t iid, ipc_call_t * icall ){ |
- | |
518 | ERROR_DECLARE; |
- | |
519 | - | ||
520 | packet_t packet; |
- | |
521 | - | ||
522 | while( true ){ |
- | |
523 | switch( IPC_GET_METHOD( * icall )){ |
- | |
524 | case NET_IL_DEVICE_STATE: |
- | |
525 | // do nothing - keep the cache |
- | |
526 | ipc_answer_0( iid, EOK ); |
- | |
527 | break; |
- | |
528 | case NET_IL_RECEIVED: |
- | |
529 | if( ! ERROR_OCCURRED( packet_translate( arp_globals.net_phone, & packet, IPC_GET_PACKET( icall )))){ |
- | |
530 | rwlock_read_lock( & arp_globals.lock ); |
- | |
531 | ERROR_CODE = arp_receive_message( IPC_GET_DEVICE( icall ), packet ); |
- | |
532 | rwlock_read_unlock( & arp_globals.lock ); |
- | |
533 | } |
- | |
534 | ipc_answer_0( iid, ERROR_CODE ); |
- | |
535 | break; |
- | |
536 | default: |
- | |
537 | ipc_answer_0( iid, ENOTSUP ); |
- | |
538 | } |
- | |
539 | iid = async_get_call( icall ); |
- | |
540 | } |
- | |
541 | } |
- | |
542 | - | ||
543 | /** @} |
523 | /** @} |
544 | */ |
524 | */ |