Line data Source code
1 : /* $OpenBSD: icmp6.h,v 1.47 2017/08/08 18:15:58 florian Exp $ */
2 : /* $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $ */
3 :
4 : /*
5 : * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 : * All rights reserved.
7 : *
8 : * Redistribution and use in source and binary forms, with or without
9 : * modification, are permitted provided that the following conditions
10 : * are met:
11 : * 1. Redistributions of source code must retain the above copyright
12 : * notice, this list of conditions and the following disclaimer.
13 : * 2. Redistributions in binary form must reproduce the above copyright
14 : * notice, this list of conditions and the following disclaimer in the
15 : * documentation and/or other materials provided with the distribution.
16 : * 3. Neither the name of the project nor the names of its contributors
17 : * may be used to endorse or promote products derived from this software
18 : * without specific prior written permission.
19 : *
20 : * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 : * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 : * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 : * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 : * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 : * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 : * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 : * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 : * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 : * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 : * SUCH DAMAGE.
31 : */
32 :
33 : /*
34 : * Copyright (c) 1982, 1986, 1993
35 : * The Regents of the University of California. All rights reserved.
36 : *
37 : * Redistribution and use in source and binary forms, with or without
38 : * modification, are permitted provided that the following conditions
39 : * are met:
40 : * 1. Redistributions of source code must retain the above copyright
41 : * notice, this list of conditions and the following disclaimer.
42 : * 2. Redistributions in binary form must reproduce the above copyright
43 : * notice, this list of conditions and the following disclaimer in the
44 : * documentation and/or other materials provided with the distribution.
45 : * 3. Neither the name of the University nor the names of its contributors
46 : * may be used to endorse or promote products derived from this software
47 : * without specific prior written permission.
48 : *
49 : * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
50 : * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
51 : * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52 : * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53 : * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 : * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 : * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 : * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 : * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 : * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 : * SUCH DAMAGE.
60 : *
61 : * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
62 : */
63 :
64 : #ifndef _NETINET_ICMP6_H_
65 : #define _NETINET_ICMP6_H_
66 :
67 : #define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
68 : - sizeof(struct icmp6_hdr) */
69 :
70 : struct icmp6_hdr {
71 : u_int8_t icmp6_type; /* type field */
72 : u_int8_t icmp6_code; /* code field */
73 : u_int16_t icmp6_cksum; /* checksum field */
74 : union {
75 : u_int32_t icmp6_un_data32[1]; /* type-specific field */
76 : u_int16_t icmp6_un_data16[2]; /* type-specific field */
77 : u_int8_t icmp6_un_data8[4]; /* type-specific field */
78 : } icmp6_dataun;
79 : } __packed;
80 :
81 : #define icmp6_data32 icmp6_dataun.icmp6_un_data32
82 : #define icmp6_data16 icmp6_dataun.icmp6_un_data16
83 : #define icmp6_data8 icmp6_dataun.icmp6_un_data8
84 : #define icmp6_pptr icmp6_data32[0] /* parameter prob */
85 : #define icmp6_mtu icmp6_data32[0] /* packet too big */
86 : #define icmp6_id icmp6_data16[0] /* echo request/reply */
87 : #define icmp6_seq icmp6_data16[1] /* echo request/reply */
88 : #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
89 :
90 : #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
91 : #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
92 : #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
93 : #define ICMP6_PARAM_PROB 4 /* ip6 header bad */
94 :
95 : #define ICMP6_ECHO_REQUEST 128 /* echo service */
96 : #define ICMP6_ECHO_REPLY 129 /* echo reply */
97 : #define MLD_LISTENER_QUERY 130 /* multicast listener query */
98 : #define MLD_LISTENER_REPORT 131 /* multicast listener report */
99 : #define MLD_LISTENER_DONE 132 /* multicast listener done */
100 :
101 : /* RFC2292 decls */
102 : #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
103 : #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
104 : #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
105 :
106 : #define ND_ROUTER_SOLICIT 133 /* router solicitation */
107 : #define ND_ROUTER_ADVERT 134 /* router advertisement */
108 : #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
109 : #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
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 : #define MLDV2_LISTENER_REPORT 143 /* RFC3810 listener report */
121 :
122 : /* The definitions below are experimental. TBA */
123 : #define MLD_MTRACE_RESP 200 /* mtrace response(to sender) */
124 : #define MLD_MTRACE 201 /* mtrace messages */
125 :
126 : #define ICMP6_MAXTYPE 201
127 :
128 : #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
129 : #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
130 : #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
131 : #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
132 : #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
133 :
134 : #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
135 : #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
136 :
137 : #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
138 : #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
139 : #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
140 :
141 : #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
142 :
143 : #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
144 : #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
145 : #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
146 :
147 : #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
148 : #define ICMP6_NI_REFUSED 1 /* node information request is refused */
149 : #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
150 :
151 : #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
152 : #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
153 : #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
154 :
155 : /* Used in kernel only */
156 : #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
157 : #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
158 :
159 : /*
160 : * Multicast Listener Discovery
161 : */
162 : struct mld_hdr {
163 : struct icmp6_hdr mld_icmp6_hdr;
164 : struct in6_addr mld_addr; /* multicast address */
165 : } __packed;
166 :
167 : /* shortcut macro definitions */
168 : #define mld_type mld_icmp6_hdr.icmp6_type
169 : #define mld_code mld_icmp6_hdr.icmp6_code
170 : #define mld_cksum mld_icmp6_hdr.icmp6_cksum
171 : #define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
172 : #define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
173 :
174 : /*
175 : * Neighbor Discovery
176 : */
177 :
178 : struct nd_router_solicit { /* router solicitation */
179 : struct icmp6_hdr nd_rs_hdr;
180 : /* could be followed by options */
181 : } __packed;
182 :
183 : #define nd_rs_type nd_rs_hdr.icmp6_type
184 : #define nd_rs_code nd_rs_hdr.icmp6_code
185 : #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
186 : #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
187 :
188 : struct nd_router_advert { /* router advertisement */
189 : struct icmp6_hdr nd_ra_hdr;
190 : u_int32_t nd_ra_reachable; /* reachable time */
191 : u_int32_t nd_ra_retransmit; /* retransmit timer */
192 : /* could be followed by options */
193 : } __packed;
194 :
195 : #define nd_ra_type nd_ra_hdr.icmp6_type
196 : #define nd_ra_code nd_ra_hdr.icmp6_code
197 : #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
198 : #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
199 : #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
200 : #define ND_RA_FLAG_MANAGED 0x80
201 : #define ND_RA_FLAG_OTHER 0x40
202 :
203 : #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
204 :
205 : #define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
206 : #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
207 : #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
208 : #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
209 :
210 : #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
211 :
212 : struct nd_neighbor_solicit { /* neighbor solicitation */
213 : struct icmp6_hdr nd_ns_hdr;
214 : struct in6_addr nd_ns_target; /*target address */
215 : /* could be followed by options */
216 : } __packed;
217 :
218 : #define nd_ns_type nd_ns_hdr.icmp6_type
219 : #define nd_ns_code nd_ns_hdr.icmp6_code
220 : #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
221 : #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
222 :
223 : struct nd_neighbor_advert { /* neighbor advertisement */
224 : struct icmp6_hdr nd_na_hdr;
225 : struct in6_addr nd_na_target; /* target address */
226 : /* could be followed by options */
227 : } __packed;
228 :
229 : #define nd_na_type nd_na_hdr.icmp6_type
230 : #define nd_na_code nd_na_hdr.icmp6_code
231 : #define nd_na_cksum nd_na_hdr.icmp6_cksum
232 : #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
233 : #define ND_NA_FLAG_ROUTER htonl(0x80000000)
234 : #define ND_NA_FLAG_SOLICITED htonl(0x40000000)
235 : #define ND_NA_FLAG_OVERRIDE htonl(0x20000000)
236 :
237 : struct nd_redirect { /* redirect */
238 : struct icmp6_hdr nd_rd_hdr;
239 : struct in6_addr nd_rd_target; /* target address */
240 : struct in6_addr nd_rd_dst; /* destination address */
241 : /* could be followed by options */
242 : } __packed;
243 :
244 : #define nd_rd_type nd_rd_hdr.icmp6_type
245 : #define nd_rd_code nd_rd_hdr.icmp6_code
246 : #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
247 : #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
248 :
249 : struct nd_opt_hdr { /* Neighbor discovery option header */
250 : u_int8_t nd_opt_type;
251 : u_int8_t nd_opt_len;
252 : /* followed by option specific data*/
253 : } __packed;
254 :
255 : #define ND_OPT_SOURCE_LINKADDR 1
256 : #define ND_OPT_TARGET_LINKADDR 2
257 : #define ND_OPT_PREFIX_INFORMATION 3
258 : #define ND_OPT_REDIRECTED_HEADER 4
259 : #define ND_OPT_MTU 5
260 : #define ND_OPT_ROUTE_INFO 24
261 : #define ND_OPT_RDNSS 25
262 : #define ND_OPT_DNSSL 31
263 :
264 : struct nd_opt_prefix_info { /* prefix information */
265 : u_int8_t nd_opt_pi_type;
266 : u_int8_t nd_opt_pi_len;
267 : u_int8_t nd_opt_pi_prefix_len;
268 : u_int8_t nd_opt_pi_flags_reserved;
269 : u_int32_t nd_opt_pi_valid_time;
270 : u_int32_t nd_opt_pi_preferred_time;
271 : u_int32_t nd_opt_pi_reserved2;
272 : struct in6_addr nd_opt_pi_prefix;
273 : } __packed;
274 :
275 : #define ND_OPT_PI_FLAG_ONLINK 0x80
276 : #define ND_OPT_PI_FLAG_AUTO 0x40
277 :
278 : struct nd_opt_rd_hdr { /* redirected header */
279 : u_int8_t nd_opt_rh_type;
280 : u_int8_t nd_opt_rh_len;
281 : u_int16_t nd_opt_rh_reserved1;
282 : u_int32_t nd_opt_rh_reserved2;
283 : /* followed by IP header and data */
284 : } __packed;
285 :
286 : struct nd_opt_mtu { /* MTU option */
287 : u_int8_t nd_opt_mtu_type;
288 : u_int8_t nd_opt_mtu_len;
289 : u_int16_t nd_opt_mtu_reserved;
290 : u_int32_t nd_opt_mtu_mtu;
291 : } __packed;
292 :
293 : struct nd_opt_route_info { /* route info */
294 : u_int8_t nd_opt_rti_type;
295 : u_int8_t nd_opt_rti_len;
296 : u_int8_t nd_opt_rti_prefixlen;
297 : u_int8_t nd_opt_rti_flags;
298 : u_int32_t nd_opt_rti_lifetime;
299 : } __packed;
300 :
301 : struct nd_opt_rdnss { /* RDNSS option */
302 : u_int8_t nd_opt_rdnss_type;
303 : u_int8_t nd_opt_rdnss_len;
304 : u_int16_t nd_opt_rdnss_reserved;
305 : u_int32_t nd_opt_rdnss_lifetime;
306 : /* followed by list of recursive DNS servers */
307 : } __packed;
308 :
309 : struct nd_opt_dnssl { /* DNSSL option */
310 : u_int8_t nd_opt_dnssl_type;
311 : u_int8_t nd_opt_dnssl_len;
312 : u_int16_t nd_opt_dnssl_reserved;
313 : u_int32_t nd_opt_dnssl_lifetime;
314 : /* followed by list of DNS search domains */
315 : } __packed;
316 :
317 : /*
318 : * icmp6 namelookup
319 : */
320 : struct icmp6_namelookup {
321 : struct icmp6_hdr icmp6_nl_hdr;
322 : u_int8_t icmp6_nl_nonce[8];
323 : int32_t icmp6_nl_ttl;
324 : #if 0
325 : u_int8_t icmp6_nl_len;
326 : u_int8_t icmp6_nl_name[3];
327 : #endif
328 : /* could be followed by options */
329 : } __packed;
330 :
331 : /*
332 : * icmp6 node information
333 : */
334 : struct icmp6_nodeinfo {
335 : struct icmp6_hdr icmp6_ni_hdr;
336 : u_int8_t icmp6_ni_nonce[8];
337 : /* could be followed by reply data */
338 : } __packed;
339 :
340 : #define ni_type icmp6_ni_hdr.icmp6_type
341 : #define ni_code icmp6_ni_hdr.icmp6_code
342 : #define ni_cksum icmp6_ni_hdr.icmp6_cksum
343 : #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
344 : #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
345 :
346 : #define NI_QTYPE_NOOP 0 /* NOOP */
347 : #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
348 : #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
349 : #define NI_QTYPE_DNSNAME 2 /* DNS Name */
350 : #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
351 : #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
352 :
353 : #define NI_SUPTYPE_FLAG_COMPRESS htons(0x0001)
354 : #define NI_FQDN_FLAG_VALIDTTL htons(0x0001)
355 :
356 : #define NI_NODEADDR_FLAG_TRUNCATE htons(0x0001)
357 : #define NI_NODEADDR_FLAG_ALL htons(0x0002)
358 : #define NI_NODEADDR_FLAG_COMPAT htons(0x0004)
359 : #define NI_NODEADDR_FLAG_LINKLOCAL htons(0x0008)
360 : #define NI_NODEADDR_FLAG_SITELOCAL htons(0x0010)
361 : #define NI_NODEADDR_FLAG_GLOBAL htons(0x0020)
362 : #define NI_NODEADDR_FLAG_ANYCAST htons(0x0040) /* not in spec */
363 :
364 : struct ni_reply_fqdn {
365 : u_int32_t ni_fqdn_ttl; /* TTL */
366 : u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
367 : u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
368 : } __packed;
369 :
370 : /*
371 : * Router Renumbering. as router-renum-08.txt
372 : */
373 : struct icmp6_router_renum { /* router renumbering header */
374 : struct icmp6_hdr rr_hdr;
375 : u_int8_t rr_segnum;
376 : u_int8_t rr_flags;
377 : u_int16_t rr_maxdelay;
378 : u_int32_t rr_reserved;
379 : } __packed;
380 :
381 : #define ICMP6_RR_FLAGS_TEST 0x80
382 : #define ICMP6_RR_FLAGS_REQRESULT 0x40
383 : #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
384 : #define ICMP6_RR_FLAGS_SPECSITE 0x10
385 : #define ICMP6_RR_FLAGS_PREVDONE 0x08
386 :
387 : #define rr_type rr_hdr.icmp6_type
388 : #define rr_code rr_hdr.icmp6_code
389 : #define rr_cksum rr_hdr.icmp6_cksum
390 : #define rr_seqnum rr_hdr.icmp6_data32[0]
391 :
392 : struct rr_pco_match { /* match prefix part */
393 : u_int8_t rpm_code;
394 : u_int8_t rpm_len;
395 : u_int8_t rpm_ordinal;
396 : u_int8_t rpm_matchlen;
397 : u_int8_t rpm_minlen;
398 : u_int8_t rpm_maxlen;
399 : u_int16_t rpm_reserved;
400 : struct in6_addr rpm_prefix;
401 : } __packed;
402 :
403 : #define RPM_PCO_ADD 1
404 : #define RPM_PCO_CHANGE 2
405 : #define RPM_PCO_SETGLOBAL 3
406 : #define RPM_PCO_MAX 4
407 :
408 : struct rr_pco_use { /* use prefix part */
409 : u_int8_t rpu_uselen;
410 : u_int8_t rpu_keeplen;
411 : u_int8_t rpu_ramask;
412 : u_int8_t rpu_raflags;
413 : u_int32_t rpu_vltime;
414 : u_int32_t rpu_pltime;
415 : u_int32_t rpu_flags;
416 : struct in6_addr rpu_prefix;
417 : } __packed;
418 : #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
419 : #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
420 :
421 : #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME htonl(0x80000000)
422 : #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME htonl(0x40000000)
423 :
424 : struct rr_result { /* router renumbering result message */
425 : u_int16_t rrr_flags;
426 : u_int8_t rrr_ordinal;
427 : u_int8_t rrr_matchedlen;
428 : u_int32_t rrr_ifid;
429 : struct in6_addr rrr_prefix;
430 : } __packed;
431 : #define ICMP6_RR_RESULT_FLAGS_OOB htons(0x0002)
432 : #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN htons(0x0001)
433 :
434 : /*
435 : * icmp6 filter structures.
436 : */
437 :
438 : struct icmp6_filter {
439 : u_int32_t icmp6_filt[8];
440 : };
441 :
442 : #define ICMP6_FILTER_SETPASSALL(filterp) \
443 : memset(filterp, 0xff, sizeof(struct icmp6_filter))
444 : #define ICMP6_FILTER_SETBLOCKALL(filterp) \
445 : memset(filterp, 0x00, sizeof(struct icmp6_filter))
446 : #define ICMP6_FILTER_SETPASS(type, filterp) \
447 : (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
448 : #define ICMP6_FILTER_SETBLOCK(type, filterp) \
449 : (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
450 : #define ICMP6_FILTER_WILLPASS(type, filterp) \
451 : ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
452 : #define ICMP6_FILTER_WILLBLOCK(type, filterp) \
453 : ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
454 :
455 : /*
456 : * Variables related to this implementation
457 : * of the internet control message protocol version 6.
458 : */
459 : struct icmp6stat {
460 : /* statistics related to icmp6 packets generated */
461 : u_int64_t icp6s_error; /* # of calls to icmp6_error */
462 : u_int64_t icp6s_canterror; /* no error because old was icmp */
463 : u_int64_t icp6s_toofreq; /* no error because rate limitation */
464 : u_int64_t icp6s_outhist[256];
465 : /* statistics related to input message processed */
466 : u_int64_t icp6s_badcode; /* icmp6_code out of range */
467 : u_int64_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */
468 : u_int64_t icp6s_checksum; /* bad checksum */
469 : u_int64_t icp6s_badlen; /* calculated bound mismatch */
470 : /*
471 : * number of responses: this member is inherited from netinet code, but
472 : * for netinet6 code, it is already available in icp6s_outhist[].
473 : */
474 : u_int64_t icp6s_reflect;
475 : u_int64_t icp6s_inhist[256];
476 : u_int64_t icp6s_nd_toomanyopt; /* too many ND options */
477 : u_int64_t icp6s_odst_unreach_noroute;
478 : u_int64_t icp6s_odst_unreach_admin;
479 : u_int64_t icp6s_odst_unreach_beyondscope;
480 : u_int64_t icp6s_odst_unreach_addr;
481 : u_int64_t icp6s_odst_unreach_noport;
482 : u_int64_t icp6s_opacket_too_big;
483 : u_int64_t icp6s_otime_exceed_transit;
484 : u_int64_t icp6s_otime_exceed_reassembly;
485 : u_int64_t icp6s_oparamprob_header;
486 : u_int64_t icp6s_oparamprob_nextheader;
487 : u_int64_t icp6s_oparamprob_option;
488 : u_int64_t icp6s_oredirect; /* we regard redirect as an error here */
489 : u_int64_t icp6s_ounknown;
490 : u_int64_t icp6s_pmtuchg; /* path MTU changes */
491 : u_int64_t icp6s_nd_badopt; /* bad ND options */
492 : u_int64_t icp6s_badns; /* bad neighbor solicitation */
493 : u_int64_t icp6s_badna; /* bad neighbor advertisement */
494 : u_int64_t icp6s_badrs; /* bad router advertisement */
495 : u_int64_t icp6s_badra; /* bad router advertisement */
496 : u_int64_t icp6s_badredirect; /* bad redirect message */
497 : };
498 :
499 : /*
500 : * Names for ICMP sysctl objects
501 : */
502 : #define ICMPV6CTL_STATS 1
503 : #define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
504 : #define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
505 : #define ICMPV6CTL_ND6_DELAY 8
506 : #define ICMPV6CTL_ND6_UMAXTRIES 9
507 : #define ICMPV6CTL_ND6_MMAXTRIES 10
508 : #define ICMPV6CTL_NODEINFO 13
509 : #define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */
510 : #define ICMPV6CTL_ND6_MAXNUDHINT 15
511 : #define ICMPV6CTL_MTUDISC_HIWAT 16
512 : #define ICMPV6CTL_MTUDISC_LOWAT 17
513 : #define ICMPV6CTL_ND6_DEBUG 18
514 : #define ICMPV6CTL_MAXID 19
515 :
516 : #define ICMPV6CTL_NAMES { \
517 : { 0, 0 }, \
518 : { 0, 0 }, \
519 : { 0, 0 }, \
520 : { "redirtimeout", CTLTYPE_INT }, \
521 : { 0, 0 }, \
522 : { 0, 0 }, \
523 : { 0, 0 }, \
524 : { 0, 0 }, \
525 : { "nd6_delay", CTLTYPE_INT }, \
526 : { "nd6_umaxtries", CTLTYPE_INT }, \
527 : { "nd6_mmaxtries", CTLTYPE_INT }, \
528 : { 0, 0 }, \
529 : { 0, 0 }, \
530 : { 0, 0 }, \
531 : { "errppslimit", CTLTYPE_INT }, \
532 : { "nd6_maxnudhint", CTLTYPE_INT }, \
533 : { "mtudisc_hiwat", CTLTYPE_INT }, \
534 : { "mtudisc_lowat", CTLTYPE_INT }, \
535 : { "nd6_debug", CTLTYPE_INT }, \
536 : }
537 :
538 : #define ICMPV6CTL_VARS { \
539 : NULL, \
540 : NULL, \
541 : NULL, \
542 : &icmp6_redirtimeout, \
543 : NULL, \
544 : NULL, \
545 : NULL, \
546 : NULL, \
547 : &nd6_delay, \
548 : &nd6_umaxtries, \
549 : &nd6_mmaxtries, \
550 : NULL, \
551 : NULL, \
552 : NULL, \
553 : &icmp6errppslim, \
554 : &nd6_maxnudhint, \
555 : &icmp6_mtudisc_hiwat, \
556 : &icmp6_mtudisc_lowat, \
557 : &nd6_debug, \
558 : }
559 :
560 : #define RTF_PROBEMTU RTF_PROTO1
561 :
562 : #ifdef _KERNEL
563 :
564 : #include <sys/percpu.h>
565 :
566 : enum icmp6stat_counters {
567 : icp6s_error,
568 : icp6s_canterror,
569 : icp6s_toofreq,
570 : icp6s_outhist,
571 : icp6s_badcode = icp6s_outhist + 256,
572 : icp6s_tooshort,
573 : icp6s_checksum,
574 : icp6s_badlen,
575 : icp6s_reflect,
576 : icp6s_inhist,
577 : icp6s_nd_toomanyopt = icp6s_inhist + 256,
578 : icp6s_odst_unreach_noroute,
579 : icp6s_odst_unreach_admin,
580 : icp6s_odst_unreach_beyondscope,
581 : icp6s_odst_unreach_addr,
582 : icp6s_odst_unreach_noport,
583 : icp6s_opacket_too_big,
584 : icp6s_otime_exceed_transit,
585 : icp6s_otime_exceed_reassembly,
586 : icp6s_oparamprob_header,
587 : icp6s_oparamprob_nextheader,
588 : icp6s_oparamprob_option,
589 : icp6s_oredirect,
590 : icp6s_ounknown,
591 : icp6s_pmtuchg,
592 : icp6s_nd_badopt,
593 : icp6s_badns,
594 : icp6s_badna,
595 : icp6s_badrs,
596 : icp6s_badra,
597 : icp6s_badredirect,
598 : icp6s_ncounters,
599 : };
600 :
601 : extern struct cpumem *icmp6counters;
602 :
603 : static inline void
604 0 : icmp6stat_inc(enum icmp6stat_counters c)
605 : {
606 0 : counters_inc(icmp6counters, c);
607 0 : }
608 :
609 : struct rtentry;
610 : struct rttimer;
611 : struct in6_multi;
612 :
613 : void icmp6_init(void);
614 : void icmp6_paramerror(struct mbuf *, int);
615 : void icmp6_error(struct mbuf *, int, int, int);
616 : int icmp6_input(struct mbuf **, int *, int, int);
617 : void icmp6_fasttimo(void);
618 : void icmp6_reflect(struct mbuf *, size_t);
619 : void icmp6_prepare(struct mbuf *);
620 : void icmp6_redirect_input(struct mbuf *, int);
621 : void icmp6_redirect_output(struct mbuf *, struct rtentry *);
622 : int icmp6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
623 :
624 : struct ip6ctlparam;
625 : void icmp6_mtudisc_update(struct ip6ctlparam *, int);
626 : void icmp6_mtudisc_callback_register(void (*)(struct sockaddr_in6 *, u_int));
627 :
628 : extern int icmp6_redirtimeout; /* cache time for redirect routes */
629 :
630 : #endif /* _KERNEL */
631 : #endif /* _NETINET_ICMP6_H_ */
|