Changeset 0b749a3 in mainline for uspace/lib/net/tl/icmp_client.c


Ignore:
Timestamp:
2010-11-22T15:39:53Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0eddb76, aae339e9
Parents:
9a1d8ab (diff), 8cd1aa5e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge development/ changes

File:
1 edited

Legend:

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

    r9a1d8ab r0b749a3  
    2727 */
    2828
    29 /** @addtogroup icmp
    30  *  @{
     29/** @addtogroup libnet
     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
    3842#ifdef CONFIG_DEBUG
    39         #include <stdio.h>
     43#include <stdio.h>
    4044#endif
    4145
     
    4347#include <sys/types.h>
    4448
    45 #include <icmp_codes.h>
    46 #include <icmp_client.h>
    47 #include <packet/packet.h>
    48 #include <packet/packet_client.h>
    49 #include <icmp_header.h>
     49#include <net/icmp_codes.h>
     50#include <net/packet.h>
    5051
    51 int icmp_client_process_packet(packet_t packet, icmp_type_t * type, icmp_code_t * code, icmp_param_t * pointer, icmp_param_t * mtu){
    52         icmp_header_ref header;
     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 * @return              The ICMP header length.
     60 * @return              Zero if the packet contains no data.
     61 */
     62int
     63icmp_client_process_packet(packet_t *packet, icmp_type_t *type,
     64    icmp_code_t *code, icmp_param_t *pointer, icmp_param_t *mtu)
     65{
     66        icmp_header_t *header;
    5367
    54         header = (icmp_header_ref) packet_get_data(packet);
    55         if((! header)
    56                 || (packet_get_data_length(packet) < sizeof(icmp_header_t))){
     68        header = (icmp_header_t *) packet_get_data(packet);
     69        if (!header ||
     70            (packet_get_data_length(packet) < sizeof(icmp_header_t))) {
    5771                return 0;
    5872        }
    59         if(type){
     73
     74        if (type)
    6075                *type = header->type;
    61         }
    62         if(code){
     76        if (code)
    6377                *code = header->code;
    64         }
    65         if(pointer){
     78        if (pointer)
    6679                *pointer = header->un.param.pointer;
    67         }
    68         if(mtu){
     80        if (mtu)
    6981                *mtu = header->un.frag.mtu;
    70         }
     82
    7183        // remove debug dump
    7284#ifdef CONFIG_DEBUG
    73         printf("ICMP error %d (%d) in packet %d\n", header->type, header->code, packet_get_id(packet));
     85        printf("ICMP error %d (%d) in packet %d\n", header->type, header->code,
     86            packet_get_id(packet));
    7487#endif
    7588        return sizeof(icmp_header_t);
    7689}
    7790
    78 size_t icmp_client_header_length(packet_t packet){
    79         if(packet_get_data_length(packet) < sizeof(icmp_header_t)){
     91/** Returns the ICMP header length.
     92 *
     93 * @param[in] packet    The packet.
     94 * @return              The ICMP header length in bytes.
     95 */
     96size_t icmp_client_header_length(packet_t *packet)
     97{
     98        if (packet_get_data_length(packet) < sizeof(icmp_header_t))
    8099                return 0;
    81         }
     100
    82101        return sizeof(icmp_header_t);
    83102}
Note: See TracChangeset for help on using the changeset viewer.