Ignore:
File:
1 edited

Legend:

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

    r2e99277 ra000878c  
    464464        ERROR_DECLARE;
    465465
    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 }};
    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;
    661660
    662661        /*
     
    664663         *  - Answer the first NET_ICMP_INIT call.
    665664         */
    666         res = EOK;
    667         answer_count = 0;
     665        ipc_answer_0( callid, EOK );
    668666
    669667//      fibril_rwlock_initialize( & lock );
     
    671669        echo_data = ( icmp_echo_ref ) malloc( sizeof( * echo_data ));
    672670        if( ! echo_data ) return ENOMEM;
    673 
    674671        // assign a new identifier
    675672        fibril_rwlock_write_lock( & icmp_globals.lock );
    676         res = icmp_bind_free_id( echo_data );
     673        ERROR_CODE = icmp_bind_free_id( echo_data );
    677674        fibril_rwlock_write_unlock( & icmp_globals.lock );
    678         if( res < 0 ){
     675        if( ERROR_CODE < 0 ){
    679676                free( echo_data );
    680                 return res;
     677                return ERROR_CODE;
    681678        }
    682679
    683680        while( keep_on_going ){
    684 
    685                 // answer the call
    686                 answer_call( callid, res, & answer, answer_count );
    687 
    688                 // refresh data
    689681                refresh_answer( & answer, & answer_count );
    690682
    691                 // get the next call
    692683                callid = async_get_call( & call );
    693684
    694                 // process the call
    695685                switch( IPC_GET_METHOD( call )){
    696686                        case IPC_M_PHONE_HUNGUP:
    697687                                keep_on_going = false;
    698                                 res = EHANGUP;
     688                                ERROR_CODE = EOK;
    699689                                break;
    700690                        case NET_ICMP_ECHO:
    701691//                              fibril_rwlock_write_lock( & lock );
    702692                                if( ! async_data_write_receive( & data_callid, & length )){
    703                                         res = EINVAL;
     693                                        ERROR_CODE = EINVAL;
    704694                                }else{
    705695                                        addr = malloc( length );
    706696                                        if( ! addr ){
    707                                                 res = ENOMEM;
     697                                                ERROR_CODE = ENOMEM;
    708698                                        }else{
    709699                                                if( ! ERROR_OCCURRED( async_data_write_finalize( data_callid, addr, length ))){
    710700                                                        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 );
    712702                                                        fibril_rwlock_write_unlock( & icmp_globals.lock );
    713703                                                        free( addr );
     
    717707                                                                echo_data->sequence_number = 0;
    718708                                                        }
    719                                                 }else{
    720                                                         res = ERROR_CODE;
    721709                                                }
    722710                                        }
     
    725713                                break;
    726714                        default:
    727                                 res = icmp_process_message( & call );
     715                                ERROR_CODE = icmp_process_message( & call );
    728716                }
     717
     718                answer_call( callid, ERROR_CODE, & answer, answer_count );
    729719        }
    730720
     
    733723        icmp_echo_data_exclude( & icmp_globals.echo_data, echo_data->identifier );
    734724        fibril_rwlock_write_unlock( & icmp_globals.lock );
    735         return res;
     725        return EOK;
    736726}
    737727
Note: See TracChangeset for help on using the changeset viewer.