Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tl/icmp/icmp.c

    ra000878c r2e99277  
    464464        ERROR_DECLARE;
    465465
    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 }};
    467467        measured_string_ref     configuration;
    468468        size_t                          count = sizeof( names ) / sizeof( measured_string_t );
     
    658658        ipc_callid_t                    data_callid;
    659659        icmp_echo_ref                   echo_data;
     660        int                                             res;
    660661
    661662        /*
     
    663664         *  - Answer the first NET_ICMP_INIT call.
    664665         */
    665         ipc_answer_0( callid, EOK );
     666        res = EOK;
     667        answer_count = 0;
    666668
    667669//      fibril_rwlock_initialize( & lock );
     
    669671        echo_data = ( icmp_echo_ref ) malloc( sizeof( * echo_data ));
    670672        if( ! echo_data ) return ENOMEM;
     673
    671674        // assign a new identifier
    672675        fibril_rwlock_write_lock( & icmp_globals.lock );
    673         ERROR_CODE = icmp_bind_free_id( echo_data );
     676        res = icmp_bind_free_id( echo_data );
    674677        fibril_rwlock_write_unlock( & icmp_globals.lock );
    675         if( ERROR_CODE < 0 ){
     678        if( res < 0 ){
    676679                free( echo_data );
    677                 return ERROR_CODE;
     680                return res;
    678681        }
    679682
    680683        while( keep_on_going ){
     684
     685                // answer the call
     686                answer_call( callid, res, & answer, answer_count );
     687
     688                // refresh data
    681689                refresh_answer( & answer, & answer_count );
    682690
     691                // get the next call
    683692                callid = async_get_call( & call );
    684693
     694                // process the call
    685695                switch( IPC_GET_METHOD( call )){
    686696                        case IPC_M_PHONE_HUNGUP:
    687697                                keep_on_going = false;
    688                                 ERROR_CODE = EOK;
     698                                res = EHANGUP;
    689699                                break;
    690700                        case NET_ICMP_ECHO:
    691701//                              fibril_rwlock_write_lock( & lock );
    692702                                if( ! async_data_write_receive( & data_callid, & length )){
    693                                         ERROR_CODE = EINVAL;
     703                                        res = EINVAL;
    694704                                }else{
    695705                                        addr = malloc( length );
    696706                                        if( ! addr ){
    697                                                 ERROR_CODE = ENOMEM;
     707                                                res = ENOMEM;
    698708                                        }else{
    699709                                                if( ! ERROR_OCCURRED( async_data_write_finalize( data_callid, addr, length ))){
    700710                                                        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 );
    702712                                                        fibril_rwlock_write_unlock( & icmp_globals.lock );
    703713                                                        free( addr );
     
    707717                                                                echo_data->sequence_number = 0;
    708718                                                        }
     719                                                }else{
     720                                                        res = ERROR_CODE;
    709721                                                }
    710722                                        }
     
    713725                                break;
    714726                        default:
    715                                 ERROR_CODE = icmp_process_message( & call );
     727                                res = icmp_process_message( & call );
    716728                }
    717 
    718                 answer_call( callid, ERROR_CODE, & answer, answer_count );
    719729        }
    720730
     
    723733        icmp_echo_data_exclude( & icmp_globals.echo_data, echo_data->identifier );
    724734        fibril_rwlock_write_unlock( & icmp_globals.lock );
    725         return EOK;
     735        return res;
    726736}
    727737
Note: See TracChangeset for help on using the changeset viewer.