]> git.saurik.com Git - apple/xnu.git/blame - bsd/netinet/icmp6.h
xnu-792.6.61.tar.gz
[apple/xnu.git] / bsd / netinet / icmp6.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
37839358
A
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
1c79356b 11 *
37839358
A
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
37839358
A
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
9bccf70c 22/* $KAME: icmp6.h,v 1.46 2001/04/27 15:09:48 itojun Exp $ */
1c79356b
A
23
24/*
25 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
26 * All rights reserved.
27 *
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
30 * are met:
31 * 1. Redistributions of source code must retain the above copyright
32 * notice, this list of conditions and the following disclaimer.
33 * 2. Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in the
35 * documentation and/or other materials provided with the distribution.
36 * 3. Neither the name of the project nor the names of its contributors
37 * may be used to endorse or promote products derived from this software
38 * without specific prior written permission.
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
41 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50 * SUCH DAMAGE.
51 */
52
53/*
54 * Copyright (c) 1982, 1986, 1993
55 * The Regents of the University of California. All rights reserved.
56 *
57 * Redistribution and use in source and binary forms, with or without
58 * modification, are permitted provided that the following conditions
59 * are met:
60 * 1. Redistributions of source code must retain the above copyright
61 * notice, this list of conditions and the following disclaimer.
62 * 2. Redistributions in binary form must reproduce the above copyright
63 * notice, this list of conditions and the following disclaimer in the
64 * documentation and/or other materials provided with the distribution.
65 * 3. All advertising materials mentioning features or use of this software
66 * must display the following acknowledgement:
67 * This product includes software developed by the University of
68 * California, Berkeley and its contributors.
69 * 4. Neither the name of the University nor the names of its contributors
70 * may be used to endorse or promote products derived from this software
71 * without specific prior written permission.
72 *
73 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
74 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
75 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
76 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
77 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
78 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
79 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
80 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
81 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
82 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
83 * SUCH DAMAGE.
84 *
85 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
86 */
87
88#ifndef _NETINET_ICMP6_H_
89#define _NETINET_ICMP6_H_
9bccf70c 90#include <sys/appleapiopts.h>
1c79356b
A
91
92#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
93 - sizeof(struct icmp6_hdr) */
94
95struct icmp6_hdr {
96 u_int8_t icmp6_type; /* type field */
97 u_int8_t icmp6_code; /* code field */
98 u_int16_t icmp6_cksum; /* checksum field */
99 union {
100 u_int32_t icmp6_un_data32[1]; /* type-specific field */
101 u_int16_t icmp6_un_data16[2]; /* type-specific field */
102 u_int8_t icmp6_un_data8[4]; /* type-specific field */
103 } icmp6_dataun;
104};
105
106#define icmp6_data32 icmp6_dataun.icmp6_un_data32
107#define icmp6_data16 icmp6_dataun.icmp6_un_data16
108#define icmp6_data8 icmp6_dataun.icmp6_un_data8
109#define icmp6_pptr icmp6_data32[0] /* parameter prob */
110#define icmp6_mtu icmp6_data32[0] /* packet too big */
111#define icmp6_id icmp6_data16[0] /* echo request/reply */
112#define icmp6_seq icmp6_data16[1] /* echo request/reply */
113#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
114
115#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
116#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
117#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
118#define ICMP6_PARAM_PROB 4 /* ip6 header bad */
119
120#define ICMP6_ECHO_REQUEST 128 /* echo service */
121#define ICMP6_ECHO_REPLY 129 /* echo reply */
122#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
123#define MLD6_LISTENER_QUERY 130 /* multicast listener query */
124#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
125#define MLD6_LISTENER_REPORT 131 /* multicast listener report */
126#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
127#define MLD6_LISTENER_DONE 132 /* multicast listener done */
128
129#define ND_ROUTER_SOLICIT 133 /* router solicitation */
130#define ND_ROUTER_ADVERT 134 /* router advertisment */
131#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
132#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */
133#define ND_REDIRECT 137 /* redirect */
134
135#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
136
137#define ICMP6_WRUREQUEST 139 /* who are you request */
138#define ICMP6_WRUREPLY 140 /* who are you reply */
139#define ICMP6_FQDN_QUERY 139 /* FQDN query */
140#define ICMP6_FQDN_REPLY 140 /* FQDN reply */
141#define ICMP6_NI_QUERY 139 /* node information request */
142#define ICMP6_NI_REPLY 140 /* node information reply */
143
144/* The definitions below are experimental. TBA */
9bccf70c
A
145#define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */
146#define MLD6_MTRACE 201 /* mtrace messages */
1c79356b 147
9bccf70c
A
148#define ICMP6_HADISCOV_REQUEST 202 /* XXX To be defined */
149#define ICMP6_HADISCOV_REPLY 203 /* XXX To be defined */
150
151#define ICMP6_MAXTYPE 203
1c79356b
A
152
153#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
154#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
155#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
156#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
157#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
158#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
159
160#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
161#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
162
163#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
164#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
165#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
166
167#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
168
9bccf70c
A
169#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
170#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
171#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
172
173#define ICMP6_NI_SUCCESS 0 /* node information successful reply */
1c79356b
A
174#define ICMP6_NI_REFUSED 1 /* node information request is refused */
175#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
176
177#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
178#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
179#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
180
181/* Used in kernel only */
182#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
183#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
184
185/*
186 * Multicast Listener Discovery
187 */
188struct mld6_hdr {
189 struct icmp6_hdr mld6_hdr;
190 struct in6_addr mld6_addr; /* multicast address */
191};
192
193#define mld6_type mld6_hdr.icmp6_type
194#define mld6_code mld6_hdr.icmp6_code
195#define mld6_cksum mld6_hdr.icmp6_cksum
196#define mld6_maxdelay mld6_hdr.icmp6_data16[0]
197#define mld6_reserved mld6_hdr.icmp6_data16[1]
198
199/*
200 * Neighbor Discovery
201 */
202
203struct nd_router_solicit { /* router solicitation */
204 struct icmp6_hdr nd_rs_hdr;
205 /* could be followed by options */
206};
207
208#define nd_rs_type nd_rs_hdr.icmp6_type
209#define nd_rs_code nd_rs_hdr.icmp6_code
210#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
211#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
212
213struct nd_router_advert { /* router advertisement */
214 struct icmp6_hdr nd_ra_hdr;
215 u_int32_t nd_ra_reachable; /* reachable time */
216 u_int32_t nd_ra_retransmit; /* retransmit timer */
217 /* could be followed by options */
218};
219
220#define nd_ra_type nd_ra_hdr.icmp6_type
221#define nd_ra_code nd_ra_hdr.icmp6_code
222#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
223#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
224#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
225#define ND_RA_FLAG_MANAGED 0x80
226#define ND_RA_FLAG_OTHER 0x40
227#define ND_RA_FLAG_HA 0x20
9bccf70c
A
228
229/*
230 * Router preference values based on draft-draves-ipngwg-router-selection-01.
231 * These are non-standard definitions.
232 */
233#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
234
235#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
236#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
237#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
238#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
239
1c79356b
A
240#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
241
242struct nd_neighbor_solicit { /* neighbor solicitation */
243 struct icmp6_hdr nd_ns_hdr;
244 struct in6_addr nd_ns_target; /*target address */
245 /* could be followed by options */
246};
247
248#define nd_ns_type nd_ns_hdr.icmp6_type
249#define nd_ns_code nd_ns_hdr.icmp6_code
250#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
251#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
252
253struct nd_neighbor_advert { /* neighbor advertisement */
254 struct icmp6_hdr nd_na_hdr;
255 struct in6_addr nd_na_target; /* target address */
256 /* could be followed by options */
257};
258
259#define nd_na_type nd_na_hdr.icmp6_type
260#define nd_na_code nd_na_hdr.icmp6_code
261#define nd_na_cksum nd_na_hdr.icmp6_cksum
262#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
263#if BYTE_ORDER == BIG_ENDIAN
264#define ND_NA_FLAG_ROUTER 0x80000000
265#define ND_NA_FLAG_SOLICITED 0x40000000
266#define ND_NA_FLAG_OVERRIDE 0x20000000
267#else
268#if BYTE_ORDER == LITTLE_ENDIAN
269#define ND_NA_FLAG_ROUTER 0x80
270#define ND_NA_FLAG_SOLICITED 0x40
271#define ND_NA_FLAG_OVERRIDE 0x20
272#endif
273#endif
274
275struct nd_redirect { /* redirect */
276 struct icmp6_hdr nd_rd_hdr;
277 struct in6_addr nd_rd_target; /* target address */
278 struct in6_addr nd_rd_dst; /* destination address */
279 /* could be followed by options */
280};
281
282#define nd_rd_type nd_rd_hdr.icmp6_type
283#define nd_rd_code nd_rd_hdr.icmp6_code
284#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
285#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
286
287struct nd_opt_hdr { /* Neighbor discovery option header */
288 u_int8_t nd_opt_type;
289 u_int8_t nd_opt_len;
290 /* followed by option specific data*/
291};
292
293#define ND_OPT_SOURCE_LINKADDR 1
294#define ND_OPT_TARGET_LINKADDR 2
295#define ND_OPT_PREFIX_INFORMATION 3
296#define ND_OPT_REDIRECTED_HEADER 4
297#define ND_OPT_MTU 5
9bccf70c
A
298
299#define ND_OPT_ROUTE_INFO 200 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
1c79356b
A
300
301struct nd_opt_prefix_info { /* prefix information */
302 u_int8_t nd_opt_pi_type;
303 u_int8_t nd_opt_pi_len;
304 u_int8_t nd_opt_pi_prefix_len;
305 u_int8_t nd_opt_pi_flags_reserved;
306 u_int32_t nd_opt_pi_valid_time;
307 u_int32_t nd_opt_pi_preferred_time;
308 u_int32_t nd_opt_pi_reserved2;
309 struct in6_addr nd_opt_pi_prefix;
310};
311
312#define ND_OPT_PI_FLAG_ONLINK 0x80
313#define ND_OPT_PI_FLAG_AUTO 0x40
1c79356b
A
314
315struct nd_opt_rd_hdr { /* redirected header */
316 u_int8_t nd_opt_rh_type;
317 u_int8_t nd_opt_rh_len;
318 u_int16_t nd_opt_rh_reserved1;
319 u_int32_t nd_opt_rh_reserved2;
320 /* followed by IP header and data */
321};
322
323struct nd_opt_mtu { /* MTU option */
324 u_int8_t nd_opt_mtu_type;
325 u_int8_t nd_opt_mtu_len;
326 u_int16_t nd_opt_mtu_reserved;
327 u_int32_t nd_opt_mtu_mtu;
328};
329
9bccf70c
A
330struct nd_opt_route_info { /* route info */
331 u_int8_t nd_opt_rti_type;
332 u_int8_t nd_opt_rti_len;
333 u_int8_t nd_opt_rti_prefixlen;
334 u_int8_t nd_opt_rti_flags;
335 u_int32_t nd_opt_rti_lifetime;
336 /* followed by prefix */
1c79356b
A
337};
338
339/*
340 * icmp6 namelookup
341 */
342
343struct icmp6_namelookup {
344 struct icmp6_hdr icmp6_nl_hdr;
345 u_int8_t icmp6_nl_nonce[8];
9bccf70c 346 int32_t icmp6_nl_ttl;
1c79356b
A
347#if 0
348 u_int8_t icmp6_nl_len;
349 u_int8_t icmp6_nl_name[3];
350#endif
351 /* could be followed by options */
352};
353
354/*
355 * icmp6 node information
356 */
357struct icmp6_nodeinfo {
358 struct icmp6_hdr icmp6_ni_hdr;
359 u_int8_t icmp6_ni_nonce[8];
360 /* could be followed by reply data */
361};
362
363#define ni_type icmp6_ni_hdr.icmp6_type
364#define ni_code icmp6_ni_hdr.icmp6_code
365#define ni_cksum icmp6_ni_hdr.icmp6_cksum
366#define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
367#define ni_flags icmp6_ni_hdr.icmp6_data16[1]
368
1c79356b
A
369#define NI_QTYPE_NOOP 0 /* NOOP */
370#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
9bccf70c
A
371#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
372#define NI_QTYPE_DNSNAME 2 /* DNS Name */
373#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
374#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
1c79356b
A
375
376#if BYTE_ORDER == BIG_ENDIAN
377#define NI_SUPTYPE_FLAG_COMPRESS 0x1
378#define NI_FQDN_FLAG_VALIDTTL 0x1
379#elif BYTE_ORDER == LITTLE_ENDIAN
380#define NI_SUPTYPE_FLAG_COMPRESS 0x0100
381#define NI_FQDN_FLAG_VALIDTTL 0x0100
382#endif
383
384#ifdef NAME_LOOKUPS_04
385#if BYTE_ORDER == BIG_ENDIAN
386#define NI_NODEADDR_FLAG_LINKLOCAL 0x1
387#define NI_NODEADDR_FLAG_SITELOCAL 0x2
388#define NI_NODEADDR_FLAG_GLOBAL 0x4
389#define NI_NODEADDR_FLAG_ALL 0x8
390#define NI_NODEADDR_FLAG_TRUNCATE 0x10
391#define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
392#elif BYTE_ORDER == LITTLE_ENDIAN
393#define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
394#define NI_NODEADDR_FLAG_SITELOCAL 0x0200
395#define NI_NODEADDR_FLAG_GLOBAL 0x0400
396#define NI_NODEADDR_FLAG_ALL 0x0800
397#define NI_NODEADDR_FLAG_TRUNCATE 0x1000
398#define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
399#endif
400#else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
401#if BYTE_ORDER == BIG_ENDIAN
402#define NI_NODEADDR_FLAG_TRUNCATE 0x1
403#define NI_NODEADDR_FLAG_ALL 0x2
404#define NI_NODEADDR_FLAG_COMPAT 0x4
405#define NI_NODEADDR_FLAG_LINKLOCAL 0x8
406#define NI_NODEADDR_FLAG_SITELOCAL 0x10
407#define NI_NODEADDR_FLAG_GLOBAL 0x20
408#define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
409#elif BYTE_ORDER == LITTLE_ENDIAN
410#define NI_NODEADDR_FLAG_TRUNCATE 0x0100
411#define NI_NODEADDR_FLAG_ALL 0x0200
412#define NI_NODEADDR_FLAG_COMPAT 0x0400
413#define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
414#define NI_NODEADDR_FLAG_SITELOCAL 0x1000
415#define NI_NODEADDR_FLAG_GLOBAL 0x2000
416#define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
417#endif
418#endif
419
420struct ni_reply_fqdn {
421 u_int32_t ni_fqdn_ttl; /* TTL */
422 u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
423 u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
424};
425
426/*
427 * Router Renumbering. as router-renum-08.txt
428 */
1c79356b
A
429struct icmp6_router_renum { /* router renumbering header */
430 struct icmp6_hdr rr_hdr;
9bccf70c
A
431 u_int8_t rr_segnum;
432 u_int8_t rr_flags;
433 u_int16_t rr_maxdelay;
434 u_int32_t rr_reserved;
1c79356b 435};
1c79356b 436
9bccf70c
A
437#define ICMP6_RR_FLAGS_TEST 0x80
438#define ICMP6_RR_FLAGS_REQRESULT 0x40
439#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
440#define ICMP6_RR_FLAGS_SPECSITE 0x10
441#define ICMP6_RR_FLAGS_PREVDONE 0x08
442
443#define rr_type rr_hdr.icmp6_type
444#define rr_code rr_hdr.icmp6_code
445#define rr_cksum rr_hdr.icmp6_cksum
446#define rr_seqnum rr_hdr.icmp6_data32[0]
1c79356b
A
447
448struct rr_pco_match { /* match prefix part */
449 u_int8_t rpm_code;
450 u_int8_t rpm_len;
451 u_int8_t rpm_ordinal;
452 u_int8_t rpm_matchlen;
453 u_int8_t rpm_minlen;
454 u_int8_t rpm_maxlen;
455 u_int16_t rpm_reserved;
9bccf70c 456 struct in6_addr rpm_prefix;
1c79356b
A
457};
458
459#define RPM_PCO_ADD 1
460#define RPM_PCO_CHANGE 2
461#define RPM_PCO_SETGLOBAL 3
462#define RPM_PCO_MAX 4
463
1c79356b
A
464struct rr_pco_use { /* use prefix part */
465 u_int8_t rpu_uselen;
466 u_int8_t rpu_keeplen;
9bccf70c
A
467 u_int8_t rpu_ramask;
468 u_int8_t rpu_raflags;
1c79356b
A
469 u_int32_t rpu_vltime;
470 u_int32_t rpu_pltime;
9bccf70c
A
471 u_int32_t rpu_flags;
472 struct in6_addr rpu_prefix;
1c79356b 473};
9bccf70c
A
474#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
475#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
476
477#if BYTE_ORDER == BIG_ENDIAN
478#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
479#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
1c79356b 480#elif BYTE_ORDER == LITTLE_ENDIAN
9bccf70c
A
481#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
482#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
483#endif
1c79356b 484
1c79356b 485struct rr_result { /* router renumbering result message */
9bccf70c 486 u_int16_t rrr_flags;
1c79356b
A
487 u_int8_t rrr_ordinal;
488 u_int8_t rrr_matchedlen;
489 u_int32_t rrr_ifid;
9bccf70c 490 struct in6_addr rrr_prefix;
1c79356b 491};
9bccf70c
A
492#if BYTE_ORDER == BIG_ENDIAN
493#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
494#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
1c79356b 495#elif BYTE_ORDER == LITTLE_ENDIAN
9bccf70c
A
496#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
497#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
498#endif
1c79356b
A
499
500/*
501 * icmp6 filter structures.
502 */
503
504struct icmp6_filter {
505 u_int32_t icmp6_filt[8];
506};
507
508#ifdef KERNEL
509#define ICMP6_FILTER_SETPASSALL(filterp) \
510do { \
511 int i; u_char *p; \
512 p = (u_char *)filterp; \
513 for (i = 0; i < sizeof(struct icmp6_filter); i++) \
514 p[i] = 0xff; \
515} while (0)
516#define ICMP6_FILTER_SETBLOCKALL(filterp) \
517 bzero(filterp, sizeof(struct icmp6_filter))
518#else /* KERNEL */
519#define ICMP6_FILTER_SETPASSALL(filterp) \
520 memset(filterp, 0xff, sizeof(struct icmp6_filter))
521#define ICMP6_FILTER_SETBLOCKALL(filterp) \
522 memset(filterp, 0x00, sizeof(struct icmp6_filter))
523#endif /* KERNEL */
524
525#define ICMP6_FILTER_SETPASS(type, filterp) \
526 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
527#define ICMP6_FILTER_SETBLOCK(type, filterp) \
528 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
529#define ICMP6_FILTER_WILLPASS(type, filterp) \
530 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
531#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
532 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
533
534/*
535 * Variables related to this implementation
536 * of the internet control message protocol version 6.
537 */
9bccf70c
A
538struct icmp6errstat {
539 u_quad_t icp6errs_dst_unreach_noroute;
540 u_quad_t icp6errs_dst_unreach_admin;
541 u_quad_t icp6errs_dst_unreach_beyondscope;
542 u_quad_t icp6errs_dst_unreach_addr;
543 u_quad_t icp6errs_dst_unreach_noport;
544 u_quad_t icp6errs_packet_too_big;
545 u_quad_t icp6errs_time_exceed_transit;
546 u_quad_t icp6errs_time_exceed_reassembly;
547 u_quad_t icp6errs_paramprob_header;
548 u_quad_t icp6errs_paramprob_nextheader;
549 u_quad_t icp6errs_paramprob_option;
550 u_quad_t icp6errs_redirect; /* we regard redirect as an error here */
551 u_quad_t icp6errs_unknown;
552};
553
1c79356b
A
554struct icmp6stat {
555/* statistics related to icmp6 packets generated */
556 u_quad_t icp6s_error; /* # of calls to icmp6_error */
557 u_quad_t icp6s_canterror; /* no error 'cuz old was icmp */
558 u_quad_t icp6s_toofreq; /* no error 'cuz rate limitation */
559 u_quad_t icp6s_outhist[256];
560/* statistics related to input message processed */
561 u_quad_t icp6s_badcode; /* icmp6_code out of range */
562 u_quad_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */
563 u_quad_t icp6s_checksum; /* bad checksum */
564 u_quad_t icp6s_badlen; /* calculated bound mismatch */
565 u_quad_t icp6s_reflect; /* number of responses */
566 u_quad_t icp6s_inhist[256];
567 u_quad_t icp6s_nd_toomanyopt; /* too many ND options */
9bccf70c
A
568 struct icmp6errstat icp6s_outerrhist;
569#define icp6s_odst_unreach_noroute \
570 icp6s_outerrhist.icp6errs_dst_unreach_noroute
571#define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin
572#define icp6s_odst_unreach_beyondscope \
573 icp6s_outerrhist.icp6errs_dst_unreach_beyondscope
574#define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr
575#define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport
576#define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big
577#define icp6s_otime_exceed_transit \
578 icp6s_outerrhist.icp6errs_time_exceed_transit
579#define icp6s_otime_exceed_reassembly \
580 icp6s_outerrhist.icp6errs_time_exceed_reassembly
581#define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header
582#define icp6s_oparamprob_nextheader \
583 icp6s_outerrhist.icp6errs_paramprob_nextheader
584#define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option
585#define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect
586#define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown
587 u_quad_t icp6s_pmtuchg; /* path MTU changes */
588 u_quad_t icp6s_nd_badopt; /* bad ND options */
589 u_quad_t icp6s_badns; /* bad neighbor solicitation */
590 u_quad_t icp6s_badna; /* bad neighbor advertisement */
591 u_quad_t icp6s_badrs; /* bad router advertisement */
592 u_quad_t icp6s_badra; /* bad router advertisement */
593 u_quad_t icp6s_badredirect; /* bad redirect message */
1c79356b
A
594};
595
596/*
597 * Names for ICMP sysctl objects
598 */
599#define ICMPV6CTL_STATS 1
600#define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
601#define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
1c79356b
A
602#define ICMPV6CTL_ND6_PRUNE 6
603#define ICMPV6CTL_ND6_DELAY 8
604#define ICMPV6CTL_ND6_UMAXTRIES 9
605#define ICMPV6CTL_ND6_MMAXTRIES 10
606#define ICMPV6CTL_ND6_USELOOPBACK 11
607/*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
608#define ICMPV6CTL_NODEINFO 13
9bccf70c
A
609#define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */
610#define ICMPV6CTL_ND6_MAXNUDHINT 15
611#define ICMPV6CTL_MTUDISC_HIWAT 16
612#define ICMPV6CTL_MTUDISC_LOWAT 17
613#define ICMPV6CTL_ND6_DEBUG 18
614#define ICMPV6CTL_ND6_DRLIST 19
615#define ICMPV6CTL_ND6_PRLIST 20
616#define ICMPV6CTL_MAXID 21
1c79356b 617
91447636 618#ifdef KERNEL_PRIVATE
1c79356b
A
619#define ICMPV6CTL_NAMES { \
620 { 0, 0 }, \
621 { 0, 0 }, \
622 { "rediraccept", CTLTYPE_INT }, \
623 { "redirtimeout", CTLTYPE_INT }, \
624 { 0, 0 }, \
9bccf70c 625 { 0, 0 }, \
1c79356b
A
626 { "nd6_prune", CTLTYPE_INT }, \
627 { 0, 0 }, \
628 { "nd6_delay", CTLTYPE_INT }, \
629 { "nd6_umaxtries", CTLTYPE_INT }, \
630 { "nd6_mmaxtries", CTLTYPE_INT }, \
631 { "nd6_useloopback", CTLTYPE_INT }, \
632 { 0, 0 }, \
633 { "nodeinfo", CTLTYPE_INT }, \
9bccf70c
A
634 { "errppslimit", CTLTYPE_INT }, \
635 { "nd6_maxnudhint", CTLTYPE_INT }, \
636 { "mtudisc_hiwat", CTLTYPE_INT }, \
637 { "mtudisc_lowat", CTLTYPE_INT }, \
638 { "nd6_debug", CTLTYPE_INT }, \
639 { 0, 0 }, \
640 { 0, 0 }, \
1c79356b 641}
1c79356b
A
642
643#define RTF_PROBEMTU RTF_PROTO1
644
1c79356b
A
645# ifdef __STDC__
646struct rtentry;
647struct rttimer;
648struct in6_multi;
649# endif
91447636
A
650void icmp6_init(void);
651void icmp6_paramerror(struct mbuf *, int);
652void icmp6_error(struct mbuf *, int, int, int);
653int icmp6_input(struct mbuf **, int *);
654void icmp6_fasttimo(void);
655void icmp6_reflect(struct mbuf *, size_t);
656void icmp6_prepare(struct mbuf *);
657void icmp6_redirect_input(struct mbuf *, int);
658void icmp6_redirect_output(struct mbuf *, struct rtentry *);
9bccf70c
A
659
660struct ip6ctlparam;
91447636 661void icmp6_mtudisc_update(struct ip6ctlparam *, int);
1c79356b
A
662
663/* XXX: is this the right place for these macros? */
664#define icmp6_ifstat_inc(ifp, tag) \
665do { \
666 if ((ifp) && (ifp)->if_index <= if_index \
667 && (ifp)->if_index < icmp6_ifstatmax \
668 && icmp6_ifstat && icmp6_ifstat[(ifp)->if_index]) { \
669 icmp6_ifstat[(ifp)->if_index]->tag++; \
670 } \
671} while (0)
672
673#define icmp6_ifoutstat_inc(ifp, type, code) \
674do { \
675 icmp6_ifstat_inc(ifp, ifs6_out_msg); \
676 if (type < ICMP6_INFOMSG_MASK) \
677 icmp6_ifstat_inc(ifp, ifs6_out_error); \
678 switch(type) { \
679 case ICMP6_DST_UNREACH: \
680 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \
681 if (code == ICMP6_DST_UNREACH_ADMIN) \
682 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \
683 break; \
684 case ICMP6_PACKET_TOO_BIG: \
685 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \
686 break; \
687 case ICMP6_TIME_EXCEEDED: \
688 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \
689 break; \
690 case ICMP6_PARAM_PROB: \
691 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \
692 break; \
693 case ICMP6_ECHO_REQUEST: \
694 icmp6_ifstat_inc(ifp, ifs6_out_echo); \
695 break; \
696 case ICMP6_ECHO_REPLY: \
697 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \
698 break; \
699 case MLD6_LISTENER_QUERY: \
700 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \
701 break; \
702 case MLD6_LISTENER_REPORT: \
703 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \
704 break; \
705 case MLD6_LISTENER_DONE: \
706 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \
707 break; \
708 case ND_ROUTER_SOLICIT: \
709 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \
710 break; \
711 case ND_ROUTER_ADVERT: \
712 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \
713 break; \
714 case ND_NEIGHBOR_SOLICIT: \
715 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \
716 break; \
717 case ND_NEIGHBOR_ADVERT: \
718 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \
719 break; \
720 case ND_REDIRECT: \
721 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \
722 break; \
723 } \
724} while (0)
725
726extern int icmp6_rediraccept; /* accept/process redirects */
727extern int icmp6_redirtimeout; /* cache time for redirect routes */
91447636 728#endif KERNEL_PRIVATE
1c79356b
A
729
730#endif /* !_NETINET_ICMP6_H_ */