icmp6.h revision 57120
1194179Sed/* 2194179Sed * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3194179Sed * All rights reserved. 4194179Sed * 5194179Sed * Redistribution and use in source and binary forms, with or without 6194179Sed * modification, are permitted provided that the following conditions 7194179Sed * are met: 8194179Sed * 1. Redistributions of source code must retain the above copyright 9194179Sed * notice, this list of conditions and the following disclaimer. 10194179Sed * 2. Redistributions in binary form must reproduce the above copyright 11194179Sed * notice, this list of conditions and the following disclaimer in the 12194179Sed * documentation and/or other materials provided with the distribution. 13194179Sed * 3. Neither the name of the project nor the names of its contributors 14194179Sed * may be used to endorse or promote products derived from this software 15194179Sed * without specific prior written permission. 16194179Sed * 17194179Sed * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 18194179Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19194179Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20194179Sed * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 21194179Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22194179Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23194179Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24194179Sed * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25194179Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26194179Sed * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27194179Sed * SUCH DAMAGE. 28263509Sdim * 29194179Sed * $FreeBSD: head/sys/netinet6/icmp6.h 57120 2000-02-10 19:33:58Z shin $ 30194179Sed */ 31194179Sed 32194179Sed/* 33218893Sdim * Copyright (c) 1982, 1986, 1993 34218893Sdim * The Regents of the University of California. All rights reserved. 35252723Sdim * 36194179Sed * Redistribution and use in source and binary forms, with or without 37194179Sed * modification, are permitted provided that the following conditions 38245431Sdim * are met: 39245431Sdim * 1. Redistributions of source code must retain the above copyright 40198092Srdivacky * notice, this list of conditions and the following disclaimer. 41226890Sdim * 2. Redistributions in binary form must reproduce the above copyright 42194179Sed * notice, this list of conditions and the following disclaimer in the 43198092Srdivacky * documentation and/or other materials provided with the distribution. 44198092Srdivacky * 3. All advertising materials mentioning features or use of this software 45229041Sdim * must display the following acknowledgement: 46245431Sdim * This product includes software developed by the University of 47194179Sed * California, Berkeley and its contributors. 48194179Sed * 4. Neither the name of the University nor the names of its contributors 49218893Sdim * may be used to endorse or promote products derived from this software 50194179Sed * without specific prior written permission. 51194179Sed * 52194179Sed * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 53194179Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 54194179Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 55218893Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 56194179Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 57194179Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 58205219Srdivacky * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 59205219Srdivacky * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 60194179Sed * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61203955Srdivacky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62194179Sed * SUCH DAMAGE. 63194179Sed * 64194179Sed * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 65194179Sed */ 66194179Sed 67198092Srdivacky#ifndef _NETINET6_ICMPV6_H_ 68194179Sed#define _NETINET6_ICMPV6_H_ 69219077Sdim 70194179Sed#if !defined(_KERNEL) && !defined(__KAME_NETINET_ICMP6_H_INCLUDED_) 71194179Sed#error "do not include netinet6/icmp6.h directly, include netinet/icmp6.h" 72194179Sed#endif 73194179Sed 74252723Sdim#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr) 75252723Sdim - sizeof(struct icmp6_hdr) */ 76198092Srdivacky 77194179Sedstruct icmp6_hdr { 78194179Sed u_int8_t icmp6_type; /* type field */ 79198092Srdivacky u_int8_t icmp6_code; /* code field */ 80194179Sed u_int16_t icmp6_cksum; /* checksum field */ 81212904Sdim union { 82212904Sdim u_int32_t icmp6_un_data32[1]; /* type-specific field */ 83212904Sdim u_int16_t icmp6_un_data16[2]; /* type-specific field */ 84212904Sdim u_int8_t icmp6_un_data8[4]; /* type-specific field */ 85212904Sdim } icmp6_dataun; 86194179Sed}; 87226890Sdim 88252723Sdim#define icmp6_data32 icmp6_dataun.icmp6_un_data32 89194179Sed#define icmp6_data16 icmp6_dataun.icmp6_un_data16 90194179Sed#define icmp6_data8 icmp6_dataun.icmp6_un_data8 91194179Sed#define icmp6_pptr icmp6_data32[0] /* parameter prob */ 92218893Sdim#define icmp6_mtu icmp6_data32[0] /* packet too big */ 93194179Sed#define icmp6_id icmp6_data16[0] /* echo request/reply */ 94194179Sed#define icmp6_seq icmp6_data16[1] /* echo request/reply */ 95263509Sdim#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ 96263509Sdim 97263509Sdim#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */ 98263509Sdim#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */ 99194179Sed#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */ 100201361Srdivacky#define ICMP6_PARAM_PROB 4 /* ip6 header bad */ 101201361Srdivacky 102201361Srdivacky#define ICMP6_ECHO_REQUEST 128 /* echo service */ 103198092Srdivacky#define ICMP6_ECHO_REPLY 129 /* echo reply */ 104198092Srdivacky#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */ 105198092Srdivacky#define MLD6_LISTENER_QUERY 130 /* multicast listener query */ 106198092Srdivacky#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */ 107198092Srdivacky#define MLD6_LISTENER_REPORT 131 /* multicast listener report */ 108198092Srdivacky#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */ 109198092Srdivacky#define MLD6_LISTENER_DONE 132 /* multicast listener done */ 110201361Srdivacky 111201361Srdivacky#define ND_ROUTER_SOLICIT 133 /* router solicitation */ 112201361Srdivacky#define ND_ROUTER_ADVERT 134 /* router advertisment */ 113226890Sdim#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */ 114226890Sdim#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */ 115226890Sdim#define ND_REDIRECT 137 /* redirect */ 116194179Sed 117194179Sed#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */ 118194179Sed 119194179Sed#define ICMP6_WRUREQUEST 139 /* who are you request */ 120194179Sed#define ICMP6_WRUREPLY 140 /* who are you reply */ 121194179Sed#define ICMP6_FQDN_QUERY 139 /* FQDN query */ 122235633Sdim#define ICMP6_FQDN_REPLY 140 /* FQDN reply */ 123235633Sdim#define ICMP6_NI_QUERY 139 /* node information request */ 124201361Srdivacky#define ICMP6_NI_REPLY 140 /* node information reply */ 125201361Srdivacky 126201361Srdivacky/* The definitions below are experimental. TBA */ 127226890Sdim#define MLD6_MTRACE_RESP 141 /* mtrace response(to sender) */ 128226890Sdim#define MLD6_MTRACE 142 /* mtrace messages */ 129226890Sdim 130194179Sed#define ICMP6_MAXTYPE 142 131194179Sed 132194179Sed#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ 133194179Sed#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */ 134194179Sed#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */ 135194179Sed#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */ 136201361Srdivacky#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ 137201361Srdivacky#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */ 138201361Srdivacky 139201361Srdivacky#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */ 140201361Srdivacky#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */ 141201361Srdivacky 142194179Sed#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ 143198092Srdivacky#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */ 144200583Srdivacky#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */ 145200583Srdivacky 146200583Srdivacky#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ 147218893Sdim 148218893Sdim#define ICMP6_NI_SUCESS 0 /* node information successful reply */ 149218893Sdim#define ICMP6_NI_REFUSED 1 /* node information request is refused */ 150200583Srdivacky#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */ 151200583Srdivacky 152200583Srdivacky#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */ 153218893Sdim#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */ 154218893Sdim#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */ 155218893Sdim 156200583Srdivacky/* Used in kernel only */ 157200583Srdivacky#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */ 158200583Srdivacky#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */ 159218893Sdim 160218893Sdim/* 161218893Sdim * Multicast Listener Discovery 162218893Sdim */ 163218893Sdimstruct mld6_hdr { 164218893Sdim struct icmp6_hdr mld6_hdr; 165200583Srdivacky struct in6_addr mld6_addr; /* multicast address */ 166200583Srdivacky}; 167200583Srdivacky 168200583Srdivacky#define mld6_type mld6_hdr.icmp6_type 169200583Srdivacky#define mld6_code mld6_hdr.icmp6_code 170200583Srdivacky#define mld6_cksum mld6_hdr.icmp6_cksum 171200583Srdivacky#define mld6_maxdelay mld6_hdr.icmp6_data16[0] 172200583Srdivacky#define mld6_reserved mld6_hdr.icmp6_data16[1] 173200583Srdivacky 174218893Sdim/* 175218893Sdim * Neighbor Discovery 176218893Sdim */ 177218893Sdim 178218893Sdimstruct nd_router_solicit { /* router solicitation */ 179218893Sdim struct icmp6_hdr nd_rs_hdr; 180200583Srdivacky /* could be followed by options */ 181200583Srdivacky}; 182200583Srdivacky 183218893Sdim#define nd_rs_type nd_rs_hdr.icmp6_type 184218893Sdim#define nd_rs_code nd_rs_hdr.icmp6_code 185218893Sdim#define nd_rs_cksum nd_rs_hdr.icmp6_cksum 186218893Sdim#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] 187218893Sdim 188218893Sdimstruct nd_router_advert { /* router advertisement */ 189218893Sdim struct icmp6_hdr nd_ra_hdr; 190218893Sdim u_int32_t nd_ra_reachable; /* reachable time */ 191218893Sdim u_int32_t nd_ra_retransmit; /* retransmit timer */ 192200583Srdivacky /* could be followed by options */ 193200583Srdivacky}; 194200583Srdivacky 195218893Sdim#define nd_ra_type nd_ra_hdr.icmp6_type 196218893Sdim#define nd_ra_code nd_ra_hdr.icmp6_code 197218893Sdim#define nd_ra_cksum nd_ra_hdr.icmp6_cksum 198218893Sdim#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] 199218893Sdim#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] 200218893Sdim#define ND_RA_FLAG_MANAGED 0x80 201218893Sdim#define ND_RA_FLAG_OTHER 0x40 202218893Sdim#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] 203218893Sdim 204201361Srdivackystruct nd_neighbor_solicit { /* neighbor solicitation */ 205201361Srdivacky struct icmp6_hdr nd_ns_hdr; 206201361Srdivacky struct in6_addr nd_ns_target; /*target address */ 207218893Sdim /* could be followed by options */ 208218893Sdim}; 209218893Sdim 210218893Sdim#define nd_ns_type nd_ns_hdr.icmp6_type 211218893Sdim#define nd_ns_code nd_ns_hdr.icmp6_code 212218893Sdim#define nd_ns_cksum nd_ns_hdr.icmp6_cksum 213218893Sdim#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] 214218893Sdim 215218893Sdimstruct nd_neighbor_advert { /* neighbor advertisement */ 216218893Sdim struct icmp6_hdr nd_na_hdr; 217218893Sdim struct in6_addr nd_na_target; /* target address */ 218218893Sdim /* could be followed by options */ 219200583Srdivacky}; 220200583Srdivacky 221200583Srdivacky#define nd_na_type nd_na_hdr.icmp6_type 222200583Srdivacky#define nd_na_code nd_na_hdr.icmp6_code 223218893Sdim#define nd_na_cksum nd_na_hdr.icmp6_cksum 224218893Sdim#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] 225218893Sdim#if BYTE_ORDER == BIG_ENDIAN 226218893Sdim#define ND_NA_FLAG_ROUTER 0x80000000 227218893Sdim#define ND_NA_FLAG_SOLICITED 0x40000000 228218893Sdim#define ND_NA_FLAG_OVERRIDE 0x20000000 229218893Sdim#elif BYTE_ORDER == LITTLE_ENDIAN 230218893Sdim#define ND_NA_FLAG_ROUTER 0x80 231218893Sdim#define ND_NA_FLAG_SOLICITED 0x40 232200583Srdivacky#define ND_NA_FLAG_OVERRIDE 0x20 233200583Srdivacky#endif 234218893Sdim 235218893Sdimstruct nd_redirect { /* redirect */ 236218893Sdim struct icmp6_hdr nd_rd_hdr; 237218893Sdim struct in6_addr nd_rd_target; /* target address */ 238218893Sdim struct in6_addr nd_rd_dst; /* destination address */ 239218893Sdim /* could be followed by options */ 240218893Sdim}; 241218893Sdim 242218893Sdim#define nd_rd_type nd_rd_hdr.icmp6_type 243218893Sdim#define nd_rd_code nd_rd_hdr.icmp6_code 244218893Sdim#define nd_rd_cksum nd_rd_hdr.icmp6_cksum 245218893Sdim#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] 246263509Sdim 247263509Sdimstruct nd_opt_hdr { /* Neighbor discovery option header */ 248218893Sdim u_int8_t nd_opt_type; 249218893Sdim u_int8_t nd_opt_len; 250218893Sdim /* followed by option specific data*/ 251218893Sdim}; 252226890Sdim 253226890Sdim#define ND_OPT_SOURCE_LINKADDR 1 254226890Sdim#define ND_OPT_TARGET_LINKADDR 2 255218893Sdim#define ND_OPT_PREFIX_INFORMATION 3 256218893Sdim#define ND_OPT_REDIRECTED_HEADER 4 257218893Sdim#define ND_OPT_MTU 5 258218893Sdim 259218893Sdimstruct nd_opt_prefix_info { /* prefix information */ 260218893Sdim u_int8_t nd_opt_pi_type; 261218893Sdim u_int8_t nd_opt_pi_len; 262218893Sdim u_int8_t nd_opt_pi_prefix_len; 263218893Sdim u_int8_t nd_opt_pi_flags_reserved; 264218893Sdim u_int32_t nd_opt_pi_valid_time; 265218893Sdim u_int32_t nd_opt_pi_preferred_time; 266218893Sdim u_int32_t nd_opt_pi_reserved2; 267200583Srdivacky struct in6_addr nd_opt_pi_prefix; 268200583Srdivacky}; 269200583Srdivacky 270200583Srdivacky#define ND_OPT_PI_FLAG_ONLINK 0x80 271200583Srdivacky#define ND_OPT_PI_FLAG_AUTO 0x40 272200583Srdivacky 273200583Srdivackystruct nd_opt_rd_hdr { /* redirected header */ 274200583Srdivacky u_int8_t nd_opt_rh_type; 275200583Srdivacky u_int8_t nd_opt_rh_len; 276200583Srdivacky u_int16_t nd_opt_rh_reserved1; 277200583Srdivacky u_int32_t nd_opt_rh_reserved2; 278200583Srdivacky /* followed by IP header and data */ 279200583Srdivacky}; 280200583Srdivacky 281200583Srdivackystruct nd_opt_mtu { /* MTU option */ 282218893Sdim u_int8_t nd_opt_mtu_type; 283218893Sdim u_int8_t nd_opt_mtu_len; 284218893Sdim u_int16_t nd_opt_mtu_reserved; 285218893Sdim u_int32_t nd_opt_mtu_mtu; 286218893Sdim}; 287218893Sdim 288198092Srdivacky/* 289198092Srdivacky * icmp6 namelookup 290198092Srdivacky */ 291198092Srdivacky 292198092Srdivackystruct icmp6_namelookup { 293198092Srdivacky struct icmp6_hdr icmp6_nl_hdr; 294198092Srdivacky u_int64_t icmp6_nl_nonce; 295218893Sdim u_int32_t icmp6_nl_ttl; 296218893Sdim /* could be followed by options */ 297218893Sdim}; 298198092Srdivacky 299198092Srdivacky/* 300198092Srdivacky * icmp6 node information 301198092Srdivacky */ 302198092Srdivackystruct icmp6_nodeinfo { 303198092Srdivacky struct icmp6_hdr icmp6_ni_hdr; 304218893Sdim u_int64_t icmp6_ni_nonce; 305218893Sdim /* could be followed by reply data */ 306218893Sdim}; 307198092Srdivacky 308198092Srdivacky#define ni_type icmp6_ni_hdr.icmp6_type 309198092Srdivacky#define ni_code icmp6_ni_hdr.icmp6_code 310218893Sdim#define ni_cksum icmp6_ni_hdr.icmp6_cksum 311218893Sdim#define ni_qtype icmp6_ni_hdr.icmp6_data16[0] 312218893Sdim#define ni_flags icmp6_ni_hdr.icmp6_data16[1] 313198092Srdivacky 314198092Srdivacky 315198092Srdivacky#define NI_QTYPE_NOOP 0 /* NOOP */ 316198092Srdivacky#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */ 317198092Srdivacky#define NI_QTYPE_FQDN 2 /* FQDN */ 318198092Srdivacky#define NI_QTYPE_NODEADDR 3 /* Node Addresses. XXX: spec says 2, but it may be a typo... */ 319198092Srdivacky 320198092Srdivacky#if BYTE_ORDER == BIG_ENDIAN 321198092Srdivacky#define NI_SUPTYPE_FLAG_COMPRESS 0x1 322198092Srdivacky#define NI_FQDN_FLAG_VALIDTTL 0x1 323198092Srdivacky#define NI_NODEADDR_FLAG_LINKLOCAL 0x1 324198092Srdivacky#define NI_NODEADDR_FLAG_SITELOCAL 0x2 325198092Srdivacky#define NI_NODEADDR_FLAG_GLOBAL 0x4 326212904Sdim#define NI_NODEADDR_FLAG_ALL 0x8 327212904Sdim#define NI_NODEADDR_FLAG_TRUNCATE 0x10 328212904Sdim#define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */ 329198092Srdivacky#elif BYTE_ORDER == LITTLE_ENDIAN 330198092Srdivacky#define NI_SUPTYPE_FLAG_COMPRESS 0x0100 331198092Srdivacky#define NI_FQDN_FLAG_VALIDTTL 0x0100 332198092Srdivacky#define NI_NODEADDR_FLAG_LINKLOCAL 0x0100 333198092Srdivacky#define NI_NODEADDR_FLAG_SITELOCAL 0x0200 334198092Srdivacky#define NI_NODEADDR_FLAG_GLOBAL 0x0400 335198092Srdivacky#define NI_NODEADDR_FLAG_ALL 0x0800 336198092Srdivacky#define NI_NODEADDR_FLAG_TRUNCATE 0x1000 337198092Srdivacky#define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */ 338198092Srdivacky#endif 339198092Srdivacky 340198092Srdivackystruct ni_reply_fqdn { 341198092Srdivacky u_int32_t ni_fqdn_ttl; /* TTL */ 342198092Srdivacky u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */ 343198092Srdivacky u_int8_t ni_fqdn_name[3]; /* XXX: alignment */ 344198092Srdivacky}; 345198092Srdivacky 346198092Srdivacky/* 347198092Srdivacky * Router Renumbering. as router-renum-08.txt 348198092Srdivacky */ 349198092Srdivackystruct icmp6_router_renum { /* router renumbering header */ 350198092Srdivacky struct icmp6_hdr rr_hdr; 351198092Srdivacky u_int8_t rr_segnum; 352198092Srdivacky u_int8_t rr_flags; 353198092Srdivacky u_int16_t rr_maxdelay; 354198092Srdivacky u_int32_t rr_reserved; 355198092Srdivacky}; 356198092Srdivacky#define ICMP6_RR_FLAGS_SEGNUM 0x80 357194179Sed#define ICMP6_RR_FLAGS_TEST 0x40 358194179Sed#define ICMP6_RR_FLAGS_REQRESULT 0x20 359194179Sed#define ICMP6_RR_FLAGS_FORCEAPPLY 0x10 360194179Sed#define ICMP6_RR_FLAGS_SPECSITE 0x08 361194179Sed#define ICMP6_RR_FLAGS_PREVDONE 0x04 362194179Sed 363194179Sed#define rr_type rr_hdr.icmp6_type 364194179Sed#define rr_code rr_hdr.icmp6_code 365198092Srdivacky#define rr_cksum rr_hdr.icmp6_cksum 366203955Srdivacky#define rr_seqnum rr_hdr.icmp6_data32[0] 367198092Srdivacky 368198092Srdivackystruct rr_pco_match { /* match prefix part */ 369198092Srdivacky u_int8_t rpm_code; 370198092Srdivacky u_int8_t rpm_len; 371198092Srdivacky u_int8_t rpm_ordinal; 372198092Srdivacky u_int8_t rpm_matchlen; 373204793Srdivacky u_int8_t rpm_minlen; 374204793Srdivacky u_int8_t rpm_maxlen; 375204793Srdivacky u_int16_t rpm_reserved; 376204793Srdivacky struct in6_addr rpm_prefix; 377204793Srdivacky}; 378194179Sed 379235633Sdim#define RPM_PCO_ADD 1 380194179Sed#define RPM_PCO_CHANGE 2 381194179Sed#define RPM_PCO_SETGLOBAL 3 382194179Sed 383194179Sedstruct rr_pco_use { /* use prefix part */ 384235633Sdim u_int8_t rpu_uselen; 385194179Sed u_int8_t rpu_keeplen; 386194179Sed u_int8_t rpu_ramask; 387194179Sed u_int8_t rpu_raflags; 388194179Sed u_int32_t rpu_vltime; 389245431Sdim u_int32_t rpu_pltime; 390245431Sdim u_int32_t rpu_flags; 391245431Sdim struct in6_addr rpu_prefix; 392194179Sed}; 393194179Sed#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80 394194179Sed#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40 395194179Sed 396194179Sed#if BYTE_ORDER == BIG_ENDIAN 397194179Sed#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000 398194179Sed#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000 399194179Sed#elif BYTE_ORDER == LITTLE_ENDIAN 400194179Sed#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80 401245431Sdim#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40 402194179Sed#endif 403194179Sed 404194179Sedstruct rr_result { /* router renumbering result message */ 405194179Sed u_int16_t rrr_flags; 406252723Sdim u_int8_t rrr_ordinal; 407252723Sdim u_int8_t rrr_matchedlen; 408194179Sed u_int32_t rrr_ifid; 409202879Srdivacky struct in6_addr rrr_prefix; 410226890Sdim}; 411194179Sed#if BYTE_ORDER == BIG_ENDIAN 412194179Sed#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002 413194179Sed#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001 414194179Sed#elif BYTE_ORDER == LITTLE_ENDIAN 415194179Sed#define ICMP6_RR_RESULT_FLAGS_OOB 0x02 416203955Srdivacky#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x01 417212904Sdim#endif 418198092Srdivacky 419194179Sed/* 420194179Sed * icmp6 filter structures. 421194179Sed */ 422194179Sed 423194179Sedstruct icmp6_filter { 424212904Sdim u_int32_t icmp6_filter[8]; 425194179Sed}; 426194179Sed 427194179Sed#ifdef _KERNEL 428194179Sed#define ICMP6_FILTER_SETPASSALL(filterp) \ 429194179Sed { \ 430194179Sed int i; u_char *p; \ 431194179Sed p = (u_char *)filterp; \ 432194179Sed for (i = 0; i < sizeof(struct icmp6_filter); i++) \ 433194179Sed p[i] = 0xff; \ 434194179Sed } 435194179Sed#define ICMP6_FILTER_SETBLOCKALL(filterp) \ 436194179Sed bzero(filterp, sizeof(struct icmp6_filter)) 437194179Sed#else /* _KERNEL */ 438194179Sed#define ICMP6_FILTER_SETPASSALL(filterp) \ 439194179Sed memset(filterp, 0xff, sizeof(struct icmp6_filter)) 440194179Sed#define ICMP6_FILTER_SETBLOCKALL(filterp) \ 441194179Sed memset(filterp, 0x00, sizeof(struct icmp6_filter)) 442194179Sed#endif /* _KERNEL */ 443194179Sed 444218893Sdim#define ICMP6_FILTER_SETPASS(type, filterp) \ 445194179Sed (((filterp)->icmp6_filter[(type) >> 5]) |= (1 << ((type) & 31))) 446218893Sdim#define ICMP6_FILTER_SETBLOCK(type, filterp) \ 447194179Sed (((filterp)->icmp6_filter[(type) >> 5]) &= ~(1 << ((type) & 31))) 448226890Sdim#define ICMP6_FILTER_WILLPASS(type, filterp) \ 449203955Srdivacky ((((filterp)->icmp6_filter[(type) >> 5]) & (1 << ((type) & 31))) != 0) 450194179Sed#define ICMP6_FILTER_WILLBLOCK(type, filterp) \ 451218893Sdim ((((filterp)->icmp6_filter[(type) >> 5]) & (1 << ((type) & 31))) == 0) 452210299Sed 453207619Srdivacky/* 454198092Srdivacky * Variables related to this implementation 455194179Sed * of the internet control message protocol version 6. 456203955Srdivacky */ 457212904Sdimstruct icmp6stat { 458203955Srdivacky/* statistics related to icmp6 packets generated */ 459203955Srdivacky u_long icp6s_error; /* # of calls to icmp6_error */ 460203955Srdivacky u_long icp6s_canterror; /* no error 'cuz old was icmp */ 461203955Srdivacky u_long icp6s_toofreq; /* no error 'cuz rate limitation */ 462204643Srdivacky u_long icp6s_outhist[256]; 463203955Srdivacky/* statistics related to input messages proccesed */ 464194179Sed u_long icp6s_badcode; /* icmp6_code out of range */ 465252723Sdim u_long icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */ 466194179Sed u_long icp6s_checksum; /* bad checksum */ 467252723Sdim u_long icp6s_badlen; /* calculated bound mismatch */ 468194179Sed u_long icp6s_reflect; /* number of responses */ 469194179Sed u_long icp6s_inhist[256]; 470194179Sed}; 471194179Sed 472194179Sed/* 473194179Sed * Names for ICMP sysctl objects 474252723Sdim */ 475252723Sdim#define ICMPV6CTL_STATS 1 476194179Sed#define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */ 477194179Sed#define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */ 478207619Srdivacky#define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */ 479194179Sed#define ICMPV6CTL_ND6_PRUNE 6 480194179Sed#define ICMPV6CTL_ND6_DELAY 8 481194179Sed#define ICMPV6CTL_ND6_UMAXTRIES 9 482194179Sed#define ICMPV6CTL_ND6_MMAXTRIES 10 483194179Sed#define ICMPV6CTL_ND6_USELOOPBACK 11 484194179Sed#define ICMPV6CTL_ND6_PROXYALL 12 485194179Sed#define ICMPV6CTL_MAXID 13 486194179Sed 487194179Sed#define ICMPV6CTL_NAMES { \ 488198893Srdivacky { 0, 0 }, \ 489194179Sed { 0, 0 }, \ 490245431Sdim { "rediraccept", CTLTYPE_INT }, \ 491198092Srdivacky { "redirtimeout", CTLTYPE_INT }, \ 492245431Sdim { 0, 0 }, \ 493198092Srdivacky { "errratelimit", CTLTYPE_INT }, \ 494194179Sed { "nd6_prune", CTLTYPE_INT }, \ 495263509Sdim { 0, 0 }, \ 496194179Sed { "nd6_delay", CTLTYPE_INT }, \ 497194179Sed { "nd6_umaxtries", CTLTYPE_INT }, \ 498194179Sed { "nd6_mmaxtries", CTLTYPE_INT }, \ 499194179Sed { "nd6_useloopback", CTLTYPE_INT }, \ 500194179Sed { "nd6_proxyall", CTLTYPE_INT }, \ 501194179Sed} 502194179Sed 503194179Sed#define ICMPV6CTL_VARS { \ 504194179Sed 0, \ 505194179Sed 0, \ 506229039Sdim &icmp6_rediraccept, \ 507229039Sdim &icmp6_redirtimeout, \ 508229039Sdim 0, \ 509229039Sdim 0, \ 510229039Sdim &icmp6errratelim, \ 511229039Sdim &nd6_prune, \ 512194179Sed 0, \ 513229039Sdim &nd6_delay, \ 514229039Sdim &nd6_umaxtries, \ 515229039Sdim &nd6_mmaxtries, \ 516229039Sdim &nd6_useloopback, \ 517229039Sdim &nd6_proxyall, \ 518229039Sdim} 519194179Sed 520229039Sdim#define RTF_PROBEMTU RTF_PROTO1 521229039Sdim 522229039Sdim#ifdef _KERNEL 523229039Sdim#ifdef SYSCTL_DECL 524229039SdimSYSCTL_DECL(_net_inet6_icmp6); 525229039Sdim#endif 526194179Sed# ifdef __STDC__ 527229039Sdimstruct rtentry; 528229039Sdimstruct rttimer; 529229039Sdimstruct in6_multi; 530229039Sdim# endif 531229039Sdimvoid icmp6_init __P((void)); 532229039Sdimvoid icmp6_paramerror __P((struct mbuf *, int)); 533194179Sedvoid icmp6_error __P((struct mbuf *, int, int, int)); 534229039Sdimint icmp6_input __P((struct mbuf **, int *, int)); 535229039Sdimvoid icmp6_fasttimo __P((void)); 536229039Sdimvoid icmp6_reflect __P((struct mbuf *, size_t)); 537229039Sdimvoid icmp6_prepare __P((struct mbuf *)); 538229039Sdimvoid icmp6_redirect_input __P((struct mbuf *, int)); 539229039Sdimvoid icmp6_redirect_output __P((struct mbuf *, struct rtentry *)); 540194179Sed 541194179Sed/* XXX: is this the right place for these macros? */ 542229039Sdim#define icmp6_ifstat_inc(ifp, tag) \ 543229039Sdimdo { \ 544229039Sdim if ((ifp) && (ifp)->if_index <= if_index \ 545229039Sdim && (ifp)->if_index < icmp6_ifstatmax \ 546229039Sdim && icmp6_ifstat && icmp6_ifstat[(ifp)->if_index]) { \ 547229039Sdim icmp6_ifstat[(ifp)->if_index]->tag++; \ 548194179Sed } \ 549229039Sdim} while (0) 550229039Sdim 551229039Sdim#define icmp6_ifoutstat_inc(ifp, type, code) \ 552229039Sdimdo { \ 553229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_msg); \ 554229039Sdim if (type < ICMP6_INFOMSG_MASK) \ 555194179Sed icmp6_ifstat_inc(ifp, ifs6_out_error); \ 556229039Sdim switch(type) { \ 557229039Sdim case ICMP6_DST_UNREACH: \ 558229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_dstunreach); \ 559229039Sdim if (code == ICMP6_DST_UNREACH_ADMIN) \ 560229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_adminprohib); \ 561229039Sdim break; \ 562194179Sed case ICMP6_PACKET_TOO_BIG: \ 563229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_pkttoobig); \ 564229039Sdim break; \ 565229039Sdim case ICMP6_TIME_EXCEEDED: \ 566229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_timeexceed); \ 567229039Sdim break; \ 568229039Sdim case ICMP6_PARAM_PROB: \ 569194179Sed icmp6_ifstat_inc(ifp, ifs6_out_paramprob); \ 570229039Sdim break; \ 571229039Sdim case ICMP6_ECHO_REQUEST: \ 572229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_echo); \ 573229039Sdim break; \ 574229039Sdim case ICMP6_ECHO_REPLY: \ 575229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_echoreply); \ 576194179Sed break; \ 577229039Sdim case MLD6_LISTENER_QUERY: \ 578229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_mldquery); \ 579229039Sdim break; \ 580229039Sdim case MLD6_LISTENER_REPORT: \ 581229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_mldreport); \ 582229039Sdim break; \ 583194179Sed case MLD6_LISTENER_DONE: \ 584229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_mlddone); \ 585229039Sdim break; \ 586229039Sdim case ND_ROUTER_SOLICIT: \ 587229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_routersolicit); \ 588229039Sdim break; \ 589229039Sdim case ND_ROUTER_ADVERT: \ 590194179Sed icmp6_ifstat_inc(ifp, ifs6_out_routeradvert); \ 591229039Sdim break; \ 592229039Sdim case ND_NEIGHBOR_SOLICIT: \ 593229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); \ 594229039Sdim break; \ 595229039Sdim case ND_NEIGHBOR_ADVERT: \ 596229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); \ 597194179Sed break; \ 598229039Sdim case ND_REDIRECT: \ 599229039Sdim icmp6_ifstat_inc(ifp, ifs6_out_redirect); \ 600229039Sdim break; \ 601229039Sdim } \ 602229039Sdim} while (0) 603229039Sdim 604194179Sedextern int icmp6_rediraccept; /* accept/process redirects */ 605229039Sdimextern int icmp6_redirtimeout; /* cache time for redirect routes */ 606229039Sdim#endif /* _KERNEL */ 607229039Sdim 608229039Sdim#endif /* not _NETINET6_ICMPV6_H_ */ 609229039Sdim 610229039Sdim