1190207Srpaulo/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.8 2007-08-29 02:31:44 mcr Exp $ (LBL) */
2190207Srpaulo/*	NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp 	*/
375115Sfenner/*	$KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $	*/
475115Sfenner
575115Sfenner/*
675115Sfenner * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
775115Sfenner * All rights reserved.
875115Sfenner *
975115Sfenner * Redistribution and use in source and binary forms, with or without
1075115Sfenner * modification, are permitted provided that the following conditions
1175115Sfenner * are met:
1275115Sfenner * 1. Redistributions of source code must retain the above copyright
1375115Sfenner *    notice, this list of conditions and the following disclaimer.
1475115Sfenner * 2. Redistributions in binary form must reproduce the above copyright
1575115Sfenner *    notice, this list of conditions and the following disclaimer in the
1675115Sfenner *    documentation and/or other materials provided with the distribution.
1775115Sfenner * 3. Neither the name of the project nor the names of its contributors
1875115Sfenner *    may be used to endorse or promote products derived from this software
1975115Sfenner *    without specific prior written permission.
2075115Sfenner *
2175115Sfenner * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
2275115Sfenner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2375115Sfenner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2475115Sfenner * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
2575115Sfenner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2675115Sfenner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2775115Sfenner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2875115Sfenner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2975115Sfenner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3075115Sfenner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3175115Sfenner * SUCH DAMAGE.
3275115Sfenner */
3375115Sfenner
3475115Sfenner/*
3575115Sfenner * Copyright (c) 1982, 1986, 1993
3675115Sfenner *	The Regents of the University of California.  All rights reserved.
3775115Sfenner *
3875115Sfenner * Redistribution and use in source and binary forms, with or without
3975115Sfenner * modification, are permitted provided that the following conditions
4075115Sfenner * are met:
4175115Sfenner * 1. Redistributions of source code must retain the above copyright
4275115Sfenner *    notice, this list of conditions and the following disclaimer.
4375115Sfenner * 2. Redistributions in binary form must reproduce the above copyright
4475115Sfenner *    notice, this list of conditions and the following disclaimer in the
4575115Sfenner *    documentation and/or other materials provided with the distribution.
4675115Sfenner * 3. All advertising materials mentioning features or use of this software
4775115Sfenner *    must display the following acknowledgement:
4875115Sfenner *	This product includes software developed by the University of
4975115Sfenner *	California, Berkeley and its contributors.
5075115Sfenner * 4. Neither the name of the University nor the names of its contributors
5175115Sfenner *    may be used to endorse or promote products derived from this software
5275115Sfenner *    without specific prior written permission.
5375115Sfenner *
5475115Sfenner * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5575115Sfenner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5675115Sfenner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5775115Sfenner * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5875115Sfenner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5975115Sfenner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6075115Sfenner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6175115Sfenner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6275115Sfenner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6375115Sfenner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6475115Sfenner * SUCH DAMAGE.
6575115Sfenner *
6675115Sfenner *	@(#)ip.h	8.1 (Berkeley) 6/10/93
6775115Sfenner */
6875115Sfenner
6975115Sfenner#ifndef _NETINET_IP6_H_
7075115Sfenner#define _NETINET_IP6_H_
7175115Sfenner
7275115Sfenner/*
7375115Sfenner * Definition for internet protocol version 6.
7475115Sfenner * RFC 2460
7575115Sfenner */
7675115Sfenner
7775115Sfennerstruct ip6_hdr {
7875115Sfenner	union {
7975115Sfenner		struct ip6_hdrctl {
8075115Sfenner			u_int32_t ip6_un1_flow;	/* 20 bits of flow-ID */
8175115Sfenner			u_int16_t ip6_un1_plen;	/* payload length */
8275115Sfenner			u_int8_t  ip6_un1_nxt;	/* next header */
8375115Sfenner			u_int8_t  ip6_un1_hlim;	/* hop limit */
8475115Sfenner		} ip6_un1;
8575115Sfenner		u_int8_t ip6_un2_vfc;	/* 4 bits version, top 4 bits class */
8675115Sfenner	} ip6_ctlun;
8775115Sfenner	struct in6_addr ip6_src;	/* source address */
8875115Sfenner	struct in6_addr ip6_dst;	/* destination address */
89235530Sdelphij} UNALIGNED;
9075115Sfenner
9175115Sfenner#define ip6_vfc		ip6_ctlun.ip6_un2_vfc
9275115Sfenner#define ip6_flow	ip6_ctlun.ip6_un1.ip6_un1_flow
9375115Sfenner#define ip6_plen	ip6_ctlun.ip6_un1.ip6_un1_plen
9475115Sfenner#define ip6_nxt		ip6_ctlun.ip6_un1.ip6_un1_nxt
9575115Sfenner#define ip6_hlim	ip6_ctlun.ip6_un1.ip6_un1_hlim
9675115Sfenner#define ip6_hops	ip6_ctlun.ip6_un1.ip6_un1_hlim
9775115Sfenner
9875115Sfenner/* in network endian */
9975115Sfenner#define IPV6_FLOWINFO_MASK	((u_int32_t)htonl(0x0fffffff))	/* flow info (28 bits) */
10075115Sfenner#define IPV6_FLOWLABEL_MASK	((u_int32_t)htonl(0x000fffff))	/* flow label (20 bits) */
10175115Sfenner#if 1
10275115Sfenner/* ECN bits proposed by Sally Floyd */
10375115Sfenner#define IP6TOS_CE		0x01	/* congestion experienced */
10475115Sfenner#define IP6TOS_ECT		0x02	/* ECN-capable transport */
10575115Sfenner#endif
10675115Sfenner
10775115Sfenner/*
10875115Sfenner * Extension Headers
10975115Sfenner */
11075115Sfenner
11175115Sfennerstruct	ip6_ext {
112235530Sdelphij	u_int8_t ip6e_nxt;
113235530Sdelphij	u_int8_t ip6e_len;
114235530Sdelphij} UNALIGNED;
11575115Sfenner
11675115Sfenner/* Hop-by-Hop options header */
11775115Sfennerstruct ip6_hbh {
11875115Sfenner	u_int8_t ip6h_nxt;	/* next header */
11975115Sfenner	u_int8_t ip6h_len;	/* length in units of 8 octets */
12075115Sfenner	/* followed by options */
121235530Sdelphij} UNALIGNED;
12275115Sfenner
12375115Sfenner/* Destination options header */
12475115Sfennerstruct ip6_dest {
12575115Sfenner	u_int8_t ip6d_nxt;	/* next header */
12675115Sfenner	u_int8_t ip6d_len;	/* length in units of 8 octets */
12775115Sfenner	/* followed by options */
128235530Sdelphij} UNALIGNED;
12975115Sfenner
13075115Sfenner/* Option types and related macros */
13175115Sfenner#define IP6OPT_PAD1		0x00	/* 00 0 00000 */
13275115Sfenner#define IP6OPT_PADN		0x01	/* 00 0 00001 */
13375115Sfenner#define IP6OPT_JUMBO		0xC2	/* 11 0 00010 = 194 */
13475115Sfenner#define IP6OPT_JUMBO_LEN	6
13575115Sfenner#define IP6OPT_ROUTER_ALERT	0x05	/* 00 0 00101 */
13675115Sfenner
13775115Sfenner#define IP6OPT_RTALERT_LEN	4
13875115Sfenner#define IP6OPT_RTALERT_MLD	0	/* Datagram contains an MLD message */
13975115Sfenner#define IP6OPT_RTALERT_RSVP	1	/* Datagram contains an RSVP message */
14075115Sfenner#define IP6OPT_RTALERT_ACTNET	2 	/* contains an Active Networks msg */
14175115Sfenner#define IP6OPT_MINLEN		2
14275115Sfenner
14375115Sfenner#define IP6OPT_BINDING_UPDATE	0xc6	/* 11 0 00110 */
14475115Sfenner#define IP6OPT_BINDING_ACK	0x07	/* 00 0 00111 */
14575115Sfenner#define IP6OPT_BINDING_REQ	0x08	/* 00 0 01000 */
14675115Sfenner#define IP6OPT_HOME_ADDRESS	0xc9	/* 11 0 01001 */
14775115Sfenner#define IP6OPT_EID		0x8a	/* 10 0 01010 */
14875115Sfenner
14975115Sfenner#define IP6OPT_TYPE(o)		((o) & 0xC0)
15075115Sfenner#define IP6OPT_TYPE_SKIP	0x00
15175115Sfenner#define IP6OPT_TYPE_DISCARD	0x40
15275115Sfenner#define IP6OPT_TYPE_FORCEICMP	0x80
15375115Sfenner#define IP6OPT_TYPE_ICMP	0xC0
15475115Sfenner
15575115Sfenner#define IP6OPT_MUTABLE		0x20
15675115Sfenner
15775115Sfenner/* Routing header */
15875115Sfennerstruct ip6_rthdr {
15975115Sfenner	u_int8_t  ip6r_nxt;	/* next header */
16075115Sfenner	u_int8_t  ip6r_len;	/* length in units of 8 octets */
16175115Sfenner	u_int8_t  ip6r_type;	/* routing type */
16275115Sfenner	u_int8_t  ip6r_segleft;	/* segments left */
16375115Sfenner	/* followed by routing type specific data */
164235530Sdelphij} UNALIGNED;
16575115Sfenner
16675115Sfenner/* Type 0 Routing header */
16775115Sfennerstruct ip6_rthdr0 {
16875115Sfenner	u_int8_t  ip6r0_nxt;		/* next header */
16975115Sfenner	u_int8_t  ip6r0_len;		/* length in units of 8 octets */
17075115Sfenner	u_int8_t  ip6r0_type;		/* always zero */
17175115Sfenner	u_int8_t  ip6r0_segleft;	/* segments left */
17275115Sfenner	u_int8_t  ip6r0_reserved;	/* reserved field */
17375115Sfenner	u_int8_t  ip6r0_slmap[3];	/* strict/loose bit map */
17475115Sfenner	struct in6_addr ip6r0_addr[1];	/* up to 23 addresses */
175235530Sdelphij} UNALIGNED;
17675115Sfenner
17775115Sfenner/* Fragment header */
17875115Sfennerstruct ip6_frag {
17975115Sfenner	u_int8_t  ip6f_nxt;		/* next header */
18075115Sfenner	u_int8_t  ip6f_reserved;	/* reserved field */
18175115Sfenner	u_int16_t ip6f_offlg;		/* offset, reserved, and flag */
18275115Sfenner	u_int32_t ip6f_ident;		/* identification */
183235530Sdelphij} UNALIGNED;
18475115Sfenner
185127668Sbms#define IP6F_OFF_MASK		0xfff8	/* mask out offset from ip6f_offlg */
186127668Sbms#define IP6F_RESERVED_MASK	0x0006	/* reserved bits in ip6f_offlg */
187127668Sbms#define IP6F_MORE_FRAG		0x0001	/* more-fragments flag */
18875115Sfenner
189235530Sdelphij/* in print-ip6.c */
190235530Sdelphijextern int nextproto6_cksum(const struct ip6_hdr *, const u_int8_t *, u_int, u_int);
191235530Sdelphij
19275115Sfenner#endif /* not _NETINET_IP6_H_ */
193