1ea7b4bf5SPeter Avalos /* NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp */ 241c99275SPeter Avalos /* $KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $ */ 341c99275SPeter Avalos 441c99275SPeter Avalos /* 541c99275SPeter Avalos * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 641c99275SPeter Avalos * All rights reserved. 741c99275SPeter Avalos * 841c99275SPeter Avalos * Redistribution and use in source and binary forms, with or without 941c99275SPeter Avalos * modification, are permitted provided that the following conditions 1041c99275SPeter Avalos * are met: 1141c99275SPeter Avalos * 1. Redistributions of source code must retain the above copyright 1241c99275SPeter Avalos * notice, this list of conditions and the following disclaimer. 1341c99275SPeter Avalos * 2. Redistributions in binary form must reproduce the above copyright 1441c99275SPeter Avalos * notice, this list of conditions and the following disclaimer in the 1541c99275SPeter Avalos * documentation and/or other materials provided with the distribution. 1641c99275SPeter Avalos * 3. Neither the name of the project nor the names of its contributors 1741c99275SPeter Avalos * may be used to endorse or promote products derived from this software 1841c99275SPeter Avalos * without specific prior written permission. 1941c99275SPeter Avalos * 2041c99275SPeter Avalos * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 2141c99275SPeter Avalos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2241c99275SPeter Avalos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2341c99275SPeter Avalos * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2441c99275SPeter Avalos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2541c99275SPeter Avalos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2641c99275SPeter Avalos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2741c99275SPeter Avalos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2841c99275SPeter Avalos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2941c99275SPeter Avalos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3041c99275SPeter Avalos * SUCH DAMAGE. 3141c99275SPeter Avalos */ 3241c99275SPeter Avalos 3341c99275SPeter Avalos /* 3441c99275SPeter Avalos * Copyright (c) 1982, 1986, 1993 3541c99275SPeter Avalos * The Regents of the University of California. All rights reserved. 3641c99275SPeter Avalos * 3741c99275SPeter Avalos * Redistribution and use in source and binary forms, with or without 3841c99275SPeter Avalos * modification, are permitted provided that the following conditions 3941c99275SPeter Avalos * are met: 4041c99275SPeter Avalos * 1. Redistributions of source code must retain the above copyright 4141c99275SPeter Avalos * notice, this list of conditions and the following disclaimer. 4241c99275SPeter Avalos * 2. Redistributions in binary form must reproduce the above copyright 4341c99275SPeter Avalos * notice, this list of conditions and the following disclaimer in the 4441c99275SPeter Avalos * documentation and/or other materials provided with the distribution. 4541c99275SPeter Avalos * 3. All advertising materials mentioning features or use of this software 4641c99275SPeter Avalos * must display the following acknowledgement: 4741c99275SPeter Avalos * This product includes software developed by the University of 4841c99275SPeter Avalos * California, Berkeley and its contributors. 4941c99275SPeter Avalos * 4. Neither the name of the University nor the names of its contributors 5041c99275SPeter Avalos * may be used to endorse or promote products derived from this software 5141c99275SPeter Avalos * without specific prior written permission. 5241c99275SPeter Avalos * 5341c99275SPeter Avalos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 5441c99275SPeter Avalos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 5541c99275SPeter Avalos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 5641c99275SPeter Avalos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 5741c99275SPeter Avalos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 5841c99275SPeter Avalos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 5941c99275SPeter Avalos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 6041c99275SPeter Avalos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 6141c99275SPeter Avalos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 6241c99275SPeter Avalos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 6341c99275SPeter Avalos * SUCH DAMAGE. 6441c99275SPeter Avalos * 6541c99275SPeter Avalos * @(#)ip.h 8.1 (Berkeley) 6/10/93 6641c99275SPeter Avalos */ 6741c99275SPeter Avalos 68*ed775ee7SAntonio Huete Jimenez #ifndef ND_IP6_H_ 69*ed775ee7SAntonio Huete Jimenez #define ND_IP6_H_ 7041c99275SPeter Avalos 7141c99275SPeter Avalos /* 7241c99275SPeter Avalos * Definition for internet protocol version 6. 7341c99275SPeter Avalos * RFC 2460 7441c99275SPeter Avalos */ 7541c99275SPeter Avalos 7641c99275SPeter Avalos struct ip6_hdr { 7741c99275SPeter Avalos union { 7841c99275SPeter Avalos struct ip6_hdrctl { 79*ed775ee7SAntonio Huete Jimenez nd_uint32_t ip6_un1_flow; /* 20 bits of flow-ID */ 80*ed775ee7SAntonio Huete Jimenez nd_uint16_t ip6_un1_plen; /* payload length */ 81*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6_un1_nxt; /* next header */ 82*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6_un1_hlim; /* hop limit */ 8341c99275SPeter Avalos } ip6_un1; 84*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */ 8541c99275SPeter Avalos } ip6_ctlun; 86*ed775ee7SAntonio Huete Jimenez nd_ipv6 ip6_src; /* source address */ 87*ed775ee7SAntonio Huete Jimenez nd_ipv6 ip6_dst; /* destination address */ 88*ed775ee7SAntonio Huete Jimenez }; 8941c99275SPeter Avalos 9041c99275SPeter Avalos #define ip6_vfc ip6_ctlun.ip6_un2_vfc 91*ed775ee7SAntonio Huete Jimenez #define IP6_VERSION(ip6_hdr) ((GET_U_1((ip6_hdr)->ip6_vfc) & 0xf0) >> 4) 9241c99275SPeter Avalos #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow 9341c99275SPeter Avalos #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen 9441c99275SPeter Avalos #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt 9541c99275SPeter Avalos #define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim 9641c99275SPeter Avalos #define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim 9741c99275SPeter Avalos 9841c99275SPeter Avalos /* in network endian */ 99411677aeSAaron LI #define IPV6_FLOWINFO_MASK ((uint32_t)htonl(0x0fffffff)) /* flow info (28 bits) */ 100411677aeSAaron LI #define IPV6_FLOWLABEL_MASK ((uint32_t)htonl(0x000fffff)) /* flow label (20 bits) */ 10141c99275SPeter Avalos 10241c99275SPeter Avalos /* 10341c99275SPeter Avalos * Extension Headers 10441c99275SPeter Avalos */ 10541c99275SPeter Avalos 10641c99275SPeter Avalos struct ip6_ext { 107*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6e_nxt; 108*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6e_len; 109*ed775ee7SAntonio Huete Jimenez }; 11041c99275SPeter Avalos 11141c99275SPeter Avalos /* Hop-by-Hop options header */ 11241c99275SPeter Avalos struct ip6_hbh { 113*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6h_nxt; /* next header */ 114*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6h_len; /* length in units of 8 octets */ 11541c99275SPeter Avalos /* followed by options */ 116*ed775ee7SAntonio Huete Jimenez }; 11741c99275SPeter Avalos 11841c99275SPeter Avalos /* Destination options header */ 11941c99275SPeter Avalos struct ip6_dest { 120*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6d_nxt; /* next header */ 121*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6d_len; /* length in units of 8 octets */ 12241c99275SPeter Avalos /* followed by options */ 123*ed775ee7SAntonio Huete Jimenez }; 12441c99275SPeter Avalos 125*ed775ee7SAntonio Huete Jimenez /* https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml */ 126411677aeSAaron LI 12741c99275SPeter Avalos /* Option types and related macros */ 12841c99275SPeter Avalos #define IP6OPT_PAD1 0x00 /* 00 0 00000 */ 12941c99275SPeter Avalos #define IP6OPT_PADN 0x01 /* 00 0 00001 */ 13041c99275SPeter Avalos #define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */ 13141c99275SPeter Avalos #define IP6OPT_JUMBO_LEN 6 132411677aeSAaron LI #define IP6OPT_RPL 0x63 /* 01 1 00011 */ 133411677aeSAaron LI #define IP6OPT_TUN_ENC_LIMIT 0x04 /* 00 0 00100 */ 13441c99275SPeter Avalos #define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */ 13541c99275SPeter Avalos 13641c99275SPeter Avalos #define IP6OPT_RTALERT_LEN 4 13741c99275SPeter Avalos #define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */ 13841c99275SPeter Avalos #define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */ 13941c99275SPeter Avalos #define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */ 14041c99275SPeter Avalos #define IP6OPT_MINLEN 2 14141c99275SPeter Avalos 142411677aeSAaron LI #define IP6OPT_QUICK_START 0x26 /* 00 1 00110 */ 143411677aeSAaron LI #define IP6OPT_CALIPSO 0x07 /* 00 0 00111 */ 144411677aeSAaron LI #define IP6OPT_SMF_DPD 0x08 /* 00 0 01000 */ 14541c99275SPeter Avalos #define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */ 146411677aeSAaron LI #define IP6OPT_HOMEADDR_MINLEN 18 14741c99275SPeter Avalos #define IP6OPT_EID 0x8a /* 10 0 01010 */ 148411677aeSAaron LI #define IP6OPT_ILNP_NOTICE 0x8b /* 10 0 01011 */ 149411677aeSAaron LI #define IP6OPT_LINE_ID 0x8c /* 10 0 01100 */ 150411677aeSAaron LI #define IP6OPT_MPL 0x6d /* 01 1 01101 */ 151411677aeSAaron LI #define IP6OPT_IP_DFF 0xee /* 11 1 01110 */ 15241c99275SPeter Avalos 15341c99275SPeter Avalos #define IP6OPT_TYPE(o) ((o) & 0xC0) 15441c99275SPeter Avalos #define IP6OPT_TYPE_SKIP 0x00 15541c99275SPeter Avalos #define IP6OPT_TYPE_DISCARD 0x40 15641c99275SPeter Avalos #define IP6OPT_TYPE_FORCEICMP 0x80 15741c99275SPeter Avalos #define IP6OPT_TYPE_ICMP 0xC0 15841c99275SPeter Avalos 15941c99275SPeter Avalos #define IP6OPT_MUTABLE 0x20 16041c99275SPeter Avalos 16141c99275SPeter Avalos /* Routing header */ 16241c99275SPeter Avalos struct ip6_rthdr { 163*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6r_nxt; /* next header */ 164*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6r_len; /* length in units of 8 octets */ 165*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6r_type; /* routing type */ 166*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6r_segleft; /* segments left */ 16741c99275SPeter Avalos /* followed by routing type specific data */ 168*ed775ee7SAntonio Huete Jimenez }; 16941c99275SPeter Avalos 170411677aeSAaron LI #define IPV6_RTHDR_TYPE_0 0 171411677aeSAaron LI #define IPV6_RTHDR_TYPE_2 2 172*ed775ee7SAntonio Huete Jimenez #define IPV6_RTHDR_TYPE_4 4 173411677aeSAaron LI 17441c99275SPeter Avalos /* Type 0 Routing header */ 175411677aeSAaron LI /* Also used for Type 2 */ 17641c99275SPeter Avalos struct ip6_rthdr0 { 177411677aeSAaron LI nd_uint8_t ip6r0_nxt; /* next header */ 178411677aeSAaron LI nd_uint8_t ip6r0_len; /* length in units of 8 octets */ 179411677aeSAaron LI nd_uint8_t ip6r0_type; /* always zero */ 180411677aeSAaron LI nd_uint8_t ip6r0_segleft; /* segments left */ 181411677aeSAaron LI nd_uint32_t ip6r0_reserved; /* reserved field */ 182*ed775ee7SAntonio Huete Jimenez nd_ipv6 ip6r0_addr[1]; /* up to 23 addresses */ 183*ed775ee7SAntonio Huete Jimenez }; 184*ed775ee7SAntonio Huete Jimenez 185*ed775ee7SAntonio Huete Jimenez /** 186*ed775ee7SAntonio Huete Jimenez * Type 4 Routing header 187*ed775ee7SAntonio Huete Jimenez * known as Segment Routing Header 'SRH' 188*ed775ee7SAntonio Huete Jimenez */ 189*ed775ee7SAntonio Huete Jimenez struct ip6_srh { 190*ed775ee7SAntonio Huete Jimenez nd_uint8_t srh_nxt; /* next header */ 191*ed775ee7SAntonio Huete Jimenez nd_uint8_t srh_len; /* length in units of 8 octets */ 192*ed775ee7SAntonio Huete Jimenez nd_uint8_t srh_type; /* Routing Type 4 */ 193*ed775ee7SAntonio Huete Jimenez nd_uint8_t srh_segleft; /* segments left */ 194*ed775ee7SAntonio Huete Jimenez nd_uint8_t srh_last_ent; /* Last Entry*/ 195*ed775ee7SAntonio Huete Jimenez nd_uint8_t srh_flags; /* Flags */ 196*ed775ee7SAntonio Huete Jimenez nd_uint16_t srh_tag; /* Tag */ 197*ed775ee7SAntonio Huete Jimenez nd_ipv6 srh_segments[1]; /* SRH segments list*/ 198411677aeSAaron LI }; 19941c99275SPeter Avalos 20041c99275SPeter Avalos /* Fragment header */ 20141c99275SPeter Avalos struct ip6_frag { 202*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6f_nxt; /* next header */ 203*ed775ee7SAntonio Huete Jimenez nd_uint8_t ip6f_reserved; /* reserved field */ 204*ed775ee7SAntonio Huete Jimenez nd_uint16_t ip6f_offlg; /* offset, reserved, and flag */ 205*ed775ee7SAntonio Huete Jimenez nd_uint32_t ip6f_ident; /* identification */ 206*ed775ee7SAntonio Huete Jimenez }; 20741c99275SPeter Avalos 20841c99275SPeter Avalos #define IP6F_OFF_MASK 0xfff8 /* mask out offset from ip6f_offlg */ 20941c99275SPeter Avalos #define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */ 21041c99275SPeter Avalos #define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */ 21141c99275SPeter Avalos 212*ed775ee7SAntonio Huete Jimenez #endif /* not ND_IP6_H_ */ 213