ip6.h revision ef7c95b8ab96897db09faec974c2547305887cbe
16846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/*	$NetBSD: ip6.h,v 1.23 2007/12/25 18:33:46 perry Exp $	*/
26846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/*	$KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $	*/
36846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
46846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/*
56846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
66846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * All rights reserved.
76846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *
86846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * Redistribution and use in source and binary forms, with or without
96846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * modification, are permitted provided that the following conditions
106846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * are met:
116846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * 1. Redistributions of source code must retain the above copyright
126846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *    notice, this list of conditions and the following disclaimer.
136846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * 2. Redistributions in binary form must reproduce the above copyright
146846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *    notice, this list of conditions and the following disclaimer in the
156846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *    documentation and/or other materials provided with the distribution.
166846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * 3. Neither the name of the project nor the names of its contributors
176846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *    may be used to endorse or promote products derived from this software
186846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *    without specific prior written permission.
196846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *
206846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
216846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
226846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
236846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
246846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
256846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
266846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
276846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
286846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
296846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
306846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * SUCH DAMAGE.
316846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson */
326846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
336846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/*
346846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * Copyright (c) 1982, 1986, 1993
356846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *	The Regents of the University of California.  All rights reserved.
366846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *
376846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * Redistribution and use in source and binary forms, with or without
386846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * modification, are permitted provided that the following conditions
396846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * are met:
406846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * 1. Redistributions of source code must retain the above copyright
416846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *    notice, this list of conditions and the following disclaimer.
426846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * 2. Redistributions in binary form must reproduce the above copyright
436846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *    notice, this list of conditions and the following disclaimer in the
446846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *    documentation and/or other materials provided with the distribution.
456846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * 3. Neither the name of the University nor the names of its contributors
466846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *    may be used to endorse or promote products derived from this software
476846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *    without specific prior written permission.
486846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *
496846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
506846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
516846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
526846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
536846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
546846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
556846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
566846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
576846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
586846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
596846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * SUCH DAMAGE.
606846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *
616846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *	@(#)ip.h	8.1 (Berkeley) 6/10/93
626846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson */
636846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
646846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#ifndef _NETINET_IP6_H_
656846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define _NETINET_IP6_H_
666846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
67ef7c95b8ab96897db09faec974c2547305887cbeJosh Gao#include <sys/types.h>
68ef7c95b8ab96897db09faec974c2547305887cbeJosh Gao
69ef7c95b8ab96897db09faec974c2547305887cbeJosh Gao#include <linux/in6.h>
70ef7c95b8ab96897db09faec974c2547305887cbeJosh Gao
716846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/*
726846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * Definition for internet protocol version 6.
736846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * RFC 2460
746846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson */
756846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
766846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersonstruct ip6_hdr {
776846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	union {
786846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson		struct ip6_hdrctl {
796846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson			u_int32_t ip6_un1_flow;	/* 20 bits of flow-ID */
806846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson			u_int16_t ip6_un1_plen;	/* payload length */
816846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson			u_int8_t  ip6_un1_nxt;	/* next header */
826846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson			u_int8_t  ip6_un1_hlim;	/* hop limit */
836846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson		} ip6_un1;
846846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson		u_int8_t ip6_un2_vfc;	/* 4 bits version, top 4 bits class */
856846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	} ip6_ctlun;
866846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	struct in6_addr ip6_src;	/* source address */
876846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	struct in6_addr ip6_dst;	/* destination address */
886846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} __packed;
896846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
906846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define ip6_vfc		ip6_ctlun.ip6_un2_vfc
916846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define ip6_flow	ip6_ctlun.ip6_un1.ip6_un1_flow
926846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define ip6_plen	ip6_ctlun.ip6_un1.ip6_un1_plen
936846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define ip6_nxt		ip6_ctlun.ip6_un1.ip6_un1_nxt
946846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define ip6_hlim	ip6_ctlun.ip6_un1.ip6_un1_hlim
956846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define ip6_hops	ip6_ctlun.ip6_un1.ip6_un1_hlim
966846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
976846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IPV6_VERSION		0x60
986846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IPV6_VERSION_MASK	0xf0
996846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
1006846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#if BYTE_ORDER == BIG_ENDIAN
1016846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IPV6_FLOWINFO_MASK	0x0fffffff	/* flow info (28 bits) */
1026846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IPV6_FLOWLABEL_MASK	0x000fffff	/* flow label (20 bits) */
1036846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#else
1046846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#if BYTE_ORDER == LITTLE_ENDIAN
1056846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IPV6_FLOWINFO_MASK	0xffffff0f	/* flow info (28 bits) */
1066846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IPV6_FLOWLABEL_MASK	0xffff0f00	/* flow label (20 bits) */
1076846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#endif /* LITTLE_ENDIAN */
1086846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#endif
1096846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#if 1
1106846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* ECN bits proposed by Sally Floyd */
1116846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6TOS_CE		0x01	/* congestion experienced */
1126846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6TOS_ECT		0x02	/* ECN-capable transport */
1136846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#endif
1146846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
1156846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#ifdef _KERNEL
1166846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/*
1176846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * for IPv6 pseudo header checksum
1186846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * XXX nonstandard
1196846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson */
1206846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersonstruct ip6_hdr_pseudo {
1216846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	struct in6_addr ip6ph_src;
1226846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	struct in6_addr ip6ph_dst;
1236846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int32_t	ip6ph_len;
1246846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t	ip6ph_zero[3];
1256846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t	ip6ph_nxt;
1266846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} __packed;
1276846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#endif
1286846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
1296846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/*
1306846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * Extension Headers
1316846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson */
1326846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
1336846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersonstruct	ip6_ext {
1346846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6e_nxt;
1356846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6e_len;
1366846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} __packed;
1376846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
1386846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* Hop-by-Hop options header */
1396846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* XXX should we pad it to force alignment on an 8-byte boundary? */
1406846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersonstruct ip6_hbh {
1416846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6h_nxt;	/* next header */
1426846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6h_len;	/* length in units of 8 octets */
1436846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	/* followed by options */
1446846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} __packed;
1456846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
1466846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* Destination options header */
1476846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* XXX should we pad it to force alignment on an 8-byte boundary? */
1486846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersonstruct ip6_dest {
1496846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6d_nxt;	/* next header */
1506846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6d_len;	/* length in units of 8 octets */
1516846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	/* followed by options */
1526846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} __packed;
1536846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
1546846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* Option types and related macros */
1556846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_PAD1		0x00	/* 00 0 00000 */
1566846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_PADN		0x01	/* 00 0 00001 */
1576846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_JUMBO		0xC2	/* 11 0 00010 = 194 */
1586846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_NSAP_ADDR	0xC3	/* 11 0 00011 */
1596846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_TUNNEL_LIMIT	0x04	/* 00 0 00100 */
1606846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_RTALERT		0x05	/* 00 0 00101 (KAME definition) */
1616846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_ROUTER_ALERT	0x05	/* (RFC3542 def, recommended) */
1626846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
1636846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_RTALERT_LEN	4
1646846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_RTALERT_MLD	0	/* Datagram contains an MLD message */
1656846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_RTALERT_RSVP	1	/* Datagram contains an RSVP message */
1666846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_RTALERT_ACTNET	2 	/* contains an Active Networks msg */
1676846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_MINLEN		2
1686846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
1696846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_TYPE(o)		((o) & 0xC0)
1706846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_TYPE_SKIP	0x00
1716846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_TYPE_DISCARD	0x40
1726846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_TYPE_FORCEICMP	0x80
1736846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_TYPE_ICMP	0xC0
1746846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
1756846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_MUTABLE		0x20
1766846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
1776846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* IPv6 options: common part */
1786846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersonstruct ip6_opt {
1796846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6o_type;
1806846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6o_len;
1816846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} __packed;
1826846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
1836846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* Jumbo Payload Option */
1846846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersonstruct ip6_opt_jumbo {
1856846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6oj_type;
1866846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6oj_len;
1876846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6oj_jumbo_len[4];
1886846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} __packed;
1896846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6OPT_JUMBO_LEN 6
1906846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
1916846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* NSAP Address Option */
1926846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersonstruct ip6_opt_nsap {
1936846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6on_type;
1946846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6on_len;
1956846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6on_src_nsap_len;
1966846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6on_dst_nsap_len;
1976846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	/* followed by source NSAP */
1986846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	/* followed by destination NSAP */
1996846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} __packed;
2006846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
2016846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* Tunnel Limit Option */
2026846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersonstruct ip6_opt_tunnel {
2036846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6ot_type;
2046846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6ot_len;
2056846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6ot_encap_limit;
2066846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} __packed;
2076846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
2086846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* Router Alert Option */
2096846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersonstruct ip6_opt_router {
2106846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6or_type;
2116846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6or_len;
2126846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t ip6or_value[2];
2136846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} __packed;
2146846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* Router alert values (in network byte order) */
2156846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#if BYTE_ORDER == BIG_ENDIAN
2166846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6_ALERT_MLD	0x0000
2176846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6_ALERT_RSVP	0x0001
2186846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6_ALERT_AN	0x0002
2196846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#else
2206846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#if BYTE_ORDER == LITTLE_ENDIAN
2216846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6_ALERT_MLD	0x0000
2226846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6_ALERT_RSVP	0x0100
2236846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6_ALERT_AN	0x0200
2246846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#endif /* LITTLE_ENDIAN */
2256846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#endif
2266846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
2276846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* Routing header */
2286846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersonstruct ip6_rthdr {
2296846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t  ip6r_nxt;	/* next header */
2306846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t  ip6r_len;	/* length in units of 8 octets */
2316846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t  ip6r_type;	/* routing type */
2326846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t  ip6r_segleft;	/* segments left */
2336846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	/* followed by routing type specific data */
2346846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} __packed;
2356846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
2366846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* Type 0 Routing header */
2376846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersonstruct ip6_rthdr0 {
2386846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t  ip6r0_nxt;		/* next header */
2396846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t  ip6r0_len;		/* length in units of 8 octets */
2406846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t  ip6r0_type;		/* always zero */
2416846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t  ip6r0_segleft;	/* segments left */
2426846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int32_t ip6r0_reserved;	/* reserved field */
2436846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} __packed;
2446846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
2456846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/* Fragment header */
2466846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersonstruct ip6_frag {
2476846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t  ip6f_nxt;		/* next header */
2486846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int8_t  ip6f_reserved;	/* reserved field */
2496846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int16_t ip6f_offlg;		/* offset, reserved, and flag */
2506846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	u_int32_t ip6f_ident;		/* identification */
2516846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} __packed;
2526846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
2536846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#if BYTE_ORDER == BIG_ENDIAN
2546846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6F_OFF_MASK		0xfff8	/* mask out offset from _offlg */
2556846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6F_RESERVED_MASK	0x0006	/* reserved bits in ip6f_offlg */
2566846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6F_MORE_FRAG		0x0001	/* more-fragments flag */
2576846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#else /* BYTE_ORDER == LITTLE_ENDIAN */
2586846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6F_OFF_MASK		0xf8ff	/* mask out offset from _offlg */
2596846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6F_RESERVED_MASK	0x0600	/* reserved bits in ip6f_offlg */
2606846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6F_MORE_FRAG		0x0100	/* more-fragments flag */
2616846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#endif /* BYTE_ORDER == LITTLE_ENDIAN */
2626846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
2636846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/*
2646846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * Internet implementation parameters.
2656846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson */
2666846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IPV6_MAXHLIM	255	/* maximum hoplimit */
2676846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IPV6_DEFHLIM	64	/* default hlim */
2686846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IPV6_FRAGTTL	120	/* ttl for fragment packets, in slowtimo tick */
2696846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IPV6_HLIMDEC	1	/* subtracted when forwarding */
2706846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
2716846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IPV6_MMTU	1280	/* minimal MTU and reassembly. 1024 + 256 */
2726846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IPV6_MAXPACKET	65535	/* ip6 max packet size without Jumbo payload*/
2736846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
2746846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#ifdef _KERNEL
2756846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson/*
2766846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * IP6_EXTHDR_GET ensures that intermediate protocol header (from "off" to
2776846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * "len") is located in single mbuf, on contiguous memory region.
2786846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * The pointer to the region will be returned to pointer variable "val",
2796846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * with type "typ".
2806846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * IP6_EXTHDR_GET0 does the same, except that it aligns the structure at the
2816846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * very top of mbuf.  GET0 is likely to make memory copy than GET.
2826846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson *
2836846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson * XXX we're now testing this, needs m_pulldown()
2846846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson */
2856846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6_EXTHDR_GET(val, typ, m, off, len) \
2866846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersondo {									\
2876846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	struct mbuf *_t;						\
2886846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	int _tmp;							\
2896846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	if ((m)->m_len >= (off) + (len))				\
2906846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson		(val) = (typ)(mtod((m), char *) + (off));		\
2916846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	else {								\
2926846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson		_t = m_pulldown((m), (off), (len), &_tmp);		\
2936846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson		if (_t) {						\
2946846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson			if (_t->m_len < _tmp + (len))			\
2956846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson				panic("m_pulldown malfunction");	\
2966846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson			(val) = (typ)(mtod(_t, char *) + _tmp);	\
2976846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson		} else {						\
2986846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson			(val) = (typ)NULL;				\
2996846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson			(m) = NULL;					\
3006846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson		}							\
3016846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	}								\
3026846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} while (/*CONSTCOND*/ 0)
3036846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
3046846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#define IP6_EXTHDR_GET0(val, typ, m, off, len) \
3056846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gundersondo {									\
3066846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	struct mbuf *_t;						\
3076846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	if ((off) == 0 && (m)->m_len >= len)				\
3086846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson		(val) = (typ)mtod((m), void *);			\
3096846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	else {								\
3106846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson		_t = m_pulldown((m), (off), (len), NULL);		\
3116846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson		if (_t) {						\
3126846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson			if (_t->m_len < (len))				\
3136846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson				panic("m_pulldown malfunction");	\
3146846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson			(val) = (typ)mtod(_t, void *);			\
3156846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson		} else {						\
3166846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson			(val) = (typ)NULL;				\
3176846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson			(m) = NULL;					\
3186846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson		}							\
3196846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson	}								\
3206846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson} while (/*CONSTCOND*/ 0)
3216846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#endif /*_KERNEL*/
3226846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson
3236846a45882f4e099f422d1455eab3a94d4c69795Steinar H. Gunderson#endif /* !_NETINET_IP6_H_ */
324