source: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip6.h@ 321

Last change on this file since 321 was 321, checked in by coas-nagasima, 7 years ago

文字コードを設定

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 11.4 KB
Line 
1/*
2 * TINET (TCP/IP Protocol Stack)
3 *
4 * Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
5 * Tomakomai National College of Technology, JAPAN
6 *
7 * 上記著作権者は,以下の (1)~(4) の条件か,Free Software Foundation
8 * によって公表されている GNU General Public License の Version 2 に記
9 * 述されている条件を満たす場合に限り,本ソフトウェア(本ソフトウェア
10 * を改変したものを含む.以下同じ)を使用・複製・改変・再配布(以下,
11 * 利用と呼ぶ)することを無償で許諾する.
12 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
13 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
14 * スコード中に含まれていること.
15 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
16 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
17 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
18 * の無保証規定を掲載すること.
19 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
20 * 用できない形で再配布する場合には,次の条件を満たすこと.
21 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
22 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
23 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
24 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
25 *
26 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
27 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,その適用可能性も
28 * 含めて,いかなる保証も行わない.また,本ソフトウェアの利用により直
29 * 接的または間接的に生じたいかなる損害に関しても,その責任を負わない.
30 *
31 * @(#) $Id$
32 */
33
34/* $FreeBSD: src/sys/netinet/ip6.h,v 1.2.2.2 2001/07/03 11:01:46 ume Exp $ */
35/* $KAME: ip6.h,v 1.18 2001/03/29 05:34:30 itojun Exp $ */
36
37/*
38 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
39 * All rights reserved.
40 *
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
43 * are met:
44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution.
49 * 3. Neither the name of the project nor the names of its contributors
50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission.
52 *
53 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE.
64 */
65
66/*
67 * Copyright (c) 1982, 1986, 1993
68 * The Regents of the University of California. All rights reserved.
69 *
70 * Redistribution and use in source and binary forms, with or without
71 * modification, are permitted provided that the following conditions
72 * are met:
73 * 1. Redistributions of source code must retain the above copyright
74 * notice, this list of conditions and the following disclaimer.
75 * 2. Redistributions in binary form must reproduce the above copyright
76 * notice, this list of conditions and the following disclaimer in the
77 * documentation and/or other materials provided with the distribution.
78 * 3. All advertising materials mentioning features or use of this software
79 * must display the following acknowledgement:
80 * This product includes software developed by the University of
81 * California, Berkeley and its contributors.
82 * 4. Neither the name of the University nor the names of its contributors
83 * may be used to endorse or promote products derived from this software
84 * without specific prior written permission.
85 *
86 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
87 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
88 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
89 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
90 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
91 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
92 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
93 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
94 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
95 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
96 * SUCH DAMAGE.
97 *
98 * @(#)ip.h 8.1 (Berkeley) 6/10/93
99 */
100
101#ifndef _IP6_H_
102#define _IP6_H_
103
104#ifdef SUPPORT_INET6
105
106/*
107 * IPv6 の定義、RFC2460 参照
108 */
109
110#define IPV6_VERSION 6
111
112/*
113 * IPv6 ヘッダの定義
114 */
115
116typedef struct t_ip6_hdr {
117 uint32_t vcf; /* Version: 4 bit */
118 /* Traffic Class: 8 bit */
119 /* Flow Label: 20 bit */
120 uint16_t plen; /* Payload Length */
121 uint8_t next; /* Next Header */
122 uint8_t hlim; /* Hop Limit */
123 T_IN6_ADDR src; /* Source Address */
124 T_IN6_ADDR dst; /* Destination Address */
125 } __attribute__((packed, aligned(2)))T_IP6_HDR;
126
127#define IP6_HDR_SIZE (sizeof(T_IP6_HDR))
128
129/*
130 * IPv6 ヘッダ構造体メンバアクセスマクロ
131 */
132
133#define IP6_MAKE_VCF(v,cf) (((uint32_t)(v)<<28)|(cf))
134#define IP6_VCF_V(vcf) ((uint32_t)(vcf)>>28)
135#define IP6_VCF_C(vcf) (((uint32_t)(vcf)>>20)&ULONG_C(0xff))
136#define IP6_VCF_F(vcf) ((uint32_t)(vcf)&ULONG_C(0x000fffff))
137#define IP6_VCF_CF(vcf) ((uint32_t)(vcf)&ULONG_C(0x0fffffff))
138
139/*
140 * 拡張ヘッダ
141 */
142
143typedef struct t_ip6_ext_hdr {
144 uint8_t next; /* Next Header */
145 uint8_t len; /* 8 オクテット単位の長さ */
146 } __attribute__((packed, aligned(2)))T_IP6_EXT_HDR;
147
148/*
149 * 中継点 (Hop-by-Hop) オプションヘッダ
150 */
151
152typedef struct t_ip6_hbh_hdr {
153 uint8_t next; /* Next Header */
154 uint8_t len; /* 8 オクテット単位の長さ。ただし、
155 * このオプションヘッダ全体のオクテット数を
156 * 8 で割った値の - 1 が入る。
157 */
158 } __attribute__((packed, aligned(2)))T_IP6_HBH_HDR;
159
160/*
161 * 終点 (Destination) オプションヘッダ
162 */
163
164typedef struct t_ip6_dest_hdr {
165 uint8_t next; /* Next Header */
166 uint8_t len; /* 8 オクテット単位の長さ。ただし、
167 * このオプションヘッダ全体のオクテット数を
168 * 8 で割った値の - 1 が入る。
169 */
170 } __attribute__((packed, aligned(2)))T_IP6_DEST_HDR;
171
172/* 中継点 (Hop-by-Hop) オプション */
173
174#define IP6OPT_PAD1 UINT_C(0x00) /* 00 0 00000 */
175#define IP6OPT_PADN UINT_C(0x01) /* 00 0 00001 */
176#define IP6OPT_JUMBO UINT_C(0xc2) /* 11 0 00010 */
177#define IP6OPT_NSAP_ADDR UINT_C(0xc3) /* 11 0 00011 */
178#define IP6OPT_TUNNEL_LIMIT UINT_C(0x04) /* 00 0 00100 */
179#define IP6OPT_RTR_ALERT UINT_C(0x05) /* 00 0 00101 */
180
181#define IP6OPT_MINLEN 2 /* オプションの最短長 */
182
183/* 未知のオプションの処理の指定 */
184
185#define IP6OPT_TYPE_SKIP UINT_C(0x00) /* 無視する。 */
186#define IP6OPT_TYPE_DISCARD UINT_C(0x40) /* データグラムを破棄する。 */
187#define IP6OPT_TYPE_FORCEICMP UINT_C(0x80) /* 破棄して、ICMP を返送する。 */
188#define IP6OPT_TYPE_ICMP UINT_C(0xc0)
189 /* 破棄して、マルチキャストでなければ ICMP を返送する。 */
190
191#define IP6OPT_TYPE(o) ((o)&UINT_C(0xc0))
192
193/*
194 * 経路制御ヘッダ
195 */
196
197typedef struct t_ip6_rt_hdr {
198 uint8_t next; /* Next Header */
199 uint8_t len; /* 8 オクテット単位の長さ。ただし、
200 * このオプションヘッダ全体のオクテット数を
201 * 8 で割った値の - 1 が入る。
202 */
203 uint8_t type; /* 経路制御タイプ */
204 uint8_t segleft; /* セグメントの残り */
205 } __attribute__((packed, aligned(2)))T_IP6_RT_HDR;
206
207/*
208 * タイプ 0 経路制御ヘッダ
209 */
210
211typedef struct t_ip6_rt0_hdr {
212 uint8_t next; /* Next Header */
213 uint8_t len; /* 8 オクテット単位の長さ。ただし、
214 * このオプションヘッダ全体のオクテット数を
215 * 8 で割った値の - 1 が入る。
216 */
217 uint8_t type; /* 経路制御タイプ */
218 uint8_t segleft; /* セグメントの残り */
219 uint32_t reserved; /* 予約 */
220 } __attribute__((packed, aligned(2)))T_IP6_RT0_HDR;
221
222/*
223 * 断片ヘッダ
224 */
225
226typedef struct t_ip6_frag_hdr {
227 uint8_t next; /* Next Header */
228 uint8_t reserved;
229 uint16_t off_flag; /* オフセットとフラグ */
230 uint32_t ident; /* 分割識別子 */
231 } __attribute__((packed, aligned(2)))T_IP6_FRAG_HDR;
232
233/* 断片ヘッダのオフセットとフラグ */
234
235#ifdef _NET_CFG_BYTE_ORDER
236
237#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
238
239#define IP6F_OFF_MASK UINT_C(0xfff8) /* オフセットを取出すマスク */
240#define IP6F_RESERVED_MASK UINT_C(0x0006) /* 予約を取出すマスク */
241#define IP6F_MORE_FRAG UINT_C(0x0001) /* 中間フラグメント */
242
243#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
244
245#define IP6F_OFF_MASK UINT_C(0xf8ff) /* オフセットを取出すマスク */
246#define IP6F_RESERVED_MASK UINT_C(0x0600) /* 予約を取出すマスク */
247#define IP6F_MORE_FRAG UINT_C(0x0100) /* 中間フラグメント */
248
249#endif /* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
250
251#endif /* of #ifdef _NET_CFG_BYTE_ORDER */
252
253/*
254 * 制限値
255 */
256
257#define IPV6_MAXHLIM UINT_C(255) /* ホップリミットの最大値 */
258#define IPV6_DEFHLIM UINT_C(64) /* ホップリミットの規定値 */
259#define IPV6_FRAGTTL UINT_C(60) /* 分割されたデータグラムの生存時間(秒) */
260#define IPV6_MMTU UINT_C(1280) /* 最小 MTU。ペイロード (1024) + ヘッダ (256) */
261#define IPV6_MAXPACKET UINT_C(65535) /* ジャンボペイロードを除く最大パケットサイズ */
262
263/*
264 * IPv4 と IPv6 をコンパイル時に選択するためのマクロ
265 */
266
267/*
268 * ホップリミットの規定値は、ルータ通知により変更されることがある
269 */
270
271#if NUM_ND6_DEF_RTR_ENTRY > 0
272
273/* ルータ通知を受信する場合は、通知された値 */
274
275#define IP_DEFTTL ip6_defhlim
276
277#else /* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
278
279/* ルータ通知を受信しない場合の値は既定値 */
280
281#define IP_DEFTTL IPV6_DEFHLIM
282
283#endif /* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
284
285#define IP_HDR_SIZE IP6_HDR_SIZE
286#define T_IP_HDR T_IP6_HDR
287
288#endif /* of #ifdef SUPPORT_INET6 */
289
290#endif /* of #ifndef _IP6_H_ */
Note: See TracBrowser for help on using the repository browser.