Changes in uspace/srv/net/tl/icmp/icmp.c [2e99277:a000878c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/icmp/icmp.c
r2e99277 ra000878c 464 464 ERROR_DECLARE; 465 465 466 measured_string_t names[] = {{ "ICMP_ERROR_REPORTING", 20 }, { "ICMP_ECHO_REPLYING", 18 }};466 measured_string_t names[] = {{ str_dup("ICMP_ERROR_REPORTING"), 20 }, { str_dup("ICMP_ECHO_REPLYING"), 18 }}; 467 467 measured_string_ref configuration; 468 468 size_t count = sizeof( names ) / sizeof( measured_string_t ); … … 658 658 ipc_callid_t data_callid; 659 659 icmp_echo_ref echo_data; 660 int res;661 660 662 661 /* … … 664 663 * - Answer the first NET_ICMP_INIT call. 665 664 */ 666 res = EOK; 667 answer_count = 0; 665 ipc_answer_0( callid, EOK ); 668 666 669 667 // fibril_rwlock_initialize( & lock ); … … 671 669 echo_data = ( icmp_echo_ref ) malloc( sizeof( * echo_data )); 672 670 if( ! echo_data ) return ENOMEM; 673 674 671 // assign a new identifier 675 672 fibril_rwlock_write_lock( & icmp_globals.lock ); 676 res= icmp_bind_free_id( echo_data );673 ERROR_CODE = icmp_bind_free_id( echo_data ); 677 674 fibril_rwlock_write_unlock( & icmp_globals.lock ); 678 if( res< 0 ){675 if( ERROR_CODE < 0 ){ 679 676 free( echo_data ); 680 return res;677 return ERROR_CODE; 681 678 } 682 679 683 680 while( keep_on_going ){ 684 685 // answer the call686 answer_call( callid, res, & answer, answer_count );687 688 // refresh data689 681 refresh_answer( & answer, & answer_count ); 690 682 691 // get the next call692 683 callid = async_get_call( & call ); 693 684 694 // process the call695 685 switch( IPC_GET_METHOD( call )){ 696 686 case IPC_M_PHONE_HUNGUP: 697 687 keep_on_going = false; 698 res = EHANGUP;688 ERROR_CODE = EOK; 699 689 break; 700 690 case NET_ICMP_ECHO: 701 691 // fibril_rwlock_write_lock( & lock ); 702 692 if( ! async_data_write_receive( & data_callid, & length )){ 703 res= EINVAL;693 ERROR_CODE = EINVAL; 704 694 }else{ 705 695 addr = malloc( length ); 706 696 if( ! addr ){ 707 res= ENOMEM;697 ERROR_CODE = ENOMEM; 708 698 }else{ 709 699 if( ! ERROR_OCCURRED( async_data_write_finalize( data_callid, addr, length ))){ 710 700 fibril_rwlock_write_lock( & icmp_globals.lock ); 711 res= icmp_echo( echo_data->identifier, echo_data->sequence_number, ICMP_GET_SIZE( call ), ICMP_GET_TIMEOUT( call ), ICMP_GET_TTL( call ), ICMP_GET_TOS( call ), ICMP_GET_DONT_FRAGMENT( call ), addr, ( socklen_t ) length );701 ERROR_CODE = icmp_echo( echo_data->identifier, echo_data->sequence_number, ICMP_GET_SIZE( call ), ICMP_GET_TIMEOUT( call ), ICMP_GET_TTL( call ), ICMP_GET_TOS( call ), ICMP_GET_DONT_FRAGMENT( call ), addr, ( socklen_t ) length ); 712 702 fibril_rwlock_write_unlock( & icmp_globals.lock ); 713 703 free( addr ); … … 717 707 echo_data->sequence_number = 0; 718 708 } 719 }else{720 res = ERROR_CODE;721 709 } 722 710 } … … 725 713 break; 726 714 default: 727 res= icmp_process_message( & call );715 ERROR_CODE = icmp_process_message( & call ); 728 716 } 717 718 answer_call( callid, ERROR_CODE, & answer, answer_count ); 729 719 } 730 720 … … 733 723 icmp_echo_data_exclude( & icmp_globals.echo_data, echo_data->identifier ); 734 724 fibril_rwlock_write_unlock( & icmp_globals.lock ); 735 return res;725 return EOK; 736 726 } 737 727
Note:
See TracChangeset
for help on using the changeset viewer.