source: trunk/src/emx/include/netinet/ip_icmp.h@ 2273

Last change on this file since 2273 was 1551, checked in by bird, 21 years ago

Updated to FreeBSD 5.2 level.

  • Property cvs2svn:cvs-rev set to 1.4
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 10.3 KB
Line 
1/** $Id: ip_icmp.h 1551 2004-10-09 08:46:16Z bird $ */
2/** @file
3 * FreeBSD 5.2
4 *
5 * @changed bird (2003): modified for gcc/os2
6 * @changed bird (2004): updated to FreeBSD 5.2 and __USE_LIBC_TCPIP
7 */
8
9/*
10 * Copyright (c) 1982, 1986, 1993
11 * The Regents of the University of California. All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
38 * $FreeBSD: src/sys/netinet/ip_icmp.h,v 1.22 2004/04/07 20:46:13 imp Exp $
39 */
40
41#ifndef _NETINET_IP_ICMP_H_
42#define _NETINET_IP_ICMP_H_
43
44/*
45 * Interface Control Message Protocol Definitions.
46 * Per RFC 792, September 1981.
47 */
48
49#ifdef __USE_LIBC_TCPIP
50/*
51 * Internal of an ICMP Router Advertisement
52 */
53struct icmp_ra_addr {
54 u_int32_t ira_addr;
55 u_int32_t ira_preference;
56};
57#endif
58
59/*
60 * Structure of an icmp header.
61 */
62#pragma pack(1)
63struct icmp {
64 u_char icmp_type; /* type of message, see below */
65 u_char icmp_code; /* type sub code */
66 u_short icmp_cksum; /* ones complement cksum of struct */
67 union {
68 u_char ih_pptr; /* ICMP_PARAMPROB */
69 struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
70 struct ih_idseq {
71 n_short icd_id;
72 n_short icd_seq;
73 } ih_idseq;
74 int ih_void;
75
76#if !defined(TCPV40HDRS) || defined(__USE_LIBC_TCPIP)
77 /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
78 struct ih_pmtu {
79 n_short ipm_void;
80 n_short ipm_nextmtu;
81 } ih_pmtu;
82
83#ifdef __USE_LIBC_TCPIP
84 struct ih_rtradv {
85 u_char irt_num_addrs;
86 u_char irt_wpa;
87 u_int16_t irt_lifetime;
88 } ih_rtradv;
89#endif
90#endif
91 } icmp_hun;
92#define icmp_pptr icmp_hun.ih_pptr
93#define icmp_gwaddr icmp_hun.ih_gwaddr
94#define icmp_id icmp_hun.ih_idseq.icd_id
95#define icmp_seq icmp_hun.ih_idseq.icd_seq
96#define icmp_void icmp_hun.ih_void
97#if !defined(TCPV40HDRS) || defined(__USE_LIBC_TCPIP)
98#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
99#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
100#ifdef __USE_LIBC_TCPIP
101#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
102#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
103#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
104#endif
105#endif
106 union {
107 struct id_ts { /* ICMP Timestamp */
108 n_time its_otime; /* Originate */
109 n_time its_rtime; /* Receive */
110 n_time its_ttime; /* Transmit */
111 } id_ts;
112 struct id_ip {
113 struct ip idi_ip;
114 /* options and then 64 bits of data */
115 } id_ip;
116#ifdef __USE_LIBC_TCPIP
117 struct icmp_ra_addr id_radv;
118 u_int32_t id_mask;
119#else
120 u_long id_mask;
121#endif
122 char id_data[1];
123 } icmp_dun;
124#define icmp_otime icmp_dun.id_ts.its_otime
125#define icmp_rtime icmp_dun.id_ts.its_rtime
126#define icmp_ttime icmp_dun.id_ts.its_ttime
127#define icmp_ip icmp_dun.id_ip.idi_ip
128#ifdef __USE_LIBC_TCPIP
129#define icmp_radv icmp_dun.id_radv
130#endif
131#define icmp_mask icmp_dun.id_mask
132#define icmp_data icmp_dun.id_data
133};
134#pragma pack()
135
136/*
137 * Lower bounds on packet lengths for various types.
138 * For the error advice packets must first insure that the
139 * packet is large enough to contain the returned ip header.
140 * Only then can we do the check to see if 64 bits of packet
141 * data have been returned, since we need to check the returned
142 * ip header length.
143 */
144#define ICMP_MINLEN 8 /* abs minimum */
145#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */
146#define ICMP_MASKLEN 12 /* address mask */
147#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
148#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
149 /* N.B.: must separately check that ip_hl >= 5 */
150
151/*
152 * Definition of type and code field values.
153 */
154#define ICMP_ECHOREPLY 0 /* echo reply */
155#define ICMP_UNREACH 3 /* dest unreachable, codes: */
156#define ICMP_UNREACH_NET 0 /* bad net */
157#define ICMP_UNREACH_HOST 1 /* bad host */
158#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
159#define ICMP_UNREACH_PORT 3 /* bad port */
160#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
161#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
162#if !defined(TCPV40HDRS) || defined(__USE_LIBC_TCPIP)
163#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
164#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
165#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
166#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */
167#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */
168#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
169#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
170#ifdef __USE_LIBC_TCPIP
171#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */
172#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */
173#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */
174#endif
175#endif
176#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
177#define ICMP_REDIRECT 5 /* shorter route, codes: */
178#define ICMP_REDIRECT_NET 0 /* for network */
179#define ICMP_REDIRECT_HOST 1 /* for host */
180#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
181#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
182#ifdef __USE_LIBC_TCPIP
183#define ICMP_ALTHOSTADDR 6 /* alternate host address */
184#endif
185#define ICMP_ECHO 8 /* echo service */
186#if !defined(TCPV40HDRS) || defined(__USE_LIBC_TCPIP)
187#define ICMP_ROUTERADVERT 9 /* router advertisement */
188#ifdef __USE_LIBC_TCPIP
189#define ICMP_ROUTERADVERT_NORMAL 0 /* normal advertisement */
190#define ICMP_ROUTERADVERT_NOROUTE_COMMON 16 /* selective routing */
191#endif
192#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
193#endif
194#define ICMP_TIMXCEED 11 /* time exceeded, code: */
195#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
196#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
197#define ICMP_PARAMPROB 12 /* ip header bad */
198#if !defined(TCPV40HDRS) || defined(__USE_LIBC_TCPIP)
199#ifdef __USE_LIBC_TCPIP
200#define ICMP_PARAMPROB_ERRATPTR 0 /* error at param ptr */
201#endif
202#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
203#ifdef __USE_LIBC_TCPIP
204#define ICMP_PARAMPROB_LENGTH 2 /* bad length */
205#endif
206#endif
207#define ICMP_TSTAMP 13 /* timestamp request */
208#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
209#define ICMP_IREQ 15 /* information request */
210#define ICMP_IREQREPLY 16 /* information reply */
211#define ICMP_MASKREQ 17 /* address mask request */
212#define ICMP_MASKREPLY 18 /* address mask reply */
213#ifdef __USE_LIBC_TCPIP
214#define ICMP_TRACEROUTE 30 /* traceroute */
215#define ICMP_DATACONVERR 31 /* data conversion error */
216#define ICMP_MOBILE_REDIRECT 32 /* mobile host redirect */
217#define ICMP_IPV6_WHEREAREYOU 33 /* IPv6 where-are-you */
218#define ICMP_IPV6_IAMHERE 34 /* IPv6 i-am-here */
219#define ICMP_MOBILE_REGREQUEST 35 /* mobile registration req */
220#define ICMP_MOBILE_REGREPLY 36 /* mobile registration reply */
221#define ICMP_SKIP 39 /* SKIP */
222#define ICMP_PHOTURIS 40 /* Photuris */
223#define ICMP_PHOTURIS_UNKNOWN_INDEX 1 /* unknown sec index */
224#define ICMP_PHOTURIS_AUTH_FAILED 2 /* auth failed */
225#define ICMP_PHOTURIS_DECRYPT_FAILED 3 /* decrypt failed */
226#endif
227
228#ifdef __USE_LIBC_TCPIP
229#define ICMP_MAXTYPE 40
230#else
231#define ICMP_MAXTYPE 18
232#endif
233
234#ifndef TCPV40HDRS
235#define ICMP_INFOTYPE(type) \
236 ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
237 (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
238 (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
239 (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
240 (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
241#else
242#define ICMP_INFOTYPE(type) \
243 ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
244 (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
245 (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
246 (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
247#endif
248
249#ifdef _KERNEL
250void icmp_error(struct mbuf *, int, int, n_long, struct ifnet *);
251void icmp_input(struct mbuf *, int);
252#endif
253
254#ifdef TCPV40HDRS
255#pragma pack(1)
256struct icmpstat {
257/* statistics related to icmp packets generated */
258 short icps_error;
259 short icps_oldshort;
260 short icps_oldicmp;
261 short icps_outhist[ICMP_MAXTYPE + 1];
262/* statistics related to input messages processed */
263 short icps_badcode;
264 short icps_tooshort;
265 short icps_checksum;
266 short icps_badlen;
267 short icps_reflect;
268 short icps_inhist[ICMP_MAXTYPE + 1];
269 u_long icps_OutMsgs;
270 u_long icps_OutErrors;
271 u_long icps_InMsgs;
272 u_long icps_InDestUnreachs;
273 u_long icps_InTimeExcds;
274 u_long icps_InParmProbs;
275 u_long icps_InSrcQuenchs;
276 u_long icps_InRedirects;
277 u_long icps_InEchos;
278 u_long icps_InEchoReps;
279 u_long icps_InTimestamps;
280 u_long icps_InTimestampReps;
281 u_long icps_InAddrMasks;
282 u_long icps_InAddrMaskReps;
283 u_long icps_OutDestUnreachs;
284 u_long icps_OutTimeExcds;
285 u_long icps_OutParmProbs;
286 u_long icps_OutSrcQuenchs;
287 u_long icps_OutRedirects;
288 u_long icps_OutEchos;
289 u_long icps_OutEchoReps;
290 u_long icps_OutTimestamps;
291 u_long icps_OutTimestampReps;
292 u_long icps_OutAddrMasks;
293 u_long icps_OutAddrMaskReps;
294};
295#pragma pack()
296#endif
297
298#endif /* !_NETINET_IP_ICMP_H_ */
Note: See TracBrowser for help on using the repository browser.