OLD | NEW |
1 #ifndef _NETINET_IP_ICMP_H | 1 #ifndef _NETINET_IP_ICMP_H |
2 #define _NETINET_IP_ICMP_H | 2 #define _NETINET_IP_ICMP_H |
3 | 3 |
4 #include <stdint.h> | 4 #include <stdint.h> |
5 #include <netinet/in.h> | 5 #include <netinet/in.h> |
6 #include <netinet/ip.h> | 6 #include <netinet/ip.h> |
7 | 7 |
8 #ifdef __cplusplus | 8 #ifdef __cplusplus |
9 extern "C" { | 9 extern "C" { |
10 #endif | 10 #endif |
11 | 11 |
12 struct icmphdr { | 12 struct icmphdr { |
13 » uint8_t type; | 13 uint8_t type; |
14 » uint8_t code; | 14 uint8_t code; |
15 » uint16_t checksum; | 15 uint16_t checksum; |
16 » union { | 16 union { |
17 » » struct { | 17 struct { |
18 » » » uint16_t id; | 18 uint16_t id; |
19 » » » uint16_t sequence; | 19 uint16_t sequence; |
20 » » } echo; | 20 } echo; |
21 » » uint32_t gateway; | 21 uint32_t gateway; |
22 » » struct { | 22 struct { |
23 » » » uint16_t __unused; | 23 uint16_t __unused; |
24 » » » uint16_t mtu; | 24 uint16_t mtu; |
25 » » } frag; | 25 } frag; |
26 » } un; | 26 } un; |
27 }; | 27 }; |
28 | 28 |
29 #define ICMP_ECHOREPLY» » 0 | 29 #define ICMP_ECHOREPLY 0 |
30 #define ICMP_DEST_UNREACH» 3 | 30 #define ICMP_DEST_UNREACH 3 |
31 #define ICMP_SOURCE_QUENCH» 4 | 31 #define ICMP_SOURCE_QUENCH 4 |
32 #define ICMP_REDIRECT» » 5 | 32 #define ICMP_REDIRECT 5 |
33 #define ICMP_ECHO» » 8 | 33 #define ICMP_ECHO 8 |
34 #define ICMP_TIME_EXCEEDED» 11 | 34 #define ICMP_TIME_EXCEEDED 11 |
35 #define ICMP_PARAMETERPROB» 12 | 35 #define ICMP_PARAMETERPROB 12 |
36 #define ICMP_TIMESTAMP» » 13 | 36 #define ICMP_TIMESTAMP 13 |
37 #define ICMP_TIMESTAMPREPLY» 14 | 37 #define ICMP_TIMESTAMPREPLY 14 |
38 #define ICMP_INFO_REQUEST» 15 | 38 #define ICMP_INFO_REQUEST 15 |
39 #define ICMP_INFO_REPLY»» 16 | 39 #define ICMP_INFO_REPLY 16 |
40 #define ICMP_ADDRESS» » 17 | 40 #define ICMP_ADDRESS 17 |
41 #define ICMP_ADDRESSREPLY» 18 | 41 #define ICMP_ADDRESSREPLY 18 |
42 #define NR_ICMP_TYPES» » 18 | 42 #define NR_ICMP_TYPES 18 |
43 | 43 |
| 44 #define ICMP_NET_UNREACH 0 |
| 45 #define ICMP_HOST_UNREACH 1 |
| 46 #define ICMP_PROT_UNREACH 2 |
| 47 #define ICMP_PORT_UNREACH 3 |
| 48 #define ICMP_FRAG_NEEDED 4 |
| 49 #define ICMP_SR_FAILED 5 |
| 50 #define ICMP_NET_UNKNOWN 6 |
| 51 #define ICMP_HOST_UNKNOWN 7 |
| 52 #define ICMP_HOST_ISOLATED 8 |
| 53 #define ICMP_NET_ANO 9 |
| 54 #define ICMP_HOST_ANO 10 |
| 55 #define ICMP_NET_UNR_TOS 11 |
| 56 #define ICMP_HOST_UNR_TOS 12 |
| 57 #define ICMP_PKT_FILTERED 13 |
| 58 #define ICMP_PREC_VIOLATION 14 |
| 59 #define ICMP_PREC_CUTOFF 15 |
| 60 #define NR_ICMP_UNREACH 15 |
44 | 61 |
45 #define ICMP_NET_UNREACH» 0 | 62 #define ICMP_REDIR_NET 0 |
46 #define ICMP_HOST_UNREACH» 1 | 63 #define ICMP_REDIR_HOST 1 |
47 #define ICMP_PROT_UNREACH» 2 | 64 #define ICMP_REDIR_NETTOS 2 |
48 #define ICMP_PORT_UNREACH» 3 | 65 #define ICMP_REDIR_HOSTTOS 3 |
49 #define ICMP_FRAG_NEEDED» 4 | |
50 #define ICMP_SR_FAILED» » 5 | |
51 #define ICMP_NET_UNKNOWN» 6 | |
52 #define ICMP_HOST_UNKNOWN» 7 | |
53 #define ICMP_HOST_ISOLATED» 8 | |
54 #define ICMP_NET_ANO» » 9 | |
55 #define ICMP_HOST_ANO» » 10 | |
56 #define ICMP_NET_UNR_TOS» 11 | |
57 #define ICMP_HOST_UNR_TOS» 12 | |
58 #define ICMP_PKT_FILTERED» 13 | |
59 #define ICMP_PREC_VIOLATION» 14 | |
60 #define ICMP_PREC_CUTOFF» 15 | |
61 #define NR_ICMP_UNREACH»» 15 | |
62 | 66 |
63 #define ICMP_REDIR_NET» » 0 | 67 #define ICMP_EXC_TTL 0 |
64 #define ICMP_REDIR_HOST»» 1 | 68 #define ICMP_EXC_FRAGTIME 1 |
65 #define ICMP_REDIR_NETTOS» 2 | |
66 #define ICMP_REDIR_HOSTTOS» 3 | |
67 | |
68 #define ICMP_EXC_TTL» » 0 | |
69 #define ICMP_EXC_FRAGTIME» 1 | |
70 | |
71 | 69 |
72 struct icmp_ra_addr { | 70 struct icmp_ra_addr { |
73 » uint32_t ira_addr; | 71 uint32_t ira_addr; |
74 » uint32_t ira_preference; | 72 uint32_t ira_preference; |
75 }; | 73 }; |
76 | 74 |
77 struct icmp { | 75 struct icmp { |
78 » uint8_t icmp_type; | 76 uint8_t icmp_type; |
79 » uint8_t icmp_code; | 77 uint8_t icmp_code; |
80 » uint16_t icmp_cksum; | 78 uint16_t icmp_cksum; |
81 » union { | 79 union { |
82 » » uint8_t ih_pptr; | 80 uint8_t ih_pptr; |
83 » » struct in_addr ih_gwaddr; | 81 struct in_addr ih_gwaddr; |
84 » » struct ih_idseq { | 82 struct ih_idseq { |
85 » » » uint16_t icd_id; | 83 uint16_t icd_id; |
86 » » » uint16_t icd_seq; | 84 uint16_t icd_seq; |
87 » » } ih_idseq; | 85 } ih_idseq; |
88 » » uint32_t ih_void; | 86 uint32_t ih_void; |
89 | 87 |
90 » » struct ih_pmtu { | 88 struct ih_pmtu { |
91 » » » uint16_t ipm_void; | 89 uint16_t ipm_void; |
92 » » » uint16_t ipm_nextmtu; | 90 uint16_t ipm_nextmtu; |
93 » » } ih_pmtu; | 91 } ih_pmtu; |
94 | 92 |
95 » » struct ih_rtradv { | 93 struct ih_rtradv { |
96 » » » uint8_t irt_num_addrs; | 94 uint8_t irt_num_addrs; |
97 » » » uint8_t irt_wpa; | 95 uint8_t irt_wpa; |
98 » » » uint16_t irt_lifetime; | 96 uint16_t irt_lifetime; |
99 » » } ih_rtradv; | 97 } ih_rtradv; |
100 » } icmp_hun; | 98 } icmp_hun; |
101 » union { | 99 union { |
102 » » struct { | 100 struct { |
103 » » » uint32_t its_otime; | 101 uint32_t its_otime; |
104 » » » uint32_t its_rtime; | 102 uint32_t its_rtime; |
105 » » » uint32_t its_ttime; | 103 uint32_t its_ttime; |
106 » » } id_ts; | 104 } id_ts; |
107 » » struct { | 105 struct { |
108 » » » struct ip idi_ip; | 106 struct ip idi_ip; |
109 » » } id_ip; | 107 } id_ip; |
110 » » struct icmp_ra_addr id_radv; | 108 struct icmp_ra_addr id_radv; |
111 » » uint32_t id_mask; | 109 uint32_t id_mask; |
112 » » uint8_t id_data[1]; | 110 uint8_t id_data[1]; |
113 » } icmp_dun; | 111 } icmp_dun; |
114 }; | 112 }; |
115 | 113 |
116 #define»icmp_pptr» icmp_hun.ih_pptr | 114 #define icmp_pptr icmp_hun.ih_pptr |
117 #define»icmp_gwaddr» icmp_hun.ih_gwaddr | 115 #define icmp_gwaddr icmp_hun.ih_gwaddr |
118 #define»icmp_id»» icmp_hun.ih_idseq.icd_id | 116 #define icmp_id icmp_hun.ih_idseq.icd_id |
119 #define»icmp_seq» icmp_hun.ih_idseq.icd_seq | 117 #define icmp_seq icmp_hun.ih_idseq.icd_seq |
120 #define»icmp_void» icmp_hun.ih_void | 118 #define icmp_void icmp_hun.ih_void |
121 #define»icmp_pmvoid» icmp_hun.ih_pmtu.ipm_void | 119 #define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void |
122 #define»icmp_nextmtu» icmp_hun.ih_pmtu.ipm_nextmtu | 120 #define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu |
123 #define»icmp_num_addrs» icmp_hun.ih_rtradv.irt_num_addrs | 121 #define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs |
124 #define»icmp_wpa» icmp_hun.ih_rtradv.irt_wpa | 122 #define icmp_wpa icmp_hun.ih_rtradv.irt_wpa |
125 #define»icmp_lifetime» icmp_hun.ih_rtradv.irt_lifetime | 123 #define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime |
126 #define»icmp_otime» icmp_dun.id_ts.its_otime | 124 #define icmp_otime icmp_dun.id_ts.its_otime |
127 #define»icmp_rtime» icmp_dun.id_ts.its_rtime | 125 #define icmp_rtime icmp_dun.id_ts.its_rtime |
128 #define»icmp_ttime» icmp_dun.id_ts.its_ttime | 126 #define icmp_ttime icmp_dun.id_ts.its_ttime |
129 #define»icmp_ip»» icmp_dun.id_ip.idi_ip | 127 #define icmp_ip icmp_dun.id_ip.idi_ip |
130 #define»icmp_radv» icmp_dun.id_radv | 128 #define icmp_radv icmp_dun.id_radv |
131 #define»icmp_mask» icmp_dun.id_mask | 129 #define icmp_mask icmp_dun.id_mask |
132 #define»icmp_data» icmp_dun.id_data | 130 #define icmp_data icmp_dun.id_data |
133 | 131 |
134 #define»ICMP_MINLEN» 8 | 132 #define ICMP_MINLEN 8 |
135 #define»ICMP_TSLEN» (8 + 3 * sizeof (n_time)) | 133 #define ICMP_TSLEN (8 + 3 * sizeof(n_time)) |
136 #define»ICMP_MASKLEN» 12 | 134 #define ICMP_MASKLEN 12 |
137 #define»ICMP_ADVLENMIN» (8 + sizeof (struct ip) + 8) | 135 #define ICMP_ADVLENMIN (8 + sizeof(struct ip) + 8) |
138 #define»ICMP_ADVLEN(p)» (8 + ((p)->icmp_ip.ip_hl << 2) + 8) | 136 #define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) |
139 | 137 |
140 #define»ICMP_UNREACH» » 3 | 138 #define ICMP_UNREACH 3 |
141 #define»ICMP_SOURCEQUENCH» 4 | 139 #define ICMP_SOURCEQUENCH 4 |
142 #define»ICMP_ROUTERADVERT» 9 | 140 #define ICMP_ROUTERADVERT 9 |
143 #define»ICMP_ROUTERSOLICIT» 10 | 141 #define ICMP_ROUTERSOLICIT 10 |
144 #define»ICMP_TIMXCEED» » 11 | 142 #define ICMP_TIMXCEED 11 |
145 #define»ICMP_PARAMPROB» » 12 | 143 #define ICMP_PARAMPROB 12 |
146 #define»ICMP_TSTAMP» » 13 | 144 #define ICMP_TSTAMP 13 |
147 #define»ICMP_TSTAMPREPLY» 14 | 145 #define ICMP_TSTAMPREPLY 14 |
148 #define»ICMP_IREQ» » 15 | 146 #define ICMP_IREQ 15 |
149 #define»ICMP_IREQREPLY» » 16 | 147 #define ICMP_IREQREPLY 16 |
150 #define»ICMP_MASKREQ» » 17 | 148 #define ICMP_MASKREQ 17 |
151 #define»ICMP_MASKREPLY» » 18 | 149 #define ICMP_MASKREPLY 18 |
152 #define»ICMP_MAXTYPE» » 18 | 150 #define ICMP_MAXTYPE 18 |
153 | 151 |
154 #define»ICMP_UNREACH_NET» 0 | 152 #define ICMP_UNREACH_NET 0 |
155 #define»ICMP_UNREACH_HOST» 1 | 153 #define ICMP_UNREACH_HOST 1 |
156 #define»ICMP_UNREACH_PROTOCOL» 2 | 154 #define ICMP_UNREACH_PROTOCOL 2 |
157 #define»ICMP_UNREACH_PORT» 3 | 155 #define ICMP_UNREACH_PORT 3 |
158 #define»ICMP_UNREACH_NEEDFRAG» 4 | 156 #define ICMP_UNREACH_NEEDFRAG 4 |
159 #define»ICMP_UNREACH_SRCFAIL» 5 | 157 #define ICMP_UNREACH_SRCFAIL 5 |
160 #define»ICMP_UNREACH_NET_UNKNOWN 6 | 158 #define ICMP_UNREACH_NET_UNKNOWN 6 |
161 #define»ICMP_UNREACH_HOST_UNKNOWN 7 | 159 #define ICMP_UNREACH_HOST_UNKNOWN 7 |
162 #define»ICMP_UNREACH_ISOLATED» 8 | 160 #define ICMP_UNREACH_ISOLATED 8 |
163 #define»ICMP_UNREACH_NET_PROHIB» 9 | 161 #define ICMP_UNREACH_NET_PROHIB 9 |
164 #define»ICMP_UNREACH_HOST_PROHIB 10 | 162 #define ICMP_UNREACH_HOST_PROHIB 10 |
165 #define»ICMP_UNREACH_TOSNET» 11 | 163 #define ICMP_UNREACH_TOSNET 11 |
166 #define»ICMP_UNREACH_TOSHOST» 12 | 164 #define ICMP_UNREACH_TOSHOST 12 |
167 #define»ICMP_UNREACH_FILTER_PROHIB 13 | 165 #define ICMP_UNREACH_FILTER_PROHIB 13 |
168 #define»ICMP_UNREACH_HOST_PRECEDENCE 14 | 166 #define ICMP_UNREACH_HOST_PRECEDENCE 14 |
169 #define»ICMP_UNREACH_PRECEDENCE_CUTOFF 15 | 167 #define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 |
170 | 168 |
171 #define»ICMP_REDIRECT_NET» 0 | 169 #define ICMP_REDIRECT_NET 0 |
172 #define»ICMP_REDIRECT_HOST» 1 | 170 #define ICMP_REDIRECT_HOST 1 |
173 #define»ICMP_REDIRECT_TOSNET» 2 | 171 #define ICMP_REDIRECT_TOSNET 2 |
174 #define»ICMP_REDIRECT_TOSHOST» 3 | 172 #define ICMP_REDIRECT_TOSHOST 3 |
175 | 173 |
176 #define»ICMP_TIMXCEED_INTRANS» 0 | 174 #define ICMP_TIMXCEED_INTRANS 0 |
177 #define»ICMP_TIMXCEED_REASS» 1 | 175 #define ICMP_TIMXCEED_REASS 1 |
178 | 176 |
179 #define»ICMP_PARAMPROB_OPTABSENT 1 | 177 #define ICMP_PARAMPROB_OPTABSENT 1 |
180 | 178 |
181 #define»ICMP_INFOTYPE(type) \ | 179 #define ICMP_INFOTYPE(type) \ |
182 » ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ | 180 ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ |
183 » (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ | 181 (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ |
184 » (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ | 182 (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ |
185 » (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ | 183 (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ |
186 » (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) | 184 (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) |
187 | 185 |
188 #ifdef __cplusplus | 186 #ifdef __cplusplus |
189 } | 187 } |
190 #endif | 188 #endif |
191 | 189 |
192 #endif | 190 #endif |
OLD | NEW |