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