Import tcpdump-3.9.8:
[dragonfly.git] / contrib / tcpdump-3.8.3 / icmp6.h
1 /* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.14 2002/12/11 07:13:52 guy Exp $ (LBL) */
2 /*      $NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp $        */
3 /*      $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $  */
4
5 /*
6  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. Neither the name of the project nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33
34 /*
35  * Copyright (c) 1982, 1986, 1993
36  *      The Regents of the University of California.  All rights reserved.
37  *
38  * Redistribution and use in source and binary forms, with or without
39  * modification, are permitted provided that the following conditions
40  * are met:
41  * 1. Redistributions of source code must retain the above copyright
42  *    notice, this list of conditions and the following disclaimer.
43  * 2. Redistributions in binary form must reproduce the above copyright
44  *    notice, this list of conditions and the following disclaimer in the
45  *    documentation and/or other materials provided with the distribution.
46  * 3. All advertising materials mentioning features or use of this software
47  *    must display the following acknowledgement:
48  *      This product includes software developed by the University of
49  *      California, Berkeley and its contributors.
50  * 4. Neither the name of the University nor the names of its contributors
51  *    may be used to endorse or promote products derived from this software
52  *    without specific prior written permission.
53  *
54  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64  * SUCH DAMAGE.
65  *
66  *      @(#)ip_icmp.h   8.1 (Berkeley) 6/10/93
67  */
68
69 #ifndef _NETINET_ICMP6_H_
70 #define _NETINET_ICMP6_H_
71
72 struct icmp6_hdr {
73         u_int8_t        icmp6_type;     /* type field */
74         u_int8_t        icmp6_code;     /* code field */
75         u_int16_t       icmp6_cksum;    /* checksum field */
76         union {
77                 u_int32_t       icmp6_un_data32[1]; /* type-specific field */
78                 u_int16_t       icmp6_un_data16[2]; /* type-specific field */
79                 u_int8_t        icmp6_un_data8[4];  /* type-specific field */
80         } icmp6_dataun;
81 };
82
83 #define icmp6_data32    icmp6_dataun.icmp6_un_data32
84 #define icmp6_data16    icmp6_dataun.icmp6_un_data16
85 #define icmp6_data8     icmp6_dataun.icmp6_un_data8
86 #define icmp6_pptr      icmp6_data32[0]         /* parameter prob */
87 #define icmp6_mtu       icmp6_data32[0]         /* packet too big */
88 #define icmp6_id        icmp6_data16[0]         /* echo request/reply */
89 #define icmp6_seq       icmp6_data16[1]         /* echo request/reply */
90 #define icmp6_maxdelay  icmp6_data16[0]         /* mcast group membership */
91
92 #define ICMP6_DST_UNREACH               1       /* dest unreachable, codes: */
93 #define ICMP6_PACKET_TOO_BIG            2       /* packet too big */
94 #define ICMP6_TIME_EXCEEDED             3       /* time exceeded, code: */
95 #define ICMP6_PARAM_PROB                4       /* ip6 header bad */
96
97 #define ICMP6_ECHO_REQUEST              128     /* echo service */
98 #define ICMP6_ECHO_REPLY                129     /* echo reply */
99 #define ICMP6_MEMBERSHIP_QUERY          130     /* group membership query */
100 #define MLD6_LISTENER_QUERY             130     /* multicast listener query */
101 #define ICMP6_MEMBERSHIP_REPORT         131     /* group membership report */
102 #define MLD6_LISTENER_REPORT            131     /* multicast listener report */
103 #define ICMP6_MEMBERSHIP_REDUCTION      132     /* group membership termination */
104 #define MLD6_LISTENER_DONE              132     /* multicast listener done */
105
106 #define ND_ROUTER_SOLICIT               133     /* router solicitation */
107 #define ND_ROUTER_ADVERT                134     /* router advertisment */
108 #define ND_NEIGHBOR_SOLICIT             135     /* neighbor solicitation */
109 #define ND_NEIGHBOR_ADVERT              136     /* neighbor advertisment */
110 #define ND_REDIRECT                     137     /* redirect */
111
112 #define ICMP6_ROUTER_RENUMBERING        138     /* router renumbering */
113
114 #define ICMP6_WRUREQUEST                139     /* who are you request */
115 #define ICMP6_WRUREPLY                  140     /* who are you reply */
116 #define ICMP6_FQDN_QUERY                139     /* FQDN query */
117 #define ICMP6_FQDN_REPLY                140     /* FQDN reply */
118 #define ICMP6_NI_QUERY                  139     /* node information request */
119 #define ICMP6_NI_REPLY                  140     /* node information reply */
120
121 /* The definitions below are experimental. TBA */
122 #define MLD6_MTRACE_RESP                141     /* mtrace response(to sender) */
123 #define MLD6_MTRACE                     142     /* mtrace messages */
124
125 /* Folloing numbers are defined in the mobile-ip draft. */
126 #define ICMP6_HADISCOV_REQUEST          150     /* XXX To be authorized */
127 #define ICMP6_HADISCOV_REPLY            151     /* XXX To be authorized */
128 #define ICMP6_MOBILEPREFIX_SOLICIT      152     /* XXX To be authorized */
129 #define ICMP6_MOBILEPREFIX_ADVERT       153     /* XXX To be authorized */
130
131 #define ICMP6_MAXTYPE                   153
132
133 #define ICMP6_DST_UNREACH_NOROUTE       0       /* no route to destination */
134 #define ICMP6_DST_UNREACH_ADMIN         1       /* administratively prohibited */
135 #define ICMP6_DST_UNREACH_NOTNEIGHBOR   2       /* not a neighbor(obsolete) */
136 #define ICMP6_DST_UNREACH_BEYONDSCOPE   2       /* beyond scope of source address */
137 #define ICMP6_DST_UNREACH_ADDR          3       /* address unreachable */
138 #define ICMP6_DST_UNREACH_NOPORT        4       /* port unreachable */
139
140 #define ICMP6_TIME_EXCEED_TRANSIT       0       /* ttl==0 in transit */
141 #define ICMP6_TIME_EXCEED_REASSEMBLY    1       /* ttl==0 in reass */
142
143 #define ICMP6_PARAMPROB_HEADER          0       /* erroneous header field */
144 #define ICMP6_PARAMPROB_NEXTHEADER      1       /* unrecognized next header */
145 #define ICMP6_PARAMPROB_OPTION          2       /* unrecognized option */
146
147 #define ICMP6_INFOMSG_MASK              0x80    /* all informational messages */
148
149 #define ICMP6_NI_SUBJ_IPV6      0       /* Query Subject is an IPv6 address */
150 #define ICMP6_NI_SUBJ_FQDN      1       /* Query Subject is a Domain name */
151 #define ICMP6_NI_SUBJ_IPV4      2       /* Query Subject is an IPv4 address */
152
153 #define ICMP6_NI_SUCCESS        0       /* node information successful reply */
154 #define ICMP6_NI_REFUSED        1       /* node information request is refused */
155 #define ICMP6_NI_UNKNOWN        2       /* unknown Qtype */
156
157 #define ICMP6_ROUTER_RENUMBERING_COMMAND  0     /* rr command */
158 #define ICMP6_ROUTER_RENUMBERING_RESULT   1     /* rr result */
159 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET   255     /* rr seq num reset */
160
161 /* Used in kernel only */
162 #define ND_REDIRECT_ONLINK      0       /* redirect to an on-link node */
163 #define ND_REDIRECT_ROUTER      1       /* redirect to a better router */
164
165 /*
166  * Multicast Listener Discovery
167  */
168 struct mld6_hdr {
169         struct icmp6_hdr        mld6_hdr;
170         struct in6_addr         mld6_addr; /* multicast address */
171 };
172
173 #define mld6_type       mld6_hdr.icmp6_type
174 #define mld6_code       mld6_hdr.icmp6_code
175 #define mld6_cksum      mld6_hdr.icmp6_cksum
176 #define mld6_maxdelay   mld6_hdr.icmp6_data16[0]
177 #define mld6_reserved   mld6_hdr.icmp6_data16[1]
178
179 /*
180  * Neighbor Discovery
181  */
182
183 struct nd_router_solicit {      /* router solicitation */
184         struct icmp6_hdr        nd_rs_hdr;
185         /* could be followed by options */
186 };
187
188 #define nd_rs_type      nd_rs_hdr.icmp6_type
189 #define nd_rs_code      nd_rs_hdr.icmp6_code
190 #define nd_rs_cksum     nd_rs_hdr.icmp6_cksum
191 #define nd_rs_reserved  nd_rs_hdr.icmp6_data32[0]
192
193 struct nd_router_advert {       /* router advertisement */
194         struct icmp6_hdr        nd_ra_hdr;
195         u_int32_t               nd_ra_reachable;        /* reachable time */
196         u_int32_t               nd_ra_retransmit;       /* retransmit timer */
197         /* could be followed by options */
198 };
199
200 #define nd_ra_type              nd_ra_hdr.icmp6_type
201 #define nd_ra_code              nd_ra_hdr.icmp6_code
202 #define nd_ra_cksum             nd_ra_hdr.icmp6_cksum
203 #define nd_ra_curhoplimit       nd_ra_hdr.icmp6_data8[0]
204 #define nd_ra_flags_reserved    nd_ra_hdr.icmp6_data8[1]
205 #define ND_RA_FLAG_MANAGED      0x80
206 #define ND_RA_FLAG_OTHER        0x40
207 #define ND_RA_FLAG_HOME_AGENT   0x20
208
209 /*
210  * Router preference values based on draft-draves-ipngwg-router-selection-01.
211  * These are non-standard definitions.
212  */
213 #define ND_RA_FLAG_RTPREF_MASK  0x18 /* 00011000 */
214
215 #define ND_RA_FLAG_RTPREF_HIGH  0x08 /* 00001000 */
216 #define ND_RA_FLAG_RTPREF_MEDIUM        0x00 /* 00000000 */
217 #define ND_RA_FLAG_RTPREF_LOW   0x18 /* 00011000 */
218 #define ND_RA_FLAG_RTPREF_RSV   0x10 /* 00010000 */
219
220 #define nd_ra_router_lifetime   nd_ra_hdr.icmp6_data16[1]
221
222 struct nd_neighbor_solicit {    /* neighbor solicitation */
223         struct icmp6_hdr        nd_ns_hdr;
224         struct in6_addr         nd_ns_target;   /*target address */
225         /* could be followed by options */
226 };
227
228 #define nd_ns_type              nd_ns_hdr.icmp6_type
229 #define nd_ns_code              nd_ns_hdr.icmp6_code
230 #define nd_ns_cksum             nd_ns_hdr.icmp6_cksum
231 #define nd_ns_reserved          nd_ns_hdr.icmp6_data32[0]
232
233 struct nd_neighbor_advert {     /* neighbor advertisement */
234         struct icmp6_hdr        nd_na_hdr;
235         struct in6_addr         nd_na_target;   /* target address */
236         /* could be followed by options */
237 };
238
239 #define nd_na_type              nd_na_hdr.icmp6_type
240 #define nd_na_code              nd_na_hdr.icmp6_code
241 #define nd_na_cksum             nd_na_hdr.icmp6_cksum
242 #define nd_na_flags_reserved    nd_na_hdr.icmp6_data32[0]
243 /* netowkr endian */
244 #define ND_NA_FLAG_ROUTER               ((u_int32_t)htonl(0x80000000))
245 #define ND_NA_FLAG_SOLICITED            ((u_int32_t)htonl(0x40000000))
246 #define ND_NA_FLAG_OVERRIDE             ((u_int32_t)htonl(0x20000000))
247
248 struct nd_redirect {            /* redirect */
249         struct icmp6_hdr        nd_rd_hdr;
250         struct in6_addr         nd_rd_target;   /* target address */
251         struct in6_addr         nd_rd_dst;      /* destination address */
252         /* could be followed by options */
253 };
254
255 #define nd_rd_type              nd_rd_hdr.icmp6_type
256 #define nd_rd_code              nd_rd_hdr.icmp6_code
257 #define nd_rd_cksum             nd_rd_hdr.icmp6_cksum
258 #define nd_rd_reserved          nd_rd_hdr.icmp6_data32[0]
259
260 struct nd_opt_hdr {             /* Neighbor discovery option header */
261         u_int8_t        nd_opt_type;
262         u_int8_t        nd_opt_len;
263         /* followed by option specific data*/
264 };
265
266 #define ND_OPT_SOURCE_LINKADDR          1
267 #define ND_OPT_TARGET_LINKADDR          2
268 #define ND_OPT_PREFIX_INFORMATION       3
269 #define ND_OPT_REDIRECTED_HEADER        4
270 #define ND_OPT_MTU                      5
271 #define ND_OPT_ADVINTERVAL              7
272 #define ND_OPT_HOMEAGENT_INFO           8
273 #define ND_OPT_ROUTE_INFO               9       /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
274
275
276 struct nd_opt_prefix_info {     /* prefix information */
277         u_int8_t        nd_opt_pi_type;
278         u_int8_t        nd_opt_pi_len;
279         u_int8_t        nd_opt_pi_prefix_len;
280         u_int8_t        nd_opt_pi_flags_reserved;
281         u_int32_t       nd_opt_pi_valid_time;
282         u_int32_t       nd_opt_pi_preferred_time;
283         u_int32_t       nd_opt_pi_reserved2;
284         struct in6_addr nd_opt_pi_prefix;
285 };
286
287 #define ND_OPT_PI_FLAG_ONLINK           0x80
288 #define ND_OPT_PI_FLAG_AUTO             0x40
289 #define ND_OPT_PI_FLAG_ROUTER           0x20    /*2292bis*/
290
291 struct nd_opt_rd_hdr {         /* redirected header */
292         u_int8_t        nd_opt_rh_type;
293         u_int8_t        nd_opt_rh_len;
294         u_int16_t       nd_opt_rh_reserved1;
295         u_int32_t       nd_opt_rh_reserved2;
296         /* followed by IP header and data */
297 };
298
299 struct nd_opt_mtu {             /* MTU option */
300         u_int8_t        nd_opt_mtu_type;
301         u_int8_t        nd_opt_mtu_len;
302         u_int16_t       nd_opt_mtu_reserved;
303         u_int32_t       nd_opt_mtu_mtu;
304 };
305
306 struct nd_opt_advinterval {     /* Advertisement interval option */
307         u_int8_t        nd_opt_adv_type;
308         u_int8_t        nd_opt_adv_len;
309         u_int16_t       nd_opt_adv_reserved;
310         u_int32_t       nd_opt_adv_interval;
311 };
312
313 struct nd_opt_homeagent_info {  /* Home Agent info */
314         u_int8_t        nd_opt_hai_type;
315         u_int8_t        nd_opt_hai_len;
316         u_int16_t       nd_opt_hai_reserved;
317         int16_t         nd_opt_hai_preference;
318         u_int16_t       nd_opt_hai_lifetime;
319 };
320
321 struct nd_opt_route_info {      /* route info */
322         u_int8_t        nd_opt_rti_type;
323         u_int8_t        nd_opt_rti_len;
324         u_int8_t        nd_opt_rti_prefixlen;
325         u_int8_t        nd_opt_rti_flags;
326         u_int32_t       nd_opt_rti_lifetime;
327         /* prefix follows */
328 };
329
330 /*
331  * icmp6 namelookup
332  */
333
334 struct icmp6_namelookup {
335         struct icmp6_hdr        icmp6_nl_hdr;
336         u_int8_t        icmp6_nl_nonce[8];
337         int32_t         icmp6_nl_ttl;
338 #if 0
339         u_int8_t        icmp6_nl_len;
340         u_int8_t        icmp6_nl_name[3];
341 #endif
342         /* could be followed by options */
343 };
344
345 /*
346  * icmp6 node information
347  */
348 struct icmp6_nodeinfo {
349         struct icmp6_hdr icmp6_ni_hdr;
350         u_int8_t icmp6_ni_nonce[8];
351         /* could be followed by reply data */
352 };
353
354 #define ni_type         icmp6_ni_hdr.icmp6_type
355 #define ni_code         icmp6_ni_hdr.icmp6_code
356 #define ni_cksum        icmp6_ni_hdr.icmp6_cksum
357 #define ni_qtype        icmp6_ni_hdr.icmp6_data16[0]
358 #define ni_flags        icmp6_ni_hdr.icmp6_data16[1]
359
360 #define NI_QTYPE_NOOP           0 /* NOOP  */
361 #define NI_QTYPE_SUPTYPES       1 /* Supported Qtypes */
362 #define NI_QTYPE_FQDN           2 /* FQDN (draft 04) */
363 #define NI_QTYPE_DNSNAME        2 /* DNS Name */
364 #define NI_QTYPE_NODEADDR       3 /* Node Addresses */
365 #define NI_QTYPE_IPV4ADDR       4 /* IPv4 Addresses */
366
367 /* network endian */
368 #define NI_SUPTYPE_FLAG_COMPRESS        ((u_int16_t)htons(0x1))
369 #define NI_FQDN_FLAG_VALIDTTL           ((u_int16_t)htons(0x1))
370
371 /* network endian */
372 #define NI_NODEADDR_FLAG_TRUNCATE       ((u_int16_t)htons(0x1))
373 #define NI_NODEADDR_FLAG_ALL            ((u_int16_t)htons(0x2))
374 #define NI_NODEADDR_FLAG_COMPAT         ((u_int16_t)htons(0x4))
375 #define NI_NODEADDR_FLAG_LINKLOCAL      ((u_int16_t)htons(0x8))
376 #define NI_NODEADDR_FLAG_SITELOCAL      ((u_int16_t)htons(0x10))
377 #define NI_NODEADDR_FLAG_GLOBAL         ((u_int16_t)htons(0x20))
378 #define NI_NODEADDR_FLAG_ANYCAST        ((u_int16_t)htons(0x40)) /* just experimental. not in spec */
379
380 struct ni_reply_fqdn {
381         u_int32_t ni_fqdn_ttl;  /* TTL */
382         u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
383         u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
384 };
385
386 /*
387  * Router Renumbering. as router-renum-08.txt
388  */
389 struct icmp6_router_renum {     /* router renumbering header */
390         struct icmp6_hdr        rr_hdr;
391         u_int8_t        rr_segnum;
392         u_int8_t        rr_flags;
393         u_int16_t       rr_maxdelay;
394         u_int32_t       rr_reserved;
395 };
396 #define ICMP6_RR_FLAGS_TEST             0x80
397 #define ICMP6_RR_FLAGS_REQRESULT        0x40
398 #define ICMP6_RR_FLAGS_FORCEAPPLY       0x20
399 #define ICMP6_RR_FLAGS_SPECSITE         0x10
400 #define ICMP6_RR_FLAGS_PREVDONE         0x08
401
402 #define rr_type         rr_hdr.icmp6_type
403 #define rr_code         rr_hdr.icmp6_code
404 #define rr_cksum        rr_hdr.icmp6_cksum
405 #define rr_seqnum       rr_hdr.icmp6_data32[0]
406
407 struct rr_pco_match {           /* match prefix part */
408         u_int8_t        rpm_code;
409         u_int8_t        rpm_len;
410         u_int8_t        rpm_ordinal;
411         u_int8_t        rpm_matchlen;
412         u_int8_t        rpm_minlen;
413         u_int8_t        rpm_maxlen;
414         u_int16_t       rpm_reserved;
415         struct  in6_addr        rpm_prefix;
416 };
417
418 #define RPM_PCO_ADD             1
419 #define RPM_PCO_CHANGE          2
420 #define RPM_PCO_SETGLOBAL       3
421 #define RPM_PCO_MAX             4
422
423 struct rr_pco_use {             /* use prefix part */
424         u_int8_t        rpu_uselen;
425         u_int8_t        rpu_keeplen;
426         u_int8_t        rpu_ramask;
427         u_int8_t        rpu_raflags;
428         u_int32_t       rpu_vltime;
429         u_int32_t       rpu_pltime;
430         u_int32_t       rpu_flags;
431         struct  in6_addr rpu_prefix;
432 };
433 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK  0x80
434 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO    0x40
435
436 /* network endian */
437 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME     ((u_int32_t)htonl(0x80000000))
438 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME     ((u_int32_t)htonl(0x40000000))
439
440 struct rr_result {              /* router renumbering result message */
441         u_int16_t       rrr_flags;
442         u_int8_t        rrr_ordinal;
443         u_int8_t        rrr_matchedlen;
444         u_int32_t       rrr_ifid;
445         struct  in6_addr rrr_prefix;
446 };
447 /* network endian */
448 #define ICMP6_RR_RESULT_FLAGS_OOB               ((u_int16_t)htons(0x0002))
449 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN         ((u_int16_t)htons(0x0001))
450
451 #endif /* not _NETINET_ICMP6_H_ */