Subversion Repositories HelenOS

Rev

Rev 4721 | Rev 4728 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4721 Rev 4722
Line 73... Line 73...
73
#include "icmp.h"
73
#include "icmp.h"
74
#include "icmp_header.h"
74
#include "icmp_header.h"
75
#include "icmp_messages.h"
75
#include "icmp_messages.h"
76
#include "icmp_module.h"
76
#include "icmp_module.h"
77
 
77
 
-
 
78
/** Default ICMP error reporting.
-
 
79
 */
-
 
80
#define NET_DEFAULT_ICMP_ERROR_REPORTING    true
-
 
81
 
-
 
82
/** Default ICMP echo replying.
-
 
83
 */
-
 
84
#define NET_DEFAULT_ICMP_ECHO_REPLYING      true
-
 
85
 
78
/** Original datagram length in bytes transfered to the error notification message.
86
/** Original datagram length in bytes transfered to the error notification message.
79
 */
87
 */
80
#define ICMP_KEEP_LENGTH    8
88
#define ICMP_KEEP_LENGTH    8
81
 
89
 
82
/** Free identifier numbers pool start.
90
/** Free identifier numbers pool start.
Line 498... Line 506...
498
    // assign a new identifier
506
    // assign a new identifier
499
    fibril_rwlock_write_lock( & icmp_globals.lock );
507
    fibril_rwlock_write_lock( & icmp_globals.lock );
500
    index = icmp_bind_free_id( echo_data );
508
    index = icmp_bind_free_id( echo_data );
501
    if( index < 0 ){
509
    if( index < 0 ){
502
        free( echo_data );
510
        free( echo_data );
-
 
511
        fibril_rwlock_write_unlock( & icmp_globals.lock );
-
 
512
        return index;
503
    }else{
513
    }else{
504
        id = echo_data->id;
514
        id = echo_data->id;
-
 
515
        fibril_rwlock_write_unlock( & icmp_globals.lock );
-
 
516
        // return the echo data identifier as the ICMP phone
-
 
517
        return id;
505
    }
518
    }
506
    fibril_rwlock_write_unlock( & icmp_globals.lock );
-
 
507
    // return the echo data identifier as the ICMP phone
-
 
508
    return id;
-
 
509
}
519
}
510
 
520
 
511
int icmp_initialize( async_client_conn_t client_connection ){
521
int icmp_initialize( async_client_conn_t client_connection ){
512
    ERROR_DECLARE;
522
    ERROR_DECLARE;
513
 
523
 
Line 525... Line 535...
525
        return icmp_globals.ip_phone;
535
        return icmp_globals.ip_phone;
526
    }
536
    }
527
    ERROR_PROPAGATE( ip_packet_size_req( icmp_globals.ip_phone, -1, & icmp_globals.addr_len, & icmp_globals.prefix, & icmp_globals.content, & icmp_globals.suffix ));
537
    ERROR_PROPAGATE( ip_packet_size_req( icmp_globals.ip_phone, -1, & icmp_globals.addr_len, & icmp_globals.prefix, & icmp_globals.content, & icmp_globals.suffix ));
528
    icmp_globals.prefix += sizeof( icmp_header_t );
538
    icmp_globals.prefix += sizeof( icmp_header_t );
529
    icmp_globals.content -= sizeof( icmp_header_t );
539
    icmp_globals.content -= sizeof( icmp_header_t );
530
    configuration = & names[ 0 ];
-
 
531
    // get configuration
540
    // get configuration
-
 
541
    icmp_globals.error_reporting = NET_DEFAULT_ICMP_ERROR_REPORTING;
-
 
542
    icmp_globals.echo_replying = NET_DEFAULT_ICMP_ECHO_REPLYING;
-
 
543
    configuration = & names[ 0 ];
532
    ERROR_PROPAGATE( net_get_conf_req( icmp_globals.net_phone, & configuration, count, & data ));
544
    ERROR_PROPAGATE( net_get_conf_req( icmp_globals.net_phone, & configuration, count, & data ));
533
    if( configuration ){
545
    if( configuration ){
-
 
546
        if( configuration[ 0 ].value ){
534
        icmp_globals.error_reporting = configuration[ 0 ].value && ( configuration[ 0 ].value[ 0 ] == 'y' );
547
            icmp_globals.error_reporting = ( configuration[ 0 ].value[ 0 ] == 'y' );
-
 
548
        }
-
 
549
        if( configuration[ 1 ].value ){
535
        icmp_globals.echo_replying = configuration[ 1 ].value && ( configuration[ 1 ].value[ 0 ] == 'y' );
550
            icmp_globals.echo_replying = ( configuration[ 1 ].value[ 0 ] == 'y' );
-
 
551
        }
536
        net_free_settings( configuration, data );
552
        net_free_settings( configuration, data );
537
    }
553
    }
538
    fibril_rwlock_write_unlock( & icmp_globals.lock );
554
    fibril_rwlock_write_unlock( & icmp_globals.lock );
539
    return EOK;
555
    return EOK;
540
}
556
}