Subversion Repositories HelenOS

Rev

Rev 4719 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4707 mejdrech 1
/*
2
 * Copyright (c) 2009 Lukas Mejdrech
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 *
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
 
29
/** @addtogroup icmp
30
 *  @{
31
 */
32
 
33
/** @file
34
 *  ICMP header definition.
4728 mejdrech 35
 *  Based on the RFC~792.
4707 mejdrech 36
 */
37
 
38
#ifndef __NET_ICMP_HEADER_H__
39
#define __NET_ICMP_HEADER_H__
40
 
41
#include <sys/types.h>
42
 
43
#include "../../include/in.h"
44
#include "../../include/icmp_codes.h"
45
 
4715 mejdrech 46
/** Type definition of the echo specific data.
47
 *  @see icmp_echo
48
 */
49
typedef struct icmp_echo    icmp_echo_t;
50
 
51
/** Type definition of the echo specific data pointer.
52
 *  @see icmp_echo
53
 */
54
typedef icmp_echo_t *       icmp_echo_ref;
55
 
56
/** Echo specific data.
57
 */
58
struct icmp_echo{
59
    /** Message idintifier.
60
     */
4728 mejdrech 61
    icmp_param_t    identifier;
4715 mejdrech 62
    /** Message sequence number.
63
     */
4728 mejdrech 64
    icmp_param_t    sequence_number;
4715 mejdrech 65
} __attribute__ ((packed));
66
 
67
/** Type definition of the internet control message header.
4707 mejdrech 68
 *  @see icmp_header
69
 */
70
typedef struct icmp_header  icmp_header_t;
71
 
4715 mejdrech 72
/** Type definition of the internet control message header pointer.
4707 mejdrech 73
 *  @see icmp_header
74
 */
75
typedef icmp_header_t *     icmp_header_ref;
76
 
4715 mejdrech 77
/** Internet control message header.
4707 mejdrech 78
 */
79
struct icmp_header{
4728 mejdrech 80
    /** The type of the message.
4707 mejdrech 81
     */
82
    uint8_t type;
4728 mejdrech 83
    /** The error code for the datagram reported by the ICMP message.
4707 mejdrech 84
     *  The interpretation is dependent on the message type.
85
     */
86
    uint8_t code;
4728 mejdrech 87
    /** The checksum is the 16-bit ones's complement of the one's complement sum of the ICMP message starting with the ICMP Type.
88
     *  For computing the checksum, the checksum field should be zero.
4707 mejdrech 89
     *  If the checksum does not match the contents, the datagram is discarded.
90
     */
91
    uint16_t    checksum;
4715 mejdrech 92
    /** Message specific data.
4707 mejdrech 93
     */
94
    union{
4715 mejdrech 95
        /** Echo specific data.
96
         */
97
        icmp_echo_t         echo;
98
        /** Proposed gateway value.
99
         */
4707 mejdrech 100
        in_addr_t           gateway;
4715 mejdrech 101
        /** Fragmentation needed specific data.
102
         */
4707 mejdrech 103
        struct{
4728 mejdrech 104
            /** Reserved field.
105
             *  Must be zero.
4715 mejdrech 106
             */
4728 mejdrech 107
            icmp_param_t    reserved;
4715 mejdrech 108
            /** Proposed MTU.
109
             */
4707 mejdrech 110
            icmp_param_t    mtu;
111
        } frag;
4715 mejdrech 112
        /** Parameter problem specific data.
113
         */
4707 mejdrech 114
        struct{
4715 mejdrech 115
            /** Problem pointer.
116
             */
4707 mejdrech 117
            icmp_param_t    pointer;
4728 mejdrech 118
            /** Reserved field.
119
             *  Must be zero.
4715 mejdrech 120
             */
4728 mejdrech 121
            icmp_param_t    reserved;
4707 mejdrech 122
        } param;
123
    } un;
124
} __attribute__ ((packed));
125
 
126
#endif
127
 
128
/** @}
129
 */