ip_icmp.h
001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019: #ifndef __NETINET_IP_ICMP_H
020: #define __NETINET_IP_ICMP_H 1
021:
022: #include <sys/cdefs.h>
023: #include <sys/types.h>
024:
025: __BEGIN_DECLS
026:
027: struct icmphdr
028: {
029: u_int8_t type;
030: u_int8_t code;
031: u_int16_t checksum;
032: union
033: {
034: struct
035: {
036: u_int16_t id;
037: u_int16_t sequence;
038: } echo;
039: u_int32_t gateway;
040: struct
041: {
042: u_int16_t __unused;
043: u_int16_t mtu;
044: } frag;
045: } un;
046: };
047:
048: #define ICMP_ECHOREPLY 0
049: #define ICMP_DEST_UNREACH 3
050: #define ICMP_SOURCE_QUENCH 4
051: #define ICMP_REDIRECT 5
052: #define ICMP_ECHO 8
053: #define ICMP_TIME_EXCEEDED 11
054: #define ICMP_PARAMETERPROB 12
055: #define ICMP_TIMESTAMP 13
056: #define ICMP_TIMESTAMPREPLY 14
057: #define ICMP_INFO_REQUEST 15
058: #define ICMP_INFO_REPLY 16
059: #define ICMP_ADDRESS 17
060: #define ICMP_ADDRESSREPLY 18
061: #define NR_ICMP_TYPES 18
062:
063:
064:
065: #define ICMP_NET_UNREACH 0
066: #define ICMP_HOST_UNREACH 1
067: #define ICMP_PROT_UNREACH 2
068: #define ICMP_PORT_UNREACH 3
069: #define ICMP_FRAG_NEEDED 4
070: #define ICMP_SR_FAILED 5
071: #define ICMP_NET_UNKNOWN 6
072: #define ICMP_HOST_UNKNOWN 7
073: #define ICMP_HOST_ISOLATED 8
074: #define ICMP_NET_ANO 9
075: #define ICMP_HOST_ANO 10
076: #define ICMP_NET_UNR_TOS 11
077: #define ICMP_HOST_UNR_TOS 12
078: #define ICMP_PKT_FILTERED 13
079: #define ICMP_PREC_VIOLATION 14
080: #define ICMP_PREC_CUTOFF 15
081: #define NR_ICMP_UNREACH 15
082:
083:
084: #define ICMP_REDIR_NET 0
085: #define ICMP_REDIR_HOST 1
086: #define ICMP_REDIR_NETTOS 2
087: #define ICMP_REDIR_HOSTTOS 3
088:
089:
090: #define ICMP_EXC_TTL 0
091: #define ICMP_EXC_FRAGTIME 1
092:
093:
094: #ifdef __USE_BSD
095:
096:
097:
098:
099:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126: #include <netinet/in.h>
127: #include <netinet/ip.h>
128:
129:
130:
131:
132: struct icmp_ra_addr
133: {
134: u_int32_t ira_addr;
135: u_int32_t ira_preference;
136: };
137:
138: struct icmp
139: {
140: u_int8_t icmp_type;
141: u_int8_t icmp_code;
142: u_int16_t icmp_cksum;
143: union
144: {
145: u_char ih_pptr;
146: struct in_addr ih_gwaddr;
147: struct ih_idseq
148: {
149: u_int16_t icd_id;
150: u_int16_t icd_seq;
151: } ih_idseq;
152: u_int32_t ih_void;
153:
154:
155: struct ih_pmtu
156: {
157: u_int16_t ipm_void;
158: u_int16_t ipm_nextmtu;
159: } ih_pmtu;
160:
161: struct ih_rtradv
162: {
163: u_int8_t irt_num_addrs;
164: u_int8_t irt_wpa;
165: u_int16_t irt_lifetime;
166: } ih_rtradv;
167: } icmp_hun;
168: #define icmp_pptr icmp_hun.ih_pptr
169: #define icmp_gwaddr icmp_hun.ih_gwaddr
170: #define icmp_id icmp_hun.ih_idseq.icd_id
171: #define icmp_seq icmp_hun.ih_idseq.icd_seq
172: #define icmp_void icmp_hun.ih_void
173: #define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
174: #define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
175: #define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
176: #define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
177: #define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
178: union
179: {
180: struct
181: {
182: u_int32_t its_otime;
183: u_int32_t its_rtime;
184: u_int32_t its_ttime;
185: } id_ts;
186: struct
187: {
188: struct ip idi_ip;
189:
190: } id_ip;
191: struct icmp_ra_addr id_radv;
192: u_int32_t id_mask;
193: u_int8_t id_data[1];
194: } icmp_dun;
195: #define icmp_otime icmp_dun.id_ts.its_otime
196: #define icmp_rtime icmp_dun.id_ts.its_rtime
197: #define icmp_ttime icmp_dun.id_ts.its_ttime
198: #define icmp_ip icmp_dun.id_ip.idi_ip
199: #define icmp_radv icmp_dun.id_radv
200: #define icmp_mask icmp_dun.id_mask
201: #define icmp_data icmp_dun.id_data
202: };
203:
204:
205:
206:
207:
208:
209:
210:
211:
212: #define ICMP_MINLEN 8
213: #define ICMP_TSLEN (8 + 3 * sizeof (n_time))
214: #define ICMP_MASKLEN 12
215: #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8)
216: #ifndef _IP_VHL
217: #define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
218:
219: #else
220: #define ICMP_ADVLEN(p) (8 + (IP_VHL_HL((p)->icmp_ip.ip_vhl) << 2) + 8)
221:
222: #endif
223:
224:
225:
226: #define ICMP_UNREACH 3
227: #define ICMP_SOURCEQUENCH 4
228: #define ICMP_ROUTERADVERT 9
229: #define ICMP_ROUTERSOLICIT 10
230: #define ICMP_TIMXCEED 11
231: #define ICMP_PARAMPROB 12
232: #define ICMP_TSTAMP 13
233: #define ICMP_TSTAMPREPLY 14
234: #define ICMP_IREQ 15
235: #define ICMP_IREQREPLY 16
236: #define ICMP_MASKREQ 17
237: #define ICMP_MASKREPLY 18
238:
239: #define ICMP_MAXTYPE 18
240:
241:
242: #define ICMP_UNREACH_NET 0
243: #define ICMP_UNREACH_HOST 1
244: #define ICMP_UNREACH_PROTOCOL 2
245: #define ICMP_UNREACH_PORT 3
246: #define ICMP_UNREACH_NEEDFRAG 4
247: #define ICMP_UNREACH_SRCFAIL 5
248: #define ICMP_UNREACH_NET_UNKNOWN 6
249: #define ICMP_UNREACH_HOST_UNKNOWN 7
250: #define ICMP_UNREACH_ISOLATED 8
251: #define ICMP_UNREACH_NET_PROHIB 9
252: #define ICMP_UNREACH_HOST_PROHIB 10
253: #define ICMP_UNREACH_TOSNET 11
254: #define ICMP_UNREACH_TOSHOST 12
255: #define ICMP_UNREACH_FILTER_PROHIB 13
256: #define ICMP_UNREACH_HOST_PRECEDENCE 14
257: #define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
258:
259:
260: #define ICMP_REDIRECT_NET 0
261: #define ICMP_REDIRECT_HOST 1
262: #define ICMP_REDIRECT_TOSNET 2
263: #define ICMP_REDIRECT_TOSHOST 3
264:
265:
266: #define ICMP_TIMXCEED_INTRANS 0
267: #define ICMP_TIMXCEED_REASS 1
268:
269:
270: #define ICMP_PARAMPROB_OPTABSENT 1
271:
272: #define ICMP_INFOTYPE(type) \
273: ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
274: (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
275: (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
276: (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
277: (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
278:
279: #endif
280:
281: __END_DECLS
282:
283: #endif
284:
© Andrew Scott 2006 -
2025,
All Rights Reserved