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