icmp6.h revision 78539
162587Sitojun/* $FreeBSD: head/sys/netinet/icmp6.h 78539 2001-06-21 07:08:43Z sumikawa $ */ 278064Sume/* $KAME: icmp6.h,v 1.46 2001/04/27 15:09:48 itojun Exp $ */ 362587Sitojun 453541Sshin/* 553541Sshin * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 653541Sshin * All rights reserved. 753541Sshin * 853541Sshin * Redistribution and use in source and binary forms, with or without 953541Sshin * modification, are permitted provided that the following conditions 1053541Sshin * are met: 1153541Sshin * 1. Redistributions of source code must retain the above copyright 1253541Sshin * notice, this list of conditions and the following disclaimer. 1353541Sshin * 2. Redistributions in binary form must reproduce the above copyright 1453541Sshin * notice, this list of conditions and the following disclaimer in the 1553541Sshin * documentation and/or other materials provided with the distribution. 1653541Sshin * 3. Neither the name of the project nor the names of its contributors 1753541Sshin * may be used to endorse or promote products derived from this software 1853541Sshin * without specific prior written permission. 1953541Sshin * 2053541Sshin * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 2153541Sshin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2253541Sshin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2353541Sshin * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2453541Sshin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2553541Sshin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2653541Sshin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2753541Sshin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2853541Sshin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2953541Sshin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3053541Sshin * SUCH DAMAGE. 3162587Sitojun */ 3262587Sitojun 3362587Sitojun/* 3462587Sitojun * Copyright (c) 1982, 1986, 1993 3562587Sitojun * The Regents of the University of California. All rights reserved. 3653541Sshin * 3762587Sitojun * Redistribution and use in source and binary forms, with or without 3862587Sitojun * modification, are permitted provided that the following conditions 3962587Sitojun * are met: 4062587Sitojun * 1. Redistributions of source code must retain the above copyright 4162587Sitojun * notice, this list of conditions and the following disclaimer. 4262587Sitojun * 2. Redistributions in binary form must reproduce the above copyright 4362587Sitojun * notice, this list of conditions and the following disclaimer in the 4462587Sitojun * documentation and/or other materials provided with the distribution. 4562587Sitojun * 3. All advertising materials mentioning features or use of this software 4662587Sitojun * must display the following acknowledgement: 4762587Sitojun * This product includes software developed by the University of 4862587Sitojun * California, Berkeley and its contributors. 4962587Sitojun * 4. Neither the name of the University nor the names of its contributors 5062587Sitojun * may be used to endorse or promote products derived from this software 5162587Sitojun * without specific prior written permission. 5262587Sitojun * 5362587Sitojun * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 5462587Sitojun * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 5562587Sitojun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 5662587Sitojun * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 5762587Sitojun * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 5862587Sitojun * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 5962587Sitojun * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 6062587Sitojun * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 6162587Sitojun * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 6262587Sitojun * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 6362587Sitojun * SUCH DAMAGE. 6462587Sitojun * 6562587Sitojun * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 6653541Sshin */ 6753541Sshin 6853541Sshin#ifndef _NETINET_ICMP6_H_ 6962587Sitojun#define _NETINET_ICMP6_H_ 7053541Sshin 7162587Sitojun#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr) 7262587Sitojun - sizeof(struct icmp6_hdr) */ 7353541Sshin 7462587Sitojunstruct icmp6_hdr { 7562587Sitojun u_int8_t icmp6_type; /* type field */ 7662587Sitojun u_int8_t icmp6_code; /* code field */ 7762587Sitojun u_int16_t icmp6_cksum; /* checksum field */ 7862587Sitojun union { 7962587Sitojun u_int32_t icmp6_un_data32[1]; /* type-specific field */ 8062587Sitojun u_int16_t icmp6_un_data16[2]; /* type-specific field */ 8162587Sitojun u_int8_t icmp6_un_data8[4]; /* type-specific field */ 8262587Sitojun } icmp6_dataun; 8378064Sume} __attribute__((__packed__)); 8462587Sitojun 8562587Sitojun#define icmp6_data32 icmp6_dataun.icmp6_un_data32 8662587Sitojun#define icmp6_data16 icmp6_dataun.icmp6_un_data16 8762587Sitojun#define icmp6_data8 icmp6_dataun.icmp6_un_data8 8862587Sitojun#define icmp6_pptr icmp6_data32[0] /* parameter prob */ 8962587Sitojun#define icmp6_mtu icmp6_data32[0] /* packet too big */ 9062587Sitojun#define icmp6_id icmp6_data16[0] /* echo request/reply */ 9162587Sitojun#define icmp6_seq icmp6_data16[1] /* echo request/reply */ 9262587Sitojun#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ 9362587Sitojun 9462587Sitojun#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */ 9562587Sitojun#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */ 9662587Sitojun#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */ 9762587Sitojun#define ICMP6_PARAM_PROB 4 /* ip6 header bad */ 9862587Sitojun 9962587Sitojun#define ICMP6_ECHO_REQUEST 128 /* echo service */ 10062587Sitojun#define ICMP6_ECHO_REPLY 129 /* echo reply */ 10162587Sitojun#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */ 10262587Sitojun#define MLD6_LISTENER_QUERY 130 /* multicast listener query */ 10362587Sitojun#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */ 10462587Sitojun#define MLD6_LISTENER_REPORT 131 /* multicast listener report */ 10562587Sitojun#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */ 10662587Sitojun#define MLD6_LISTENER_DONE 132 /* multicast listener done */ 10762587Sitojun 10862587Sitojun#define ND_ROUTER_SOLICIT 133 /* router solicitation */ 10962587Sitojun#define ND_ROUTER_ADVERT 134 /* router advertisment */ 11062587Sitojun#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */ 11162587Sitojun#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */ 11262587Sitojun#define ND_REDIRECT 137 /* redirect */ 11362587Sitojun 11462587Sitojun#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */ 11562587Sitojun 11662587Sitojun#define ICMP6_WRUREQUEST 139 /* who are you request */ 11762587Sitojun#define ICMP6_WRUREPLY 140 /* who are you reply */ 11862587Sitojun#define ICMP6_FQDN_QUERY 139 /* FQDN query */ 11962587Sitojun#define ICMP6_FQDN_REPLY 140 /* FQDN reply */ 12062587Sitojun#define ICMP6_NI_QUERY 139 /* node information request */ 12162587Sitojun#define ICMP6_NI_REPLY 140 /* node information reply */ 12262587Sitojun 12362587Sitojun/* The definitions below are experimental. TBA */ 12478539Ssumikawa#define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */ 12578539Ssumikawa#define MLD6_MTRACE 201 /* mtrace messages */ 12662587Sitojun 12778539Ssumikawa#define ICMP6_HADISCOV_REQUEST 202 /* XXX To be defined */ 12878539Ssumikawa#define ICMP6_HADISCOV_REPLY 203 /* XXX To be defined */ 12978064Sume 13078539Ssumikawa#define ICMP6_MAXTYPE 203 13162587Sitojun 13262587Sitojun#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ 13362587Sitojun#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */ 13462587Sitojun#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */ 13562587Sitojun#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */ 13662587Sitojun#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ 13762587Sitojun#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */ 13862587Sitojun 13962587Sitojun#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */ 14062587Sitojun#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */ 14162587Sitojun 14262587Sitojun#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ 14362587Sitojun#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */ 14462587Sitojun#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */ 14562587Sitojun 14662587Sitojun#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ 14762587Sitojun 14862587Sitojun#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */ 14962587Sitojun#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */ 15062587Sitojun#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */ 15162587Sitojun 15278064Sume#define ICMP6_NI_SUCCESS 0 /* node information successful reply */ 15362587Sitojun#define ICMP6_NI_REFUSED 1 /* node information request is refused */ 15462587Sitojun#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */ 15562587Sitojun 15662587Sitojun#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */ 15762587Sitojun#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */ 15862587Sitojun#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */ 15962587Sitojun 16062587Sitojun/* Used in kernel only */ 16162587Sitojun#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */ 16262587Sitojun#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */ 16362587Sitojun 16462587Sitojun/* 16562587Sitojun * Multicast Listener Discovery 16662587Sitojun */ 16762587Sitojunstruct mld6_hdr { 16862587Sitojun struct icmp6_hdr mld6_hdr; 16962587Sitojun struct in6_addr mld6_addr; /* multicast address */ 17078064Sume} __attribute__((__packed__)); 17162587Sitojun 17262587Sitojun#define mld6_type mld6_hdr.icmp6_type 17362587Sitojun#define mld6_code mld6_hdr.icmp6_code 17462587Sitojun#define mld6_cksum mld6_hdr.icmp6_cksum 17562587Sitojun#define mld6_maxdelay mld6_hdr.icmp6_data16[0] 17662587Sitojun#define mld6_reserved mld6_hdr.icmp6_data16[1] 17762587Sitojun 17862587Sitojun/* 17962587Sitojun * Neighbor Discovery 18062587Sitojun */ 18162587Sitojun 18262587Sitojunstruct nd_router_solicit { /* router solicitation */ 18362587Sitojun struct icmp6_hdr nd_rs_hdr; 18462587Sitojun /* could be followed by options */ 18578064Sume} __attribute__((__packed__)); 18662587Sitojun 18762587Sitojun#define nd_rs_type nd_rs_hdr.icmp6_type 18862587Sitojun#define nd_rs_code nd_rs_hdr.icmp6_code 18962587Sitojun#define nd_rs_cksum nd_rs_hdr.icmp6_cksum 19062587Sitojun#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] 19162587Sitojun 19262587Sitojunstruct nd_router_advert { /* router advertisement */ 19362587Sitojun struct icmp6_hdr nd_ra_hdr; 19462587Sitojun u_int32_t nd_ra_reachable; /* reachable time */ 19562587Sitojun u_int32_t nd_ra_retransmit; /* retransmit timer */ 19662587Sitojun /* could be followed by options */ 19778064Sume} __attribute__((__packed__)); 19862587Sitojun 19962587Sitojun#define nd_ra_type nd_ra_hdr.icmp6_type 20062587Sitojun#define nd_ra_code nd_ra_hdr.icmp6_code 20162587Sitojun#define nd_ra_cksum nd_ra_hdr.icmp6_cksum 20262587Sitojun#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] 20362587Sitojun#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] 20462587Sitojun#define ND_RA_FLAG_MANAGED 0x80 20562587Sitojun#define ND_RA_FLAG_OTHER 0x40 20678064Sume#define ND_RA_FLAG_HA 0x20 20778064Sume 20878064Sume/* 20978064Sume * Router preference values based on draft-draves-ipngwg-router-selection-01. 21078064Sume * These are non-standard definitions. 21178064Sume */ 21278064Sume#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */ 21378064Sume 21478064Sume#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */ 21578064Sume#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */ 21678064Sume#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */ 21778064Sume#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */ 21878064Sume 21962587Sitojun#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] 22062587Sitojun 22162587Sitojunstruct nd_neighbor_solicit { /* neighbor solicitation */ 22262587Sitojun struct icmp6_hdr nd_ns_hdr; 22362587Sitojun struct in6_addr nd_ns_target; /*target address */ 22462587Sitojun /* could be followed by options */ 22578064Sume} __attribute__((__packed__)); 22662587Sitojun 22762587Sitojun#define nd_ns_type nd_ns_hdr.icmp6_type 22862587Sitojun#define nd_ns_code nd_ns_hdr.icmp6_code 22962587Sitojun#define nd_ns_cksum nd_ns_hdr.icmp6_cksum 23062587Sitojun#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] 23162587Sitojun 23262587Sitojunstruct nd_neighbor_advert { /* neighbor advertisement */ 23362587Sitojun struct icmp6_hdr nd_na_hdr; 23462587Sitojun struct in6_addr nd_na_target; /* target address */ 23562587Sitojun /* could be followed by options */ 23678064Sume} __attribute__((__packed__)); 23762587Sitojun 23862587Sitojun#define nd_na_type nd_na_hdr.icmp6_type 23962587Sitojun#define nd_na_code nd_na_hdr.icmp6_code 24062587Sitojun#define nd_na_cksum nd_na_hdr.icmp6_cksum 24162587Sitojun#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] 24262587Sitojun#if BYTE_ORDER == BIG_ENDIAN 24362587Sitojun#define ND_NA_FLAG_ROUTER 0x80000000 24462587Sitojun#define ND_NA_FLAG_SOLICITED 0x40000000 24562587Sitojun#define ND_NA_FLAG_OVERRIDE 0x20000000 24662587Sitojun#else 24762587Sitojun#if BYTE_ORDER == LITTLE_ENDIAN 24862587Sitojun#define ND_NA_FLAG_ROUTER 0x80 24962587Sitojun#define ND_NA_FLAG_SOLICITED 0x40 25062587Sitojun#define ND_NA_FLAG_OVERRIDE 0x20 25162587Sitojun#endif 25262587Sitojun#endif 25362587Sitojun 25462587Sitojunstruct nd_redirect { /* redirect */ 25562587Sitojun struct icmp6_hdr nd_rd_hdr; 25662587Sitojun struct in6_addr nd_rd_target; /* target address */ 25762587Sitojun struct in6_addr nd_rd_dst; /* destination address */ 25862587Sitojun /* could be followed by options */ 25978064Sume} __attribute__((__packed__)); 26062587Sitojun 26162587Sitojun#define nd_rd_type nd_rd_hdr.icmp6_type 26262587Sitojun#define nd_rd_code nd_rd_hdr.icmp6_code 26362587Sitojun#define nd_rd_cksum nd_rd_hdr.icmp6_cksum 26462587Sitojun#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] 26562587Sitojun 26662587Sitojunstruct nd_opt_hdr { /* Neighbor discovery option header */ 26762587Sitojun u_int8_t nd_opt_type; 26862587Sitojun u_int8_t nd_opt_len; 26962587Sitojun /* followed by option specific data*/ 27078064Sume} __attribute__((__packed__)); 27162587Sitojun 27262587Sitojun#define ND_OPT_SOURCE_LINKADDR 1 27362587Sitojun#define ND_OPT_TARGET_LINKADDR 2 27462587Sitojun#define ND_OPT_PREFIX_INFORMATION 3 27562587Sitojun#define ND_OPT_REDIRECTED_HEADER 4 27662587Sitojun#define ND_OPT_MTU 5 27762587Sitojun 27878539Ssumikawa#define ND_OPT_ROUTE_INFO 200 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */ 27978539Ssumikawa 28062587Sitojunstruct nd_opt_prefix_info { /* prefix information */ 28162587Sitojun u_int8_t nd_opt_pi_type; 28262587Sitojun u_int8_t nd_opt_pi_len; 28362587Sitojun u_int8_t nd_opt_pi_prefix_len; 28462587Sitojun u_int8_t nd_opt_pi_flags_reserved; 28562587Sitojun u_int32_t nd_opt_pi_valid_time; 28662587Sitojun u_int32_t nd_opt_pi_preferred_time; 28762587Sitojun u_int32_t nd_opt_pi_reserved2; 28862587Sitojun struct in6_addr nd_opt_pi_prefix; 28978064Sume} __attribute__((__packed__)); 29062587Sitojun 29162587Sitojun#define ND_OPT_PI_FLAG_ONLINK 0x80 29262587Sitojun#define ND_OPT_PI_FLAG_AUTO 0x40 29362587Sitojun 29462587Sitojunstruct nd_opt_rd_hdr { /* redirected header */ 29562587Sitojun u_int8_t nd_opt_rh_type; 29662587Sitojun u_int8_t nd_opt_rh_len; 29762587Sitojun u_int16_t nd_opt_rh_reserved1; 29862587Sitojun u_int32_t nd_opt_rh_reserved2; 29962587Sitojun /* followed by IP header and data */ 30078064Sume} __attribute__((__packed__)); 30162587Sitojun 30262587Sitojunstruct nd_opt_mtu { /* MTU option */ 30362587Sitojun u_int8_t nd_opt_mtu_type; 30462587Sitojun u_int8_t nd_opt_mtu_len; 30562587Sitojun u_int16_t nd_opt_mtu_reserved; 30662587Sitojun u_int32_t nd_opt_mtu_mtu; 30778064Sume} __attribute__((__packed__)); 30862587Sitojun 30978064Sumestruct nd_opt_route_info { /* route info */ 31078064Sume u_int8_t nd_opt_rti_type; 31178064Sume u_int8_t nd_opt_rti_len; 31278064Sume u_int8_t nd_opt_rti_prefixlen; 31378064Sume u_int8_t nd_opt_rti_flags; 31478064Sume u_int32_t nd_opt_rti_lifetime; 31578064Sume /* followed by prefix */ 31678064Sume} __attribute__((__packed__)); 31778539Ssumikawa 31862587Sitojun/* 31962587Sitojun * icmp6 namelookup 32062587Sitojun */ 32162587Sitojun 32262587Sitojunstruct icmp6_namelookup { 32362587Sitojun struct icmp6_hdr icmp6_nl_hdr; 32462587Sitojun u_int8_t icmp6_nl_nonce[8]; 32562587Sitojun int32_t icmp6_nl_ttl; 32662587Sitojun#if 0 32762587Sitojun u_int8_t icmp6_nl_len; 32862587Sitojun u_int8_t icmp6_nl_name[3]; 32962587Sitojun#endif 33062587Sitojun /* could be followed by options */ 33178064Sume} __attribute__((__packed__)); 33262587Sitojun 33362587Sitojun/* 33462587Sitojun * icmp6 node information 33562587Sitojun */ 33662587Sitojunstruct icmp6_nodeinfo { 33762587Sitojun struct icmp6_hdr icmp6_ni_hdr; 33862587Sitojun u_int8_t icmp6_ni_nonce[8]; 33962587Sitojun /* could be followed by reply data */ 34078064Sume} __attribute__((__packed__)); 34162587Sitojun 34262587Sitojun#define ni_type icmp6_ni_hdr.icmp6_type 34362587Sitojun#define ni_code icmp6_ni_hdr.icmp6_code 34462587Sitojun#define ni_cksum icmp6_ni_hdr.icmp6_cksum 34562587Sitojun#define ni_qtype icmp6_ni_hdr.icmp6_data16[0] 34662587Sitojun#define ni_flags icmp6_ni_hdr.icmp6_data16[1] 34762587Sitojun 34862587Sitojun#define NI_QTYPE_NOOP 0 /* NOOP */ 34962587Sitojun#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */ 35078064Sume#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */ 35178064Sume#define NI_QTYPE_DNSNAME 2 /* DNS Name */ 35278064Sume#define NI_QTYPE_NODEADDR 3 /* Node Addresses */ 35378064Sume#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */ 35462587Sitojun 35562587Sitojun#if BYTE_ORDER == BIG_ENDIAN 35662587Sitojun#define NI_SUPTYPE_FLAG_COMPRESS 0x1 35762587Sitojun#define NI_FQDN_FLAG_VALIDTTL 0x1 35862587Sitojun#elif BYTE_ORDER == LITTLE_ENDIAN 35962587Sitojun#define NI_SUPTYPE_FLAG_COMPRESS 0x0100 36062587Sitojun#define NI_FQDN_FLAG_VALIDTTL 0x0100 36162587Sitojun#endif 36262587Sitojun 36362587Sitojun#ifdef NAME_LOOKUPS_04 36462587Sitojun#if BYTE_ORDER == BIG_ENDIAN 36562587Sitojun#define NI_NODEADDR_FLAG_LINKLOCAL 0x1 36662587Sitojun#define NI_NODEADDR_FLAG_SITELOCAL 0x2 36762587Sitojun#define NI_NODEADDR_FLAG_GLOBAL 0x4 36862587Sitojun#define NI_NODEADDR_FLAG_ALL 0x8 36962587Sitojun#define NI_NODEADDR_FLAG_TRUNCATE 0x10 37062587Sitojun#define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */ 37162587Sitojun#elif BYTE_ORDER == LITTLE_ENDIAN 37262587Sitojun#define NI_NODEADDR_FLAG_LINKLOCAL 0x0100 37362587Sitojun#define NI_NODEADDR_FLAG_SITELOCAL 0x0200 37462587Sitojun#define NI_NODEADDR_FLAG_GLOBAL 0x0400 37562587Sitojun#define NI_NODEADDR_FLAG_ALL 0x0800 37662587Sitojun#define NI_NODEADDR_FLAG_TRUNCATE 0x1000 37762587Sitojun#define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */ 37862587Sitojun#endif 37962587Sitojun#else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */ 38062587Sitojun#if BYTE_ORDER == BIG_ENDIAN 38162587Sitojun#define NI_NODEADDR_FLAG_TRUNCATE 0x1 38262587Sitojun#define NI_NODEADDR_FLAG_ALL 0x2 38362587Sitojun#define NI_NODEADDR_FLAG_COMPAT 0x4 38462587Sitojun#define NI_NODEADDR_FLAG_LINKLOCAL 0x8 38562587Sitojun#define NI_NODEADDR_FLAG_SITELOCAL 0x10 38662587Sitojun#define NI_NODEADDR_FLAG_GLOBAL 0x20 38762587Sitojun#define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */ 38862587Sitojun#elif BYTE_ORDER == LITTLE_ENDIAN 38962587Sitojun#define NI_NODEADDR_FLAG_TRUNCATE 0x0100 39062587Sitojun#define NI_NODEADDR_FLAG_ALL 0x0200 39162587Sitojun#define NI_NODEADDR_FLAG_COMPAT 0x0400 39262587Sitojun#define NI_NODEADDR_FLAG_LINKLOCAL 0x0800 39362587Sitojun#define NI_NODEADDR_FLAG_SITELOCAL 0x1000 39462587Sitojun#define NI_NODEADDR_FLAG_GLOBAL 0x2000 39562587Sitojun#define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */ 39662587Sitojun#endif 39762587Sitojun#endif 39862587Sitojun 39962587Sitojunstruct ni_reply_fqdn { 40062587Sitojun u_int32_t ni_fqdn_ttl; /* TTL */ 40162587Sitojun u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */ 40262587Sitojun u_int8_t ni_fqdn_name[3]; /* XXX: alignment */ 40378064Sume} __attribute__((__packed__)); 40462587Sitojun 40562587Sitojun/* 40662587Sitojun * Router Renumbering. as router-renum-08.txt 40762587Sitojun */ 40862587Sitojunstruct icmp6_router_renum { /* router renumbering header */ 40962587Sitojun struct icmp6_hdr rr_hdr; 41062587Sitojun u_int8_t rr_segnum; 41162587Sitojun u_int8_t rr_flags; 41262587Sitojun u_int16_t rr_maxdelay; 41362587Sitojun u_int32_t rr_reserved; 41478064Sume} __attribute__((__packed__)); 41562587Sitojun 41678064Sume#define ICMP6_RR_FLAGS_TEST 0x80 41778064Sume#define ICMP6_RR_FLAGS_REQRESULT 0x40 41878064Sume#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20 41978064Sume#define ICMP6_RR_FLAGS_SPECSITE 0x10 42078064Sume#define ICMP6_RR_FLAGS_PREVDONE 0x08 42178064Sume 42262587Sitojun#define rr_type rr_hdr.icmp6_type 42362587Sitojun#define rr_code rr_hdr.icmp6_code 42462587Sitojun#define rr_cksum rr_hdr.icmp6_cksum 42562587Sitojun#define rr_seqnum rr_hdr.icmp6_data32[0] 42662587Sitojun 42762587Sitojunstruct rr_pco_match { /* match prefix part */ 42862587Sitojun u_int8_t rpm_code; 42962587Sitojun u_int8_t rpm_len; 43062587Sitojun u_int8_t rpm_ordinal; 43162587Sitojun u_int8_t rpm_matchlen; 43262587Sitojun u_int8_t rpm_minlen; 43362587Sitojun u_int8_t rpm_maxlen; 43462587Sitojun u_int16_t rpm_reserved; 43562587Sitojun struct in6_addr rpm_prefix; 43678064Sume} __attribute__((__packed__)); 43762587Sitojun 43862587Sitojun#define RPM_PCO_ADD 1 43962587Sitojun#define RPM_PCO_CHANGE 2 44062587Sitojun#define RPM_PCO_SETGLOBAL 3 44162587Sitojun#define RPM_PCO_MAX 4 44262587Sitojun 44362587Sitojunstruct rr_pco_use { /* use prefix part */ 44462587Sitojun u_int8_t rpu_uselen; 44562587Sitojun u_int8_t rpu_keeplen; 44662587Sitojun u_int8_t rpu_ramask; 44762587Sitojun u_int8_t rpu_raflags; 44862587Sitojun u_int32_t rpu_vltime; 44962587Sitojun u_int32_t rpu_pltime; 45062587Sitojun u_int32_t rpu_flags; 45162587Sitojun struct in6_addr rpu_prefix; 45278064Sume} __attribute__((__packed__)); 45362587Sitojun#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80 45462587Sitojun#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40 45562587Sitojun 45662587Sitojun#if BYTE_ORDER == BIG_ENDIAN 45762587Sitojun#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000 45862587Sitojun#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000 45962587Sitojun#elif BYTE_ORDER == LITTLE_ENDIAN 46062587Sitojun#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80 46162587Sitojun#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40 46262587Sitojun#endif 46362587Sitojun 46462587Sitojunstruct rr_result { /* router renumbering result message */ 46562587Sitojun u_int16_t rrr_flags; 46662587Sitojun u_int8_t rrr_ordinal; 46762587Sitojun u_int8_t rrr_matchedlen; 46862587Sitojun u_int32_t rrr_ifid; 46962587Sitojun struct in6_addr rrr_prefix; 47078064Sume} __attribute__((__packed__)); 47162587Sitojun#if BYTE_ORDER == BIG_ENDIAN 47262587Sitojun#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002 47362587Sitojun#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001 47462587Sitojun#elif BYTE_ORDER == LITTLE_ENDIAN 47578064Sume#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200 47678064Sume#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100 47762587Sitojun#endif 47862587Sitojun 47962587Sitojun/* 48062587Sitojun * icmp6 filter structures. 48162587Sitojun */ 48262587Sitojun 48362587Sitojunstruct icmp6_filter { 48462587Sitojun u_int32_t icmp6_filt[8]; 48562587Sitojun}; 48662587Sitojun 48762587Sitojun#ifdef _KERNEL 48862587Sitojun#define ICMP6_FILTER_SETPASSALL(filterp) \ 48962587Sitojundo { \ 49062587Sitojun int i; u_char *p; \ 49162587Sitojun p = (u_char *)filterp; \ 49262587Sitojun for (i = 0; i < sizeof(struct icmp6_filter); i++) \ 49362587Sitojun p[i] = 0xff; \ 49462587Sitojun} while (0) 49562587Sitojun#define ICMP6_FILTER_SETBLOCKALL(filterp) \ 49662587Sitojun bzero(filterp, sizeof(struct icmp6_filter)) 49762587Sitojun#else /* _KERNEL */ 49862587Sitojun#define ICMP6_FILTER_SETPASSALL(filterp) \ 49962587Sitojun memset(filterp, 0xff, sizeof(struct icmp6_filter)) 50062587Sitojun#define ICMP6_FILTER_SETBLOCKALL(filterp) \ 50162587Sitojun memset(filterp, 0x00, sizeof(struct icmp6_filter)) 50262587Sitojun#endif /* _KERNEL */ 50362587Sitojun 50462587Sitojun#define ICMP6_FILTER_SETPASS(type, filterp) \ 50562587Sitojun (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))) 50662587Sitojun#define ICMP6_FILTER_SETBLOCK(type, filterp) \ 50762587Sitojun (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))) 50862587Sitojun#define ICMP6_FILTER_WILLPASS(type, filterp) \ 50962587Sitojun ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0) 51062587Sitojun#define ICMP6_FILTER_WILLBLOCK(type, filterp) \ 51162587Sitojun ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0) 51262587Sitojun 51362587Sitojun/* 51462587Sitojun * Variables related to this implementation 51562587Sitojun * of the internet control message protocol version 6. 51662587Sitojun */ 51762587Sitojunstruct icmp6errstat { 51862587Sitojun u_quad_t icp6errs_dst_unreach_noroute; 51962587Sitojun u_quad_t icp6errs_dst_unreach_admin; 52062587Sitojun u_quad_t icp6errs_dst_unreach_beyondscope; 52162587Sitojun u_quad_t icp6errs_dst_unreach_addr; 52262587Sitojun u_quad_t icp6errs_dst_unreach_noport; 52362587Sitojun u_quad_t icp6errs_packet_too_big; 52462587Sitojun u_quad_t icp6errs_time_exceed_transit; 52562587Sitojun u_quad_t icp6errs_time_exceed_reassembly; 52662587Sitojun u_quad_t icp6errs_paramprob_header; 52762587Sitojun u_quad_t icp6errs_paramprob_nextheader; 52862587Sitojun u_quad_t icp6errs_paramprob_option; 52962587Sitojun u_quad_t icp6errs_redirect; /* we regard redirect as an error here */ 53062587Sitojun u_quad_t icp6errs_unknown; 53162587Sitojun}; 53262587Sitojun 53362587Sitojunstruct icmp6stat { 53462587Sitojun/* statistics related to icmp6 packets generated */ 53562587Sitojun u_quad_t icp6s_error; /* # of calls to icmp6_error */ 53662587Sitojun u_quad_t icp6s_canterror; /* no error 'cuz old was icmp */ 53762587Sitojun u_quad_t icp6s_toofreq; /* no error 'cuz rate limitation */ 53862587Sitojun u_quad_t icp6s_outhist[256]; 53962587Sitojun/* statistics related to input message processed */ 54062587Sitojun u_quad_t icp6s_badcode; /* icmp6_code out of range */ 54162587Sitojun u_quad_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */ 54262587Sitojun u_quad_t icp6s_checksum; /* bad checksum */ 54362587Sitojun u_quad_t icp6s_badlen; /* calculated bound mismatch */ 54462587Sitojun u_quad_t icp6s_reflect; /* number of responses */ 54562587Sitojun u_quad_t icp6s_inhist[256]; 54662587Sitojun u_quad_t icp6s_nd_toomanyopt; /* too many ND options */ 54762587Sitojun struct icmp6errstat icp6s_outerrhist; 54862587Sitojun#define icp6s_odst_unreach_noroute \ 54962587Sitojun icp6s_outerrhist.icp6errs_dst_unreach_noroute 55062587Sitojun#define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin 55162587Sitojun#define icp6s_odst_unreach_beyondscope \ 55262587Sitojun icp6s_outerrhist.icp6errs_dst_unreach_beyondscope 55362587Sitojun#define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr 55462587Sitojun#define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport 55562587Sitojun#define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big 55662587Sitojun#define icp6s_otime_exceed_transit \ 55762587Sitojun icp6s_outerrhist.icp6errs_time_exceed_transit 55862587Sitojun#define icp6s_otime_exceed_reassembly \ 55962587Sitojun icp6s_outerrhist.icp6errs_time_exceed_reassembly 56062587Sitojun#define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header 56162587Sitojun#define icp6s_oparamprob_nextheader \ 56262587Sitojun icp6s_outerrhist.icp6errs_paramprob_nextheader 56362587Sitojun#define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option 56462587Sitojun#define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect 56562587Sitojun#define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown 56678064Sume u_quad_t icp6s_pmtuchg; /* path MTU changes */ 56778064Sume u_quad_t icp6s_nd_badopt; /* bad ND options */ 56878064Sume u_quad_t icp6s_badns; /* bad neighbor solicitation */ 56978064Sume u_quad_t icp6s_badna; /* bad neighbor advertisement */ 57078064Sume u_quad_t icp6s_badrs; /* bad router advertisement */ 57178064Sume u_quad_t icp6s_badra; /* bad router advertisement */ 57278064Sume u_quad_t icp6s_badredirect; /* bad redirect message */ 57362587Sitojun}; 57462587Sitojun 57562587Sitojun/* 57662587Sitojun * Names for ICMP sysctl objects 57762587Sitojun */ 57862587Sitojun#define ICMPV6CTL_STATS 1 57962587Sitojun#define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */ 58062587Sitojun#define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */ 58178064Sume#if 0 /*obsoleted*/ 58262587Sitojun#define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */ 58378064Sume#endif 58462587Sitojun#define ICMPV6CTL_ND6_PRUNE 6 58562587Sitojun#define ICMPV6CTL_ND6_DELAY 8 58662587Sitojun#define ICMPV6CTL_ND6_UMAXTRIES 9 58762587Sitojun#define ICMPV6CTL_ND6_MMAXTRIES 10 58862587Sitojun#define ICMPV6CTL_ND6_USELOOPBACK 11 58962587Sitojun/*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */ 59062587Sitojun#define ICMPV6CTL_NODEINFO 13 59162587Sitojun#define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */ 59262587Sitojun#define ICMPV6CTL_ND6_MAXNUDHINT 15 59378064Sume#define ICMPV6CTL_MTUDISC_HIWAT 16 59478064Sume#define ICMPV6CTL_MTUDISC_LOWAT 17 59578064Sume#define ICMPV6CTL_ND6_DEBUG 18 59678064Sume#define ICMPV6CTL_ND6_DRLIST 19 59778064Sume#define ICMPV6CTL_ND6_PRLIST 20 59878064Sume#define ICMPV6CTL_MAXID 21 59962587Sitojun 60062587Sitojun#define ICMPV6CTL_NAMES { \ 60162587Sitojun { 0, 0 }, \ 60262587Sitojun { 0, 0 }, \ 60362587Sitojun { "rediraccept", CTLTYPE_INT }, \ 60462587Sitojun { "redirtimeout", CTLTYPE_INT }, \ 60562587Sitojun { 0, 0 }, \ 60678064Sume { 0, 0 }, \ 60762587Sitojun { "nd6_prune", CTLTYPE_INT }, \ 60862587Sitojun { 0, 0 }, \ 60962587Sitojun { "nd6_delay", CTLTYPE_INT }, \ 61062587Sitojun { "nd6_umaxtries", CTLTYPE_INT }, \ 61162587Sitojun { "nd6_mmaxtries", CTLTYPE_INT }, \ 61262587Sitojun { "nd6_useloopback", CTLTYPE_INT }, \ 61362587Sitojun { 0, 0 }, \ 61462587Sitojun { "nodeinfo", CTLTYPE_INT }, \ 61562587Sitojun { "errppslimit", CTLTYPE_INT }, \ 61662587Sitojun { "nd6_maxnudhint", CTLTYPE_INT }, \ 61778064Sume { "mtudisc_hiwat", CTLTYPE_INT }, \ 61878064Sume { "mtudisc_lowat", CTLTYPE_INT }, \ 61978064Sume { "nd6_debug", CTLTYPE_INT }, \ 62078064Sume { 0, 0 }, \ 62178064Sume { 0, 0 }, \ 62262587Sitojun} 62362587Sitojun 62462587Sitojun#define RTF_PROBEMTU RTF_PROTO1 62562587Sitojun 62662587Sitojun#ifdef _KERNEL 62762587Sitojun# ifdef __STDC__ 62862587Sitojunstruct rtentry; 62962587Sitojunstruct rttimer; 63062587Sitojunstruct in6_multi; 63162587Sitojun# endif 63262587Sitojunvoid icmp6_init __P((void)); 63362587Sitojunvoid icmp6_paramerror __P((struct mbuf *, int)); 63462587Sitojunvoid icmp6_error __P((struct mbuf *, int, int, int)); 63562587Sitojunint icmp6_input __P((struct mbuf **, int *, int)); 63662587Sitojunvoid icmp6_fasttimo __P((void)); 63762587Sitojunvoid icmp6_reflect __P((struct mbuf *, size_t)); 63862587Sitojunvoid icmp6_prepare __P((struct mbuf *)); 63962587Sitojunvoid icmp6_redirect_input __P((struct mbuf *, int)); 64062587Sitojunvoid icmp6_redirect_output __P((struct mbuf *, struct rtentry *)); 64162587Sitojun 64278064Sumestruct ip6ctlparam; 64378064Sumevoid icmp6_mtudisc_update __P((struct ip6ctlparam *, int)); 64478064Sume 64562587Sitojun/* XXX: is this the right place for these macros? */ 64662587Sitojun#define icmp6_ifstat_inc(ifp, tag) \ 64762587Sitojundo { \ 64862587Sitojun if ((ifp) && (ifp)->if_index <= if_index \ 64962587Sitojun && (ifp)->if_index < icmp6_ifstatmax \ 65062587Sitojun && icmp6_ifstat && icmp6_ifstat[(ifp)->if_index]) { \ 65162587Sitojun icmp6_ifstat[(ifp)->if_index]->tag++; \ 65262587Sitojun } \ 65362587Sitojun} while (0) 65462587Sitojun 65562587Sitojun#define icmp6_ifoutstat_inc(ifp, type, code) \ 65662587Sitojundo { \ 65762587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_msg); \ 65862587Sitojun if (type < ICMP6_INFOMSG_MASK) \ 65962587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_error); \ 66062587Sitojun switch(type) { \ 66162587Sitojun case ICMP6_DST_UNREACH: \ 66262587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \ 66362587Sitojun if (code == ICMP6_DST_UNREACH_ADMIN) \ 66462587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \ 66562587Sitojun break; \ 66662587Sitojun case ICMP6_PACKET_TOO_BIG: \ 66762587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \ 66862587Sitojun break; \ 66962587Sitojun case ICMP6_TIME_EXCEEDED: \ 67062587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \ 67162587Sitojun break; \ 67262587Sitojun case ICMP6_PARAM_PROB: \ 67362587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \ 67462587Sitojun break; \ 67562587Sitojun case ICMP6_ECHO_REQUEST: \ 67662587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_echo); \ 67762587Sitojun break; \ 67862587Sitojun case ICMP6_ECHO_REPLY: \ 67962587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \ 68062587Sitojun break; \ 68162587Sitojun case MLD6_LISTENER_QUERY: \ 68262587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \ 68362587Sitojun break; \ 68462587Sitojun case MLD6_LISTENER_REPORT: \ 68562587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \ 68662587Sitojun break; \ 68762587Sitojun case MLD6_LISTENER_DONE: \ 68862587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \ 68962587Sitojun break; \ 69062587Sitojun case ND_ROUTER_SOLICIT: \ 69162587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \ 69262587Sitojun break; \ 69362587Sitojun case ND_ROUTER_ADVERT: \ 69462587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \ 69562587Sitojun break; \ 69662587Sitojun case ND_NEIGHBOR_SOLICIT: \ 69762587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \ 69862587Sitojun break; \ 69962587Sitojun case ND_NEIGHBOR_ADVERT: \ 70062587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \ 70162587Sitojun break; \ 70262587Sitojun case ND_REDIRECT: \ 70362587Sitojun icmp6_ifstat_inc(ifp, ifs6_out_redirect); \ 70462587Sitojun break; \ 70562587Sitojun } \ 70662587Sitojun} while (0) 70762587Sitojun 70862587Sitojunextern int icmp6_rediraccept; /* accept/process redirects */ 70962587Sitojunextern int icmp6_redirtimeout; /* cache time for redirect routes */ 71062587Sitojun#endif /* _KERNEL */ 71162587Sitojun 71262587Sitojun#endif /* not _NETINET_ICMP6_H_ */ 713