1/* $NetBSD: icmp6.h,v 1.44 2011/12/10 19:14:29 roy Exp $ */ 2/* $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $ */ 3 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. Neither the name of the University nor the names of its contributors 47 * may be used to endorse or promote products derived from this software 48 * without specific prior written permission. 49 * 50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 60 * SUCH DAMAGE. 61 * 62 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 63 */ 64 65#ifndef _NETINET_ICMP6_H_ 66#define _NETINET_ICMP6_H_ 67 68#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr) 69 - sizeof(struct icmp6_hdr) */ 70 71struct icmp6_hdr { 72 u_int8_t icmp6_type; /* type field */ 73 u_int8_t icmp6_code; /* code field */ 74 u_int16_t icmp6_cksum; /* checksum field */ 75 union { 76 u_int32_t icmp6_un_data32[1]; /* type-specific field */ 77 u_int16_t icmp6_un_data16[2]; /* type-specific field */ 78 u_int8_t icmp6_un_data8[4]; /* type-specific field */ 79 } icmp6_dataun; 80} __packed; 81 82#define icmp6_data32 icmp6_dataun.icmp6_un_data32 83#define icmp6_data16 icmp6_dataun.icmp6_un_data16 84#define icmp6_data8 icmp6_dataun.icmp6_un_data8 85#define icmp6_pptr icmp6_data32[0] /* parameter prob */ 86#define icmp6_mtu icmp6_data32[0] /* packet too big */ 87#define icmp6_id icmp6_data16[0] /* echo request/reply */ 88#define icmp6_seq icmp6_data16[1] /* echo request/reply */ 89#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ 90 91#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */ 92#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */ 93#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */ 94#define ICMP6_PARAM_PROB 4 /* ip6 header bad */ 95 96#define ICMP6_ECHO_REQUEST 128 /* echo service */ 97#define ICMP6_ECHO_REPLY 129 /* echo reply */ 98#define MLD_LISTENER_QUERY 130 /* multicast listener query */ 99#define MLD_LISTENER_REPORT 131 /* multicast listener report */ 100#define MLD_LISTENER_DONE 132 /* multicast listener done */ 101 102/* RFC2292 decls */ 103#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */ 104#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */ 105#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */ 106 107#ifndef _KERNEL 108/* the followings are for backward compatibility to old KAME apps. */ 109#define MLD6_LISTENER_QUERY MLD_LISTENER_QUERY 110#define MLD6_LISTENER_REPORT MLD_LISTENER_REPORT 111#define MLD6_LISTENER_DONE MLD_LISTENER_DONE 112#endif 113 114#define ND_ROUTER_SOLICIT 133 /* router solicitation */ 115#define ND_ROUTER_ADVERT 134 /* router advertisement */ 116#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */ 117#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */ 118#define ND_REDIRECT 137 /* redirect */ 119 120#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */ 121 122#define ICMP6_WRUREQUEST 139 /* who are you request */ 123#define ICMP6_WRUREPLY 140 /* who are you reply */ 124#define ICMP6_FQDN_QUERY 139 /* FQDN query */ 125#define ICMP6_FQDN_REPLY 140 /* FQDN reply */ 126#define ICMP6_NI_QUERY 139 /* node information request */ 127#define ICMP6_NI_REPLY 140 /* node information reply */ 128#define MLDV2_LISTENER_REPORT 143 /* RFC3810 listener report */ 129 130/* The definitions below are experimental. TBA */ 131#define MLD_MTRACE_RESP 200 /* mtrace response(to sender) */ 132#define MLD_MTRACE 201 /* mtrace messages */ 133 134#ifndef _KERNEL 135/* the followings are for backward compatibility to old KAME apps. */ 136#define MLD6_MTRACE_RESP MLD_MTRACE_RESP 137#define MLD6_MTRACE MLD_MTRACE 138#endif 139 140#define ICMP6_MAXTYPE 201 141 142#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ 143#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */ 144#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */ 145#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */ 146#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ 147#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */ 148#define ICMP6_DST_UNREACH_POLICY 5 /* source address failed ingress/egress policy */ 149#define ICMP6_DST_UNREACH_REJROUTE 6 /* reject route to destination */ 150#define ICMP6_DST_UNREACH_SOURCERT 7 /* error in source routing header */ 151 152#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */ 153#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */ 154 155#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ 156#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */ 157#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */ 158 159#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ 160 161#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */ 162#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */ 163#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */ 164 165#define ICMP6_NI_SUCCESS 0 /* node information successful reply */ 166#define ICMP6_NI_REFUSED 1 /* node information request is refused */ 167#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */ 168 169#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */ 170#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */ 171#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */ 172 173/* Used in kernel only */ 174#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */ 175#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */ 176 177/* 178 * Multicast Listener Discovery 179 */ 180struct mld_hdr { 181 struct icmp6_hdr mld_icmp6_hdr; 182 struct in6_addr mld_addr; /* multicast address */ 183} __packed; 184 185/* definitions to provide backward compatibility to old KAME applications */ 186#ifndef _KERNEL 187#define mld6_hdr mld_hdr 188#define mld6_type mld_type 189#define mld6_code mld_code 190#define mld6_cksum mld_cksum 191#define mld6_maxdelay mld_maxdelay 192#define mld6_reserved mld_reserved 193#define mld6_addr mld_addr 194#endif 195 196/* shortcut macro definitions */ 197#define mld_type mld_icmp6_hdr.icmp6_type 198#define mld_code mld_icmp6_hdr.icmp6_code 199#define mld_cksum mld_icmp6_hdr.icmp6_cksum 200#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0] 201#define mld_reserved mld_icmp6_hdr.icmp6_data16[1] 202 203#define MLD_MINLEN 24 204 205/* 206 * Neighbor Discovery 207 */ 208 209struct nd_router_solicit { /* router solicitation */ 210 struct icmp6_hdr nd_rs_hdr; 211 /* could be followed by options */ 212} __packed; 213 214#define nd_rs_type nd_rs_hdr.icmp6_type 215#define nd_rs_code nd_rs_hdr.icmp6_code 216#define nd_rs_cksum nd_rs_hdr.icmp6_cksum 217#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] 218 219struct nd_router_advert { /* router advertisement */ 220 struct icmp6_hdr nd_ra_hdr; 221 u_int32_t nd_ra_reachable; /* reachable time */ 222 u_int32_t nd_ra_retransmit; /* retransmit timer */ 223 /* could be followed by options */ 224} __packed; 225 226#define nd_ra_type nd_ra_hdr.icmp6_type 227#define nd_ra_code nd_ra_hdr.icmp6_code 228#define nd_ra_cksum nd_ra_hdr.icmp6_cksum 229#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] 230#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] 231#define ND_RA_FLAG_MANAGED 0x80 232#define ND_RA_FLAG_OTHER 0x40 233#define ND_RA_FLAG_HOME_AGENT 0x20 234 235/* 236 * Router preference values based on RFC4191. 237 */ 238#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */ 239 240#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */ 241#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */ 242#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */ 243#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */ 244 245#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] 246 247struct nd_neighbor_solicit { /* neighbor solicitation */ 248 struct icmp6_hdr nd_ns_hdr; 249 struct in6_addr nd_ns_target; /*target address */ 250 /* could be followed by options */ 251} __packed; 252 253#define nd_ns_type nd_ns_hdr.icmp6_type 254#define nd_ns_code nd_ns_hdr.icmp6_code 255#define nd_ns_cksum nd_ns_hdr.icmp6_cksum 256#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] 257 258struct nd_neighbor_advert { /* neighbor advertisement */ 259 struct icmp6_hdr nd_na_hdr; 260 struct in6_addr nd_na_target; /* target address */ 261 /* could be followed by options */ 262} __packed; 263 264#define nd_na_type nd_na_hdr.icmp6_type 265#define nd_na_code nd_na_hdr.icmp6_code 266#define nd_na_cksum nd_na_hdr.icmp6_cksum 267#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] 268#if BYTE_ORDER == BIG_ENDIAN 269#define ND_NA_FLAG_ROUTER 0x80000000 270#define ND_NA_FLAG_SOLICITED 0x40000000 271#define ND_NA_FLAG_OVERRIDE 0x20000000 272#else 273#if BYTE_ORDER == LITTLE_ENDIAN 274#define ND_NA_FLAG_ROUTER 0x80 275#define ND_NA_FLAG_SOLICITED 0x40 276#define ND_NA_FLAG_OVERRIDE 0x20 277#endif 278#endif 279 280struct nd_redirect { /* redirect */ 281 struct icmp6_hdr nd_rd_hdr; 282 struct in6_addr nd_rd_target; /* target address */ 283 struct in6_addr nd_rd_dst; /* destination address */ 284 /* could be followed by options */ 285} __packed; 286 287#define nd_rd_type nd_rd_hdr.icmp6_type 288#define nd_rd_code nd_rd_hdr.icmp6_code 289#define nd_rd_cksum nd_rd_hdr.icmp6_cksum 290#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] 291 292struct nd_opt_hdr { /* Neighbor discovery option header */ 293 u_int8_t nd_opt_type; 294 u_int8_t nd_opt_len; 295 /* followed by option specific data*/ 296} __packed; 297 298#define ND_OPT_SOURCE_LINKADDR 1 299#define ND_OPT_TARGET_LINKADDR 2 300#define ND_OPT_PREFIX_INFORMATION 3 301#define ND_OPT_REDIRECTED_HEADER 4 302#define ND_OPT_MTU 5 303#define ND_OPT_ADVINTERVAL 7 304#define ND_OPT_HOMEAGENT_INFO 8 305#define ND_OPT_SOURCE_ADDRLIST 9 306#define ND_OPT_TARGET_ADDRLIST 10 307#define ND_OPT_MAP 23 /* RFC 5380 */ 308#define ND_OPT_ROUTE_INFO 24 /* RFC 4191 */ 309#define ND_OPT_RDNSS 25 /* RFC 6016 */ 310#define ND_OPT_DNSSL 31 /* RFC 6016 */ 311 312struct nd_opt_route_info { /* route info */ 313 u_int8_t nd_opt_rti_type; 314 u_int8_t nd_opt_rti_len; 315 u_int8_t nd_opt_rti_prefixlen; 316 u_int8_t nd_opt_rti_flags; 317 u_int32_t nd_opt_rti_lifetime; 318 /* prefix follows */ 319}; 320 321struct nd_opt_prefix_info { /* prefix information */ 322 u_int8_t nd_opt_pi_type; 323 u_int8_t nd_opt_pi_len; 324 u_int8_t nd_opt_pi_prefix_len; 325 u_int8_t nd_opt_pi_flags_reserved; 326 u_int32_t nd_opt_pi_valid_time; 327 u_int32_t nd_opt_pi_preferred_time; 328 u_int32_t nd_opt_pi_reserved2; 329 struct in6_addr nd_opt_pi_prefix; 330} __packed; 331 332#define ND_OPT_PI_FLAG_ONLINK 0x80 333#define ND_OPT_PI_FLAG_AUTO 0x40 334 335struct nd_opt_rd_hdr { /* redirected header */ 336 u_int8_t nd_opt_rh_type; 337 u_int8_t nd_opt_rh_len; 338 u_int16_t nd_opt_rh_reserved1; 339 u_int32_t nd_opt_rh_reserved2; 340 /* followed by IP header and data */ 341} __packed; 342 343struct nd_opt_mtu { /* MTU option */ 344 u_int8_t nd_opt_mtu_type; 345 u_int8_t nd_opt_mtu_len; 346 u_int16_t nd_opt_mtu_reserved; 347 u_int32_t nd_opt_mtu_mtu; 348} __packed; 349 350struct nd_opt_rdnss { /* RDNSS option RFC 6106 */ 351 u_int8_t nd_opt_rdnss_type; 352 u_int8_t nd_opt_rdnss_len; 353 u_int16_t nd_opt_rdnss_reserved; 354 u_int32_t nd_opt_rdnss_lifetime; 355 /* followed by list of IP prefixes */ 356} __packed; 357 358struct nd_opt_dnssl { /* DNSSL option RFC 6106 */ 359 u_int8_t nd_opt_dnssl_type; 360 u_int8_t nd_opt_dnssl_len; 361 u_int16_t nd_opt_dnssl_reserved; 362 u_int32_t nd_opt_dnssl_lifetime; 363 /* followed by list of IP prefixes */ 364} __packed; 365 366/* 367 * icmp6 namelookup 368 */ 369 370struct icmp6_namelookup { 371 struct icmp6_hdr icmp6_nl_hdr; 372 u_int8_t icmp6_nl_nonce[8]; 373 int32_t icmp6_nl_ttl; 374#if 0 375 u_int8_t icmp6_nl_len; 376 u_int8_t icmp6_nl_name[3]; 377#endif 378 /* could be followed by options */ 379} __packed; 380 381/* 382 * icmp6 node information 383 */ 384struct icmp6_nodeinfo { 385 struct icmp6_hdr icmp6_ni_hdr; 386 u_int8_t icmp6_ni_nonce[8]; 387 /* could be followed by reply data */ 388} __packed; 389 390#define ni_type icmp6_ni_hdr.icmp6_type 391#define ni_code icmp6_ni_hdr.icmp6_code 392#define ni_cksum icmp6_ni_hdr.icmp6_cksum 393#define ni_qtype icmp6_ni_hdr.icmp6_data16[0] 394#define ni_flags icmp6_ni_hdr.icmp6_data16[1] 395 396#define NI_QTYPE_NOOP 0 /* NOOP */ 397#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */ 398#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */ 399#define NI_QTYPE_DNSNAME 2 /* DNS Name */ 400#define NI_QTYPE_NODEADDR 3 /* Node Addresses */ 401#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */ 402 403#if BYTE_ORDER == BIG_ENDIAN 404#define NI_SUPTYPE_FLAG_COMPRESS 0x1 405#define NI_FQDN_FLAG_VALIDTTL 0x1 406#elif BYTE_ORDER == LITTLE_ENDIAN 407#define NI_SUPTYPE_FLAG_COMPRESS 0x0100 408#define NI_FQDN_FLAG_VALIDTTL 0x0100 409#endif 410 411#ifdef NAME_LOOKUPS_04 412#if BYTE_ORDER == BIG_ENDIAN 413#define NI_NODEADDR_FLAG_LINKLOCAL 0x1 414#define NI_NODEADDR_FLAG_SITELOCAL 0x2 415#define NI_NODEADDR_FLAG_GLOBAL 0x4 416#define NI_NODEADDR_FLAG_ALL 0x8 417#define NI_NODEADDR_FLAG_TRUNCATE 0x10 418#define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */ 419#elif BYTE_ORDER == LITTLE_ENDIAN 420#define NI_NODEADDR_FLAG_LINKLOCAL 0x0100 421#define NI_NODEADDR_FLAG_SITELOCAL 0x0200 422#define NI_NODEADDR_FLAG_GLOBAL 0x0400 423#define NI_NODEADDR_FLAG_ALL 0x0800 424#define NI_NODEADDR_FLAG_TRUNCATE 0x1000 425#define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */ 426#endif 427#else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */ 428#if BYTE_ORDER == BIG_ENDIAN 429#define NI_NODEADDR_FLAG_TRUNCATE 0x1 430#define NI_NODEADDR_FLAG_ALL 0x2 431#define NI_NODEADDR_FLAG_COMPAT 0x4 432#define NI_NODEADDR_FLAG_LINKLOCAL 0x8 433#define NI_NODEADDR_FLAG_SITELOCAL 0x10 434#define NI_NODEADDR_FLAG_GLOBAL 0x20 435#define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */ 436#elif BYTE_ORDER == LITTLE_ENDIAN 437#define NI_NODEADDR_FLAG_TRUNCATE 0x0100 438#define NI_NODEADDR_FLAG_ALL 0x0200 439#define NI_NODEADDR_FLAG_COMPAT 0x0400 440#define NI_NODEADDR_FLAG_LINKLOCAL 0x0800 441#define NI_NODEADDR_FLAG_SITELOCAL 0x1000 442#define NI_NODEADDR_FLAG_GLOBAL 0x2000 443#define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */ 444#endif 445#endif 446 447struct ni_reply_fqdn { 448 u_int32_t ni_fqdn_ttl; /* TTL */ 449 u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */ 450 u_int8_t ni_fqdn_name[3]; /* XXX: alignment */ 451} __packed; 452 453/* 454 * Router Renumbering. as router-renum-08.txt 455 */ 456struct icmp6_router_renum { /* router renumbering header */ 457 struct icmp6_hdr rr_hdr; 458 u_int8_t rr_segnum; 459 u_int8_t rr_flags; 460 u_int16_t rr_maxdelay; 461 u_int32_t rr_reserved; 462} __packed; 463 464#define ICMP6_RR_FLAGS_TEST 0x80 465#define ICMP6_RR_FLAGS_REQRESULT 0x40 466#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20 467#define ICMP6_RR_FLAGS_SPECSITE 0x10 468#define ICMP6_RR_FLAGS_PREVDONE 0x08 469 470#define rr_type rr_hdr.icmp6_type 471#define rr_code rr_hdr.icmp6_code 472#define rr_cksum rr_hdr.icmp6_cksum 473#define rr_seqnum rr_hdr.icmp6_data32[0] 474 475struct rr_pco_match { /* match prefix part */ 476 u_int8_t rpm_code; 477 u_int8_t rpm_len; 478 u_int8_t rpm_ordinal; 479 u_int8_t rpm_matchlen; 480 u_int8_t rpm_minlen; 481 u_int8_t rpm_maxlen; 482 u_int16_t rpm_reserved; 483 struct in6_addr rpm_prefix; 484} __packed; 485 486#define RPM_PCO_ADD 1 487#define RPM_PCO_CHANGE 2 488#define RPM_PCO_SETGLOBAL 3 489#define RPM_PCO_MAX 4 490 491struct rr_pco_use { /* use prefix part */ 492 u_int8_t rpu_uselen; 493 u_int8_t rpu_keeplen; 494 u_int8_t rpu_ramask; 495 u_int8_t rpu_raflags; 496 u_int32_t rpu_vltime; 497 u_int32_t rpu_pltime; 498 u_int32_t rpu_flags; 499 struct in6_addr rpu_prefix; 500} __packed; 501#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80 502#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40 503 504#if BYTE_ORDER == BIG_ENDIAN 505#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000 506#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000 507#elif BYTE_ORDER == LITTLE_ENDIAN 508#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80 509#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40 510#endif 511 512struct rr_result { /* router renumbering result message */ 513 u_int16_t rrr_flags; 514 u_int8_t rrr_ordinal; 515 u_int8_t rrr_matchedlen; 516 u_int32_t rrr_ifid; 517 struct in6_addr rrr_prefix; 518} __packed; 519#if BYTE_ORDER == BIG_ENDIAN 520#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002 521#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001 522#elif BYTE_ORDER == LITTLE_ENDIAN 523#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200 524#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100 525#endif 526 527/* 528 * icmp6 filter structures. 529 */ 530 531struct icmp6_filter { 532 u_int32_t icmp6_filt[8]; 533}; 534 535#define ICMP6_FILTER_SETPASSALL(filterp) \ 536 (void)memset(filterp, 0xff, sizeof(struct icmp6_filter)) 537#define ICMP6_FILTER_SETBLOCKALL(filterp) \ 538 (void)memset(filterp, 0x00, sizeof(struct icmp6_filter)) 539#define ICMP6_FILTER_SETPASS(type, filterp) \ 540 (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))) 541#define ICMP6_FILTER_SETBLOCK(type, filterp) \ 542 (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))) 543#define ICMP6_FILTER_WILLPASS(type, filterp) \ 544 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0) 545#define ICMP6_FILTER_WILLBLOCK(type, filterp) \ 546 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0) 547 548/* 549 * Variables related to this implementation 550 * of the internet control message protocol version 6. 551 */ 552 553/* 554 * IPv6 ICMP statistics. 555 * Each counter is an unsigned 64-bit value. 556 */ 557#define ICMP6_STAT_ERROR 0 /* # of calls to icmp6_error */ 558#define ICMP6_STAT_CANTERROR 1 /* no error (old was icmp) */ 559#define ICMP6_STAT_TOOFREQ 2 /* no error (rate limitation) */ 560#define ICMP6_STAT_OUTHIST 3 /* # of output messages */ 561 /* space for 256 counters */ 562#define ICMP6_STAT_BADCODE 259 /* icmp6_code out of range */ 563#define ICMP6_STAT_TOOSHORT 260 /* packet < sizeof(struct icmp6_hdr) */ 564#define ICMP6_STAT_CHECKSUM 261 /* bad checksum */ 565#define ICMP6_STAT_BADLEN 262 /* calculated bound mismatch */ 566 /* 567 * number of responses; this member is inherited from the netinet code, 568 * but for netinet6 code, it is already available in outhist[]. 569 */ 570#define ICMP6_STAT_REFLECT 263 571#define ICMP6_STAT_INHIST 264 /* # of input messages */ 572 /* space for 256 counters */ 573#define ICMP6_STAT_ND_TOOMANYOPT 520 /* too many ND options */ 574#define ICMP6_STAT_OUTERRHIST 521 575 /* space for 13 counters */ 576#define ICMP6_STAT_PMTUCHG 534 /* path MTU changes */ 577#define ICMP6_STAT_ND_BADOPT 535 /* bad ND options */ 578#define ICMP6_STAT_BADNS 536 /* bad neighbor solicititation */ 579#define ICMP6_STAT_BADNA 537 /* bad neighbor advertisement */ 580#define ICMP6_STAT_BADRS 538 /* bad router solicitiation */ 581#define ICMP6_STAT_BADRA 539 /* bad router advertisement */ 582#define ICMP6_STAT_BADREDIRECT 540 /* bad redirect message */ 583#define ICMP6_STAT_DROPPED_RAROUTE 541 /* discarded routes from router advertisement */ 584 585#define ICMP6_NSTATS 542 586 587#define ICMP6_ERRSTAT_DST_UNREACH_NOROUTE 0 588#define ICMP6_ERRSTAT_DST_UNREACH_ADMIN 1 589#define ICMP6_ERRSTAT_DST_UNREACH_BEYONDSCOPE 2 590#define ICMP6_ERRSTAT_DST_UNREACH_ADDR 3 591#define ICMP6_ERRSTAT_DST_UNREACH_NOPORT 4 592#define ICMP6_ERRSTAT_PACKET_TOO_BIG 5 593#define ICMP6_ERRSTAT_TIME_EXCEED_TRANSIT 6 594#define ICMP6_ERRSTAT_TIME_EXCEED_REASSEMBLY 7 595#define ICMP6_ERRSTAT_PARAMPROB_HEADER 8 596#define ICMP6_ERRSTAT_PARAMPROB_NEXTHEADER 9 597#define ICMP6_ERRSTAT_PARAMPROB_OPTION 10 598#define ICMP6_ERRSTAT_REDIRECT 11 599#define ICMP6_ERRSTAT_UNKNOWN 12 600 601/* 602 * Names for ICMP sysctl objects 603 */ 604#define ICMPV6CTL_STATS 1 605#define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */ 606#define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */ 607#if 0 /*obsoleted*/ 608#define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */ 609#endif 610#define ICMPV6CTL_ND6_PRUNE 6 611#define ICMPV6CTL_ND6_DELAY 8 612#define ICMPV6CTL_ND6_UMAXTRIES 9 613#define ICMPV6CTL_ND6_MMAXTRIES 10 614#define ICMPV6CTL_ND6_USELOOPBACK 11 615/*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */ 616#define ICMPV6CTL_NODEINFO 13 617#define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */ 618#define ICMPV6CTL_ND6_MAXNUDHINT 15 619#define ICMPV6CTL_MTUDISC_HIWAT 16 620#define ICMPV6CTL_MTUDISC_LOWAT 17 621#define ICMPV6CTL_ND6_DEBUG 18 622#define ICMPV6CTL_ND6_DRLIST 19 623#define ICMPV6CTL_ND6_PRLIST 20 624#define ICMPV6CTL_ND6_MAXQLEN 24 625#define ICMPV6CTL_MAXID 25 626 627#define ICMPV6CTL_NAMES { \ 628 { 0, 0 }, \ 629 { 0, 0 }, \ 630 { "rediraccept", CTLTYPE_INT }, \ 631 { "redirtimeout", CTLTYPE_INT }, \ 632 { 0, 0 }, \ 633 { 0, 0 }, \ 634 { "nd6_prune", CTLTYPE_INT }, \ 635 { 0, 0 }, \ 636 { "nd6_delay", CTLTYPE_INT }, \ 637 { "nd6_umaxtries", CTLTYPE_INT }, \ 638 { "nd6_mmaxtries", CTLTYPE_INT }, \ 639 { "nd6_useloopback", CTLTYPE_INT }, \ 640 { 0, 0 }, \ 641 { "nodeinfo", CTLTYPE_INT }, \ 642 { "errppslimit", CTLTYPE_INT }, \ 643 { "nd6_maxnudhint", CTLTYPE_INT }, \ 644 { "mtudisc_hiwat", CTLTYPE_INT }, \ 645 { "mtudisc_lowat", CTLTYPE_INT }, \ 646 { "nd6_debug", CTLTYPE_INT }, \ 647 { 0, 0 }, \ 648 { 0, 0 }, \ 649 { 0, 0 }, \ 650 { 0, 0 }, \ 651 { 0, 0 }, \ 652 { "nd6_maxqueuelen", CTLTYPE_INT }, \ 653} 654 655#ifdef _KERNEL 656struct rtentry; 657struct rttimer; 658struct in6_multi; 659 660void icmp6_init(void); 661void icmp6_paramerror(struct mbuf *, int); 662void icmp6_error(struct mbuf *, int, int, int); 663void icmp6_error2(struct mbuf *, int, int, int, struct ifnet *); 664int icmp6_input(struct mbuf **, int *, int); 665void icmp6_fasttimo(void); 666void icmp6_reflect(struct mbuf *, size_t); 667void icmp6_prepare(struct mbuf *); 668void icmp6_redirect_input(struct mbuf *, int); 669void icmp6_redirect_output(struct mbuf *, struct rtentry *); 670int icmp6_sysctl(int *, u_int, void *, size_t *, void *, size_t); 671 672void icmp6_statinc(u_int); 673 674struct ip6ctlparam; 675void icmp6_mtudisc_update(struct ip6ctlparam *, int); 676void icmp6_mtudisc_callback_register(void (*)(struct in6_addr *)); 677 678/* XXX: is this the right place for these macros? */ 679#define icmp6_ifstat_inc(ifp, tag) \ 680do { \ 681 if (ifp) \ 682 ((struct in6_ifextra *)((ifp)->if_afdata[AF_INET6]))->icmp6_ifstat->tag++; \ 683} while (/*CONSTCOND*/ 0) 684 685#define icmp6_ifoutstat_inc(ifp, type, code) \ 686do { \ 687 icmp6_ifstat_inc(ifp, ifs6_out_msg); \ 688 switch(type) { \ 689 case ICMP6_DST_UNREACH: \ 690 icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \ 691 if (code == ICMP6_DST_UNREACH_ADMIN) \ 692 icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \ 693 break; \ 694 case ICMP6_PACKET_TOO_BIG: \ 695 icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \ 696 break; \ 697 case ICMP6_TIME_EXCEEDED: \ 698 icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \ 699 break; \ 700 case ICMP6_PARAM_PROB: \ 701 icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \ 702 break; \ 703 case ICMP6_ECHO_REQUEST: \ 704 icmp6_ifstat_inc(ifp, ifs6_out_echo); \ 705 break; \ 706 case ICMP6_ECHO_REPLY: \ 707 icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \ 708 break; \ 709 case MLD_LISTENER_QUERY: \ 710 icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \ 711 break; \ 712 case MLD_LISTENER_REPORT: \ 713 icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \ 714 break; \ 715 case MLD_LISTENER_DONE: \ 716 icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \ 717 break; \ 718 case ND_ROUTER_SOLICIT: \ 719 icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \ 720 break; \ 721 case ND_ROUTER_ADVERT: \ 722 icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \ 723 break; \ 724 case ND_NEIGHBOR_SOLICIT: \ 725 icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \ 726 break; \ 727 case ND_NEIGHBOR_ADVERT: \ 728 icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \ 729 break; \ 730 case ND_REDIRECT: \ 731 icmp6_ifstat_inc(ifp, ifs6_out_redirect); \ 732 break; \ 733 } \ 734} while (/*CONSTCOND*/ 0) 735 736extern int icmp6_rediraccept; /* accept/process redirects */ 737extern int icmp6_redirtimeout; /* cache time for redirect routes */ 738#endif /* _KERNEL */ 739 740#ifdef ICMP6_STRINGS 741/* Info: http://www.iana.org/assignments/icmpv6-parameters */ 742 743static const char * const icmp6_type_err[] = { 744 "reserved0", "unreach", "packet_too_big", "timxceed", "paramprob", 745 NULL 746}; 747 748static const char * const icmp6_type_info[] = { 749 "echo", "echoreply", 750 "mcastlistenq", "mcastlistenrep", "mcastlistendone", 751 "rtsol", "rtadv", "neighsol", "neighadv", "redirect", 752 "routerrenum", "nodeinfoq", "nodeinfor", "invneighsol", "invneighrep", 753 "mcastlistenrep2", "haad_req", "haad_rep", 754 "mobile_psol", "mobile_padv", "cga_sol", "cga_adv", 755 "experimental150", "mcast_rtadv", "mcast_rtsol", "mcast_rtterm", 756 "fmipv6_msg", "rpl_control", NULL 757}; 758 759static const char * const icmp6_code_none[] = { "none", NULL }; 760 761static const char * const icmp6_code_unreach[] = { 762 "noroute", "admin", "beyondscope", "addr", "port", 763 "srcaddr_policy", "reject_route", "source_route_err", NULL 764}; 765 766static const char * const icmp6_code_timxceed[] = { 767 "intrans", "reass", NULL 768}; 769 770static const char * const icmp6_code_paramprob[] = { 771 "hdr_field", "nxthdr_type", "option", NULL 772}; 773 774/* not all informational icmps that have codes have a names array */ 775#endif 776 777#endif /* !_NETINET_ICMP6_H_ */ 778