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