1a5779b6eSRui Paulo /* NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp */ 2685295f4SBill Fenner /* $KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $ */ 3685295f4SBill Fenner 4685295f4SBill Fenner /* 5685295f4SBill Fenner * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 6685295f4SBill Fenner * All rights reserved. 7685295f4SBill Fenner * 8685295f4SBill Fenner * Redistribution and use in source and binary forms, with or without 9685295f4SBill Fenner * modification, are permitted provided that the following conditions 10685295f4SBill Fenner * are met: 11685295f4SBill Fenner * 1. Redistributions of source code must retain the above copyright 12685295f4SBill Fenner * notice, this list of conditions and the following disclaimer. 13685295f4SBill Fenner * 2. Redistributions in binary form must reproduce the above copyright 14685295f4SBill Fenner * notice, this list of conditions and the following disclaimer in the 15685295f4SBill Fenner * documentation and/or other materials provided with the distribution. 16685295f4SBill Fenner * 3. Neither the name of the project nor the names of its contributors 17685295f4SBill Fenner * may be used to endorse or promote products derived from this software 18685295f4SBill Fenner * without specific prior written permission. 19685295f4SBill Fenner * 20685295f4SBill Fenner * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 21685295f4SBill Fenner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22685295f4SBill Fenner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23685295f4SBill Fenner * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 24685295f4SBill Fenner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25685295f4SBill Fenner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26685295f4SBill Fenner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27685295f4SBill Fenner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28685295f4SBill Fenner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29685295f4SBill Fenner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30685295f4SBill Fenner * SUCH DAMAGE. 31685295f4SBill Fenner */ 32685295f4SBill Fenner 33685295f4SBill Fenner /* 34685295f4SBill Fenner * Copyright (c) 1982, 1986, 1993 35685295f4SBill Fenner * The Regents of the University of California. All rights reserved. 36685295f4SBill Fenner * 37685295f4SBill Fenner * Redistribution and use in source and binary forms, with or without 38685295f4SBill Fenner * modification, are permitted provided that the following conditions 39685295f4SBill Fenner * are met: 40685295f4SBill Fenner * 1. Redistributions of source code must retain the above copyright 41685295f4SBill Fenner * notice, this list of conditions and the following disclaimer. 42685295f4SBill Fenner * 2. Redistributions in binary form must reproduce the above copyright 43685295f4SBill Fenner * notice, this list of conditions and the following disclaimer in the 44685295f4SBill Fenner * documentation and/or other materials provided with the distribution. 45685295f4SBill Fenner * 3. All advertising materials mentioning features or use of this software 46685295f4SBill Fenner * must display the following acknowledgement: 47685295f4SBill Fenner * This product includes software developed by the University of 48685295f4SBill Fenner * California, Berkeley and its contributors. 49685295f4SBill Fenner * 4. Neither the name of the University nor the names of its contributors 50685295f4SBill Fenner * may be used to endorse or promote products derived from this software 51685295f4SBill Fenner * without specific prior written permission. 52685295f4SBill Fenner * 53685295f4SBill Fenner * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 54685295f4SBill Fenner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 55685295f4SBill Fenner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 56685295f4SBill Fenner * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 57685295f4SBill Fenner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 58685295f4SBill Fenner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 59685295f4SBill Fenner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 60685295f4SBill Fenner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 61685295f4SBill Fenner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 62685295f4SBill Fenner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 63685295f4SBill Fenner * SUCH DAMAGE. 64685295f4SBill Fenner * 65685295f4SBill Fenner * @(#)ip.h 8.1 (Berkeley) 6/10/93 66685295f4SBill Fenner */ 67685295f4SBill Fenner 68*ee67461eSJoseph Mingrone #ifndef ND_IP6_H_ 69*ee67461eSJoseph Mingrone #define ND_IP6_H_ 70685295f4SBill Fenner 71685295f4SBill Fenner /* 72685295f4SBill Fenner * Definition for internet protocol version 6. 73685295f4SBill Fenner * RFC 2460 74685295f4SBill Fenner */ 75685295f4SBill Fenner 76685295f4SBill Fenner struct ip6_hdr { 77685295f4SBill Fenner union { 78685295f4SBill Fenner struct ip6_hdrctl { 79*ee67461eSJoseph Mingrone nd_uint32_t ip6_un1_flow; /* 20 bits of flow-ID */ 80*ee67461eSJoseph Mingrone nd_uint16_t ip6_un1_plen; /* payload length */ 81*ee67461eSJoseph Mingrone nd_uint8_t ip6_un1_nxt; /* next header */ 82*ee67461eSJoseph Mingrone nd_uint8_t ip6_un1_hlim; /* hop limit */ 83685295f4SBill Fenner } ip6_un1; 84*ee67461eSJoseph Mingrone nd_uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */ 85685295f4SBill Fenner } ip6_ctlun; 86*ee67461eSJoseph Mingrone nd_ipv6 ip6_src; /* source address */ 87*ee67461eSJoseph Mingrone nd_ipv6 ip6_dst; /* destination address */ 88*ee67461eSJoseph Mingrone }; 8927df3f5dSRui Paulo 90685295f4SBill Fenner #define ip6_vfc ip6_ctlun.ip6_un2_vfc 91*ee67461eSJoseph Mingrone #define IP6_VERSION(ip6_hdr) ((GET_U_1((ip6_hdr)->ip6_vfc) & 0xf0) >> 4) 92685295f4SBill Fenner #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow 93685295f4SBill Fenner #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen 94685295f4SBill Fenner #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt 95685295f4SBill Fenner #define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim 96685295f4SBill Fenner #define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim 97685295f4SBill Fenner 98685295f4SBill Fenner /* in network endian */ 993c602fabSXin LI #define IPV6_FLOWINFO_MASK ((uint32_t)htonl(0x0fffffff)) /* flow info (28 bits) */ 1003c602fabSXin LI #define IPV6_FLOWLABEL_MASK ((uint32_t)htonl(0x000fffff)) /* flow label (20 bits) */ 101685295f4SBill Fenner 102685295f4SBill Fenner /* 103685295f4SBill Fenner * Extension Headers 104685295f4SBill Fenner */ 105685295f4SBill Fenner 106685295f4SBill Fenner struct ip6_ext { 107*ee67461eSJoseph Mingrone nd_uint8_t ip6e_nxt; 108*ee67461eSJoseph Mingrone nd_uint8_t ip6e_len; 109*ee67461eSJoseph Mingrone }; 110685295f4SBill Fenner 111685295f4SBill Fenner /* Hop-by-Hop options header */ 112685295f4SBill Fenner struct ip6_hbh { 113*ee67461eSJoseph Mingrone nd_uint8_t ip6h_nxt; /* next header */ 114*ee67461eSJoseph Mingrone nd_uint8_t ip6h_len; /* length in units of 8 octets */ 115685295f4SBill Fenner /* followed by options */ 116*ee67461eSJoseph Mingrone }; 117685295f4SBill Fenner 118685295f4SBill Fenner /* Destination options header */ 119685295f4SBill Fenner struct ip6_dest { 120*ee67461eSJoseph Mingrone nd_uint8_t ip6d_nxt; /* next header */ 121*ee67461eSJoseph Mingrone nd_uint8_t ip6d_len; /* length in units of 8 octets */ 122685295f4SBill Fenner /* followed by options */ 123*ee67461eSJoseph Mingrone }; 124685295f4SBill Fenner 125*ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml */ 1263c602fabSXin LI 127685295f4SBill Fenner /* Option types and related macros */ 128685295f4SBill Fenner #define IP6OPT_PAD1 0x00 /* 00 0 00000 */ 129685295f4SBill Fenner #define IP6OPT_PADN 0x01 /* 00 0 00001 */ 130685295f4SBill Fenner #define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */ 131685295f4SBill Fenner #define IP6OPT_JUMBO_LEN 6 1323c602fabSXin LI #define IP6OPT_RPL 0x63 /* 01 1 00011 */ 1333c602fabSXin LI #define IP6OPT_TUN_ENC_LIMIT 0x04 /* 00 0 00100 */ 134685295f4SBill Fenner #define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */ 135685295f4SBill Fenner 136685295f4SBill Fenner #define IP6OPT_RTALERT_LEN 4 137685295f4SBill Fenner #define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */ 138685295f4SBill Fenner #define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */ 139685295f4SBill Fenner #define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */ 140685295f4SBill Fenner #define IP6OPT_MINLEN 2 141685295f4SBill Fenner 1423c602fabSXin LI #define IP6OPT_QUICK_START 0x26 /* 00 1 00110 */ 1433c602fabSXin LI #define IP6OPT_CALIPSO 0x07 /* 00 0 00111 */ 1443c602fabSXin LI #define IP6OPT_SMF_DPD 0x08 /* 00 0 01000 */ 145685295f4SBill Fenner #define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */ 1463c602fabSXin LI #define IP6OPT_HOMEADDR_MINLEN 18 147685295f4SBill Fenner #define IP6OPT_EID 0x8a /* 10 0 01010 */ 1483c602fabSXin LI #define IP6OPT_ILNP_NOTICE 0x8b /* 10 0 01011 */ 1493c602fabSXin LI #define IP6OPT_LINE_ID 0x8c /* 10 0 01100 */ 1503c602fabSXin LI #define IP6OPT_MPL 0x6d /* 01 1 01101 */ 1513c602fabSXin LI #define IP6OPT_IP_DFF 0xee /* 11 1 01110 */ 152685295f4SBill Fenner 153685295f4SBill Fenner #define IP6OPT_TYPE(o) ((o) & 0xC0) 154685295f4SBill Fenner #define IP6OPT_TYPE_SKIP 0x00 155685295f4SBill Fenner #define IP6OPT_TYPE_DISCARD 0x40 156685295f4SBill Fenner #define IP6OPT_TYPE_FORCEICMP 0x80 157685295f4SBill Fenner #define IP6OPT_TYPE_ICMP 0xC0 158685295f4SBill Fenner 159685295f4SBill Fenner #define IP6OPT_MUTABLE 0x20 160685295f4SBill Fenner 161685295f4SBill Fenner /* Routing header */ 162685295f4SBill Fenner struct ip6_rthdr { 163*ee67461eSJoseph Mingrone nd_uint8_t ip6r_nxt; /* next header */ 164*ee67461eSJoseph Mingrone nd_uint8_t ip6r_len; /* length in units of 8 octets */ 165*ee67461eSJoseph Mingrone nd_uint8_t ip6r_type; /* routing type */ 166*ee67461eSJoseph Mingrone nd_uint8_t ip6r_segleft; /* segments left */ 167685295f4SBill Fenner /* followed by routing type specific data */ 168*ee67461eSJoseph Mingrone }; 169685295f4SBill Fenner 1703340d773SGleb Smirnoff #define IPV6_RTHDR_TYPE_0 0 1713340d773SGleb Smirnoff #define IPV6_RTHDR_TYPE_2 2 172*ee67461eSJoseph Mingrone #define IPV6_RTHDR_TYPE_4 4 1733340d773SGleb Smirnoff 174685295f4SBill Fenner /* Type 0 Routing header */ 1753340d773SGleb Smirnoff /* Also used for Type 2 */ 176685295f4SBill Fenner struct ip6_rthdr0 { 1770bff6a5aSEd Maste nd_uint8_t ip6r0_nxt; /* next header */ 1780bff6a5aSEd Maste nd_uint8_t ip6r0_len; /* length in units of 8 octets */ 1790bff6a5aSEd Maste nd_uint8_t ip6r0_type; /* always zero */ 1800bff6a5aSEd Maste nd_uint8_t ip6r0_segleft; /* segments left */ 1810bff6a5aSEd Maste nd_uint32_t ip6r0_reserved; /* reserved field */ 182*ee67461eSJoseph Mingrone nd_ipv6 ip6r0_addr[1]; /* up to 23 addresses */ 183*ee67461eSJoseph Mingrone }; 184*ee67461eSJoseph Mingrone 185*ee67461eSJoseph Mingrone /** 186*ee67461eSJoseph Mingrone * Type 4 Routing header 187*ee67461eSJoseph Mingrone * known as Segment Routing Header 'SRH' 188*ee67461eSJoseph Mingrone */ 189*ee67461eSJoseph Mingrone struct ip6_srh { 190*ee67461eSJoseph Mingrone nd_uint8_t srh_nxt; /* next header */ 191*ee67461eSJoseph Mingrone nd_uint8_t srh_len; /* length in units of 8 octets */ 192*ee67461eSJoseph Mingrone nd_uint8_t srh_type; /* Routing Type 4 */ 193*ee67461eSJoseph Mingrone nd_uint8_t srh_segleft; /* segments left */ 194*ee67461eSJoseph Mingrone nd_uint8_t srh_last_ent; /* Last Entry*/ 195*ee67461eSJoseph Mingrone nd_uint8_t srh_flags; /* Flags */ 196*ee67461eSJoseph Mingrone nd_uint16_t srh_tag; /* Tag */ 197*ee67461eSJoseph Mingrone nd_ipv6 srh_segments[1]; /* SRH segments list*/ 1980bff6a5aSEd Maste }; 199685295f4SBill Fenner 200685295f4SBill Fenner /* Fragment header */ 201685295f4SBill Fenner struct ip6_frag { 202*ee67461eSJoseph Mingrone nd_uint8_t ip6f_nxt; /* next header */ 203*ee67461eSJoseph Mingrone nd_uint8_t ip6f_reserved; /* reserved field */ 204*ee67461eSJoseph Mingrone nd_uint16_t ip6f_offlg; /* offset, reserved, and flag */ 205*ee67461eSJoseph Mingrone nd_uint32_t ip6f_ident; /* identification */ 206*ee67461eSJoseph Mingrone }; 207685295f4SBill Fenner 2085b0fe478SBruce M Simpson #define IP6F_OFF_MASK 0xfff8 /* mask out offset from ip6f_offlg */ 2095b0fe478SBruce M Simpson #define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */ 2105b0fe478SBruce M Simpson #define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */ 211685295f4SBill Fenner 212*ee67461eSJoseph Mingrone #endif /* not ND_IP6_H_ */ 213