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