Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/tl/icmp_client.c

    r25171e5 r753bca3  
    2727 */
    2828
    29 /** @addtogroup libnet
    30  * @{
     29/** @addtogroup icmp
     30 *  @{
    3131 */
    3232
    3333/** @file
    34  * ICMP client interface implementation.
    35  * @see icmp_client.h
     34 *  ICMP client interface implementation.
     35 *  @see icmp_client.h
    3636 */
    3737
    38 #include <icmp_client.h>
    39 #include <icmp_header.h>
    40 #include <packet_client.h>
    41 
    4238#ifdef CONFIG_DEBUG
    43 #include <stdio.h>
     39        #include <stdio.h>
    4440#endif
    4541
     
    4844
    4945#include <net/icmp_codes.h>
     46#include <icmp_client.h>
    5047#include <net/packet.h>
     48#include <packet_client.h>
     49#include <icmp_header.h>
    5150
    52 /** Processes the received packet prefixed with an ICMP header.
    53  *
    54  * @param[in] packet    The received packet.
    55  * @param[out] type     The ICMP header type.
    56  * @param[out] code     The ICMP header code.
    57  * @param[out] pointer  The ICMP header pointer.
    58  * @param[out] mtu      The ICMP header MTU.
    59  * @returns             The ICMP header length.
    60  * @returns             Zero if the packet contains no data.
    61  */
    62 int
    63 icmp_client_process_packet(packet_t packet, icmp_type_t *type,
    64     icmp_code_t *code, icmp_param_t *pointer, icmp_param_t *mtu)
    65 {
     51int icmp_client_process_packet(packet_t packet, icmp_type_t * type, icmp_code_t * code, icmp_param_t * pointer, icmp_param_t * mtu){
    6652        icmp_header_ref header;
    6753
    6854        header = (icmp_header_ref) packet_get_data(packet);
    69         if (!header ||
    70             (packet_get_data_length(packet) < sizeof(icmp_header_t))) {
     55        if((! header)
     56                || (packet_get_data_length(packet) < sizeof(icmp_header_t))){
    7157                return 0;
    7258        }
    73 
    74         if (type)
     59        if(type){
    7560                *type = header->type;
    76         if (code)
     61        }
     62        if(code){
    7763                *code = header->code;
    78         if (pointer)
     64        }
     65        if(pointer){
    7966                *pointer = header->un.param.pointer;
    80         if (mtu)
     67        }
     68        if(mtu){
    8169                *mtu = header->un.frag.mtu;
    82 
     70        }
    8371        // remove debug dump
    8472#ifdef CONFIG_DEBUG
    85         printf("ICMP error %d (%d) in packet %d\n", header->type, header->code,
    86             packet_get_id(packet));
     73        printf("ICMP error %d (%d) in packet %d\n", header->type, header->code, packet_get_id(packet));
    8774#endif
    8875        return sizeof(icmp_header_t);
    8976}
    9077
    91 /** Returns the ICMP header length.
    92  *
    93  * @param[in] packet    The packet.
    94  * @returns             The ICMP header length in bytes.
    95  */
    96 size_t icmp_client_header_length(packet_t packet)
    97 {
    98         if (packet_get_data_length(packet) < sizeof(icmp_header_t))
     78size_t icmp_client_header_length(packet_t packet){
     79        if(packet_get_data_length(packet) < sizeof(icmp_header_t)){
    9980                return 0;
    100 
     81        }
    10182        return sizeof(icmp_header_t);
    10283}
Note: See TracChangeset for help on using the changeset viewer.