OSDN Git Service

Add in a bunch of junk. Busybox now compiles (except for mkfs.minix and
[uclinux-h8/uClibc.git] / include / netinet / ip_icmp.h
1 /* Copyright (C) 1991, 92, 93, 95, 96, 97 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public License as
6    published by the Free Software Foundation; either version 2 of the
7    License, or (at your option) any later version.
8
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13
14    You should have received a copy of the GNU Library General Public
15    License along with the GNU C Library; see the file COPYING.LIB.  If not,
16    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17    Boston, MA 02111-1307, USA.  */
18
19 #ifndef __NETINET_IP_ICMP_H
20 #define __NETINET_IP_ICMP_H    1
21
22 #include <sys/cdefs.h>
23 #include <sys/types.h>
24
25 __BEGIN_DECLS
26
27 struct icmphdr
28 {
29   u_int8_t type;                /* message type */
30   u_int8_t code;                /* type sub-code */
31   u_int16_t checksum;
32   union
33   {
34     struct
35     {
36       u_int16_t id;
37       u_int16_t sequence;
38     } echo;                     /* echo datagram */
39     u_int32_t   gateway;        /* gateway address */
40     struct
41     {
42       u_int16_t __unused;
43       u_int16_t mtu;
44     } frag;                     /* path mtu discovery */
45   } un;
46 };
47
48 #define ICMP_ECHOREPLY          0       /* Echo Reply                   */
49 #define ICMP_DEST_UNREACH       3       /* Destination Unreachable      */
50 #define ICMP_SOURCE_QUENCH      4       /* Source Quench                */
51 #define ICMP_REDIRECT           5       /* Redirect (change route)      */
52 #define ICMP_ECHO               8       /* Echo Request                 */
53 #define ICMP_TIME_EXCEEDED      11      /* Time Exceeded                */
54 #define ICMP_PARAMETERPROB      12      /* Parameter Problem            */
55 #define ICMP_TIMESTAMP          13      /* Timestamp Request            */
56 #define ICMP_TIMESTAMPREPLY     14      /* Timestamp Reply              */
57 #define ICMP_INFO_REQUEST       15      /* Information Request          */
58 #define ICMP_INFO_REPLY         16      /* Information Reply            */
59 #define ICMP_ADDRESS            17      /* Address Mask Request         */
60 #define ICMP_ADDRESSREPLY       18      /* Address Mask Reply           */
61 #define NR_ICMP_TYPES           18
62
63
64 /* Codes for UNREACH. */
65 #define ICMP_NET_UNREACH        0       /* Network Unreachable          */
66 #define ICMP_HOST_UNREACH       1       /* Host Unreachable             */
67 #define ICMP_PROT_UNREACH       2       /* Protocol Unreachable         */
68 #define ICMP_PORT_UNREACH       3       /* Port Unreachable             */
69 #define ICMP_FRAG_NEEDED        4       /* Fragmentation Needed/DF set  */
70 #define ICMP_SR_FAILED          5       /* Source Route failed          */
71 #define ICMP_NET_UNKNOWN        6
72 #define ICMP_HOST_UNKNOWN       7
73 #define ICMP_HOST_ISOLATED      8
74 #define ICMP_NET_ANO            9
75 #define ICMP_HOST_ANO           10
76 #define ICMP_NET_UNR_TOS        11
77 #define ICMP_HOST_UNR_TOS       12
78 #define ICMP_PKT_FILTERED       13      /* Packet filtered */
79 #define ICMP_PREC_VIOLATION     14      /* Precedence violation */
80 #define ICMP_PREC_CUTOFF        15      /* Precedence cut off */
81 #define NR_ICMP_UNREACH         15      /* instead of hardcoding immediate value */
82
83 /* Codes for REDIRECT. */
84 #define ICMP_REDIR_NET          0       /* Redirect Net                 */
85 #define ICMP_REDIR_HOST         1       /* Redirect Host                */
86 #define ICMP_REDIR_NETTOS       2       /* Redirect Net for TOS         */
87 #define ICMP_REDIR_HOSTTOS      3       /* Redirect Host for TOS        */
88
89 /* Codes for TIME_EXCEEDED. */
90 #define ICMP_EXC_TTL            0       /* TTL count exceeded           */
91 #define ICMP_EXC_FRAGTIME       1       /* Fragment Reass time exceeded */
92
93
94 #ifdef __USE_BSD
95 /*
96  * Copyright (c) 1982, 1986, 1993
97  *      The Regents of the University of California.  All rights reserved.
98  *
99  * Redistribution and use in source and binary forms, with or without
100  * modification, are permitted provided that the following conditions
101  * are met:
102  * 1. Redistributions of source code must retain the above copyright
103  *    notice, this list of conditions and the following disclaimer.
104  * 2. Redistributions in binary form must reproduce the above copyright
105  *    notice, this list of conditions and the following disclaimer in the
106  *    documentation and/or other materials provided with the distribution.
107  * 3. All advertising materials mentioning features or use of this software
108  *    must display the following acknowledgement:
109  *      This product includes software developed by the University of
110  *      California, Berkeley and its contributors.
111  * 4. Neither the name of the University nor the names of its contributors
112  *    may be used to endorse or promote products derived from this software
113  *    without specific prior written permission.
114  *
115  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
116  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
117  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
118  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
119  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
120  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
121  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
122  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
123  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
124  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
125  * SUCH DAMAGE.
126  *
127  *      @(#)ip_icmp.h   8.1 (Berkeley) 6/10/93
128  */
129
130 #include <netinet/in.h>
131 #include <netinet/ip.h>
132
133 /*
134  * Internal of an ICMP Router Advertisement
135  */
136 struct icmp_ra_addr
137 {
138   u_int32_t ira_addr;
139   u_int32_t ira_preference;
140 };
141
142 struct icmp
143 {
144   u_int8_t  icmp_type;  /* type of message, see below */
145   u_int8_t  icmp_code;  /* type sub code */
146   u_int16_t icmp_cksum; /* ones complement checksum of struct */
147   union
148   {
149     u_char ih_pptr;             /* ICMP_PARAMPROB */
150     struct in_addr ih_gwaddr;   /* gateway address */
151     struct ih_idseq             /* echo datagram */
152     {
153       u_int16_t icd_id;
154       u_int16_t icd_seq;
155     } ih_idseq;
156     u_int32_t ih_void;
157
158     /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
159     struct ih_pmtu
160     {
161       u_int16_t ipm_void;
162       u_int16_t ipm_nextmtu;
163     } ih_pmtu;
164
165     struct ih_rtradv
166     {
167       u_int8_t irt_num_addrs;
168       u_int8_t irt_wpa;
169       u_int16_t irt_lifetime;
170     } ih_rtradv;
171   } icmp_hun;
172 #define icmp_pptr       icmp_hun.ih_pptr
173 #define icmp_gwaddr     icmp_hun.ih_gwaddr
174 #define icmp_id         icmp_hun.ih_idseq.icd_id
175 #define icmp_seq        icmp_hun.ih_idseq.icd_seq
176 #define icmp_void       icmp_hun.ih_void
177 #define icmp_pmvoid     icmp_hun.ih_pmtu.ipm_void
178 #define icmp_nextmtu    icmp_hun.ih_pmtu.ipm_nextmtu
179 #define icmp_num_addrs  icmp_hun.ih_rtradv.irt_num_addrs
180 #define icmp_wpa        icmp_hun.ih_rtradv.irt_wpa
181 #define icmp_lifetime   icmp_hun.ih_rtradv.irt_lifetime
182   union
183   {
184     struct
185     {
186       u_int32_t its_otime;
187       u_int32_t its_rtime;
188       u_int32_t its_ttime;
189     } id_ts;
190     struct
191     {
192       struct ip idi_ip;
193       /* options and then 64 bits of data */
194     } id_ip;
195     struct icmp_ra_addr id_radv;
196     u_int32_t   id_mask;
197     u_int8_t    id_data[1];
198   } icmp_dun;
199 #define icmp_otime      icmp_dun.id_ts.its_otime
200 #define icmp_rtime      icmp_dun.id_ts.its_rtime
201 #define icmp_ttime      icmp_dun.id_ts.its_ttime
202 #define icmp_ip         icmp_dun.id_ip.idi_ip
203 #define icmp_radv       icmp_dun.id_radv
204 #define icmp_mask       icmp_dun.id_mask
205 #define icmp_data       icmp_dun.id_data
206 };
207
208 /*
209  * Lower bounds on packet lengths for various types.
210  * For the error advice packets must first insure that the
211  * packet is large enough to contain the returned ip header.
212  * Only then can we do the check to see if 64 bits of packet
213  * data have been returned, since we need to check the returned
214  * ip header length.
215  */
216 #define ICMP_MINLEN     8                               /* abs minimum */
217 #define ICMP_TSLEN      (8 + 3 * sizeof (n_time))       /* timestamp */
218 #define ICMP_MASKLEN    12                              /* address mask */
219 #define ICMP_ADVLENMIN  (8 + sizeof (struct ip) + 8)    /* min */
220 #ifndef _IP_VHL
221 #define ICMP_ADVLEN(p)  (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
222         /* N.B.: must separately check that ip_hl >= 5 */
223 #else
224 #define ICMP_ADVLEN(p)  (8 + (IP_VHL_HL((p)->icmp_ip.ip_vhl) << 2) + 8)
225         /* N.B.: must separately check that header length >= 5 */
226 #endif
227
228 /* Definition of type and code fields. */
229 /* defined above: ICMP_ECHOREPLY, ICMP_REDIRECT, ICMP_ECHO */
230 #define ICMP_UNREACH            3               /* dest unreachable, codes: */
231 #define ICMP_SOURCEQUENCH       4               /* packet lost, slow down */
232 #define ICMP_ROUTERADVERT       9               /* router advertisement */
233 #define ICMP_ROUTERSOLICIT      10              /* router solicitation */
234 #define ICMP_TIMXCEED           11              /* time exceeded, code: */
235 #define ICMP_PARAMPROB          12              /* ip header bad */
236 #define ICMP_TSTAMP             13              /* timestamp request */
237 #define ICMP_TSTAMPREPLY        14              /* timestamp reply */
238 #define ICMP_IREQ               15              /* information request */
239 #define ICMP_IREQREPLY          16              /* information reply */
240 #define ICMP_MASKREQ            17              /* address mask request */
241 #define ICMP_MASKREPLY          18              /* address mask reply */
242
243 #define ICMP_MAXTYPE            18
244
245 /* UNREACH codes */
246 #define ICMP_UNREACH_NET                0       /* bad net */
247 #define ICMP_UNREACH_HOST               1       /* bad host */
248 #define ICMP_UNREACH_PROTOCOL           2       /* bad protocol */
249 #define ICMP_UNREACH_PORT               3       /* bad port */
250 #define ICMP_UNREACH_NEEDFRAG           4       /* IP_DF caused drop */
251 #define ICMP_UNREACH_SRCFAIL            5       /* src route failed */
252 #define ICMP_UNREACH_NET_UNKNOWN        6       /* unknown net */
253 #define ICMP_UNREACH_HOST_UNKNOWN       7       /* unknown host */
254 #define ICMP_UNREACH_ISOLATED           8       /* src host isolated */
255 #define ICMP_UNREACH_NET_PROHIB         9       /* net denied */
256 #define ICMP_UNREACH_HOST_PROHIB        10      /* host denied */
257 #define ICMP_UNREACH_TOSNET             11      /* bad tos for net */
258 #define ICMP_UNREACH_TOSHOST            12      /* bad tos for host */
259 #define ICMP_UNREACH_FILTER_PROHIB      13      /* admin prohib */
260 #define ICMP_UNREACH_HOST_PRECEDENCE    14      /* host prec vio. */
261 #define ICMP_UNREACH_PRECEDENCE_CUTOFF  15      /* prec cutoff */
262
263 /* REDIRECT codes */
264 #define ICMP_REDIRECT_NET       0               /* for network */
265 #define ICMP_REDIRECT_HOST      1               /* for host */
266 #define ICMP_REDIRECT_TOSNET    2               /* for tos and net */
267 #define ICMP_REDIRECT_TOSHOST   3               /* for tos and host */
268
269 /* TIMEXCEED codes */
270 #define ICMP_TIMXCEED_INTRANS   0               /* ttl==0 in transit */
271 #define ICMP_TIMXCEED_REASS     1               /* ttl==0 in reass */
272
273 /* PARAMPROB code */
274 #define ICMP_PARAMPROB_OPTABSENT 1              /* req. opt. absent */
275
276 #define ICMP_INFOTYPE(type) \
277         ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
278         (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
279         (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
280         (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
281         (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
282
283 #endif /* __USE_BSD */
284
285 __END_DECLS
286
287 #endif /* netinet/ip_icmp.h */