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

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

mruby版ECNLプロトタイピング・ツールを追加

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