source: asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/netinet/ip6.h@ 337

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

ASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 11.5 KB
Line 
1/*
2 * TINET (TCP/IP Protocol Stack)
3 *
4 * Copyright (C) 2001-2017 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/*
105 * IPv6 の定義、RFC2460 参照
106 */
107
108#define IPV6_VERSION 6
109
110/*
111 * IPv6 ヘッダの定義
112 */
113
114typedef struct t_ip6_hdr {
115 uint32_t vcf; /* Version: 4 bit */
116 /* Traffic Class: 8 bit */
117 /* Flow Label: 20 bit */
118 uint16_t plen; /* Payload Length */
119 uint8_t next; /* Next Header */
120 uint8_t hlim; /* Hop Limit */
121 T_IN6_ADDR src; /* Source Address */
122 T_IN6_ADDR dst; /* Destination Address */
123 } __attribute__((packed, aligned(2)))T_IP6_HDR;
124
125#define IP6_HDR_SIZE (sizeof(T_IP6_HDR))
126
127/*
128 * IPv6 ヘッダ構造体メンバアクセスマクロ
129 */
130
131#define IP6_MAKE_VCF(v,cf) (((uint32_t)(v)<<28)|(cf))
132#define IP6_VCF_V(vcf) ((uint32_t)(vcf)>>28)
133#define IP6_VCF_C(vcf) (((uint32_t)(vcf)>>20)&ULONG_C(0xff))
134#define IP6_VCF_F(vcf) ((uint32_t)(vcf)&ULONG_C(0x000fffff))
135#define IP6_VCF_CF(vcf) ((uint32_t)(vcf)&ULONG_C(0x0fffffff))
136
137/*
138 * 拡張ヘッダ
139 */
140
141typedef struct t_ip6_ext_hdr {
142 uint8_t next; /* Next Header */
143 uint8_t len; /* 8 オクテット単位の長さ */
144 } __attribute__((packed, aligned(2)))T_IP6_EXT_HDR;
145
146/*
147 * 中継点 (Hop-by-Hop) オプションヘッダ
148 */
149
150typedef struct t_ip6_hbh_hdr {
151 uint8_t next; /* Next Header */
152 uint8_t len; /* 8 オクテット単位の長さ。ただし、
153 * このオプションヘッダ全体のオクテット数を
154 * 8 で割った値の - 1 が入る。
155 */
156 } __attribute__((packed, aligned(2)))T_IP6_HBH_HDR;
157
158/*
159 * 終点 (Destination) オプションヘッダ
160 */
161
162typedef struct t_ip6_dest_hdr {
163 uint8_t next; /* Next Header */
164 uint8_t len; /* 8 オクテット単位の長さ。ただし、
165 * このオプションヘッダ全体のオクテット数を
166 * 8 で割った値の - 1 が入る。
167 */
168 } __attribute__((packed, aligned(2)))T_IP6_DEST_HDR;
169
170/* 中継点 (Hop-by-Hop) オプション */
171
172#define IP6OPT_PAD1 UINT_C(0x00) /* 00 0 00000 */
173#define IP6OPT_PADN UINT_C(0x01) /* 00 0 00001 */
174#define IP6OPT_JUMBO UINT_C(0xc2) /* 11 0 00010 */
175#define IP6OPT_NSAP_ADDR UINT_C(0xc3) /* 11 0 00011 */
176#define IP6OPT_TUNNEL_LIMIT UINT_C(0x04) /* 00 0 00100 */
177#define IP6OPT_RTR_ALERT UINT_C(0x05) /* 00 0 00101 */
178
179#define IP6OPT_MINLEN 2 /* オプションの最短長 */
180
181/* 未知のオプションの処理の指定 */
182
183#define IP6OPT_TYPE_SKIP UINT_C(0x00) /* 無視する。 */
184#define IP6OPT_TYPE_DISCARD UINT_C(0x40) /* データグラムを破棄する。 */
185#define IP6OPT_TYPE_FORCEICMP UINT_C(0x80) /* 破棄して、ICMP を返送する。 */
186#define IP6OPT_TYPE_ICMP UINT_C(0xc0)
187 /* 破棄して、マルチキャストでなければ ICMP を返送する。 */
188
189#define IP6OPT_TYPE(o) ((o)&UINT_C(0xc0))
190
191/*
192 * 経路制御ヘッダ
193 */
194
195typedef struct t_ip6_rt_hdr {
196 uint8_t next; /* Next Header */
197 uint8_t len; /* 8 オクテット単位の長さ。ただし、
198 * このオプションヘッダ全体のオクテット数を
199 * 8 で割った値の - 1 が入る。
200 */
201 uint8_t type; /* 経路制御タイプ */
202 uint8_t segleft; /* セグメントの残り */
203 } __attribute__((packed, aligned(2)))T_IP6_RT_HDR;
204
205/*
206 * タイプ 0 経路制御ヘッダ
207 */
208
209typedef struct t_ip6_rt0_hdr {
210 uint8_t next; /* Next Header */
211 uint8_t len; /* 8 オクテット単位の長さ。ただし、
212 * このオプションヘッダ全体のオクテット数を
213 * 8 で割った値の - 1 が入る。
214 */
215 uint8_t type; /* 経路制御タイプ */
216 uint8_t segleft; /* セグメントの残り */
217 uint32_t reserved; /* 予約 */
218 } __attribute__((packed, aligned(2)))T_IP6_RT0_HDR;
219
220/*
221 * 断片ヘッダ
222 */
223
224typedef struct t_ip6_frag_hdr {
225 uint8_t next; /* Next Header */
226 uint8_t reserved;
227 uint16_t off_flag; /* オフセットとフラグ */
228 uint32_t ident; /* 分割識別子 */
229 } __attribute__((packed, aligned(2)))T_IP6_FRAG_HDR;
230
231/* 断片ヘッダのオフセットとフラグ */
232
233#ifdef _NET_CFG_BYTE_ORDER
234
235#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
236
237#define IP6F_OFF_MASK UINT_C(0xfff8) /* オフセットを取出すマスク */
238#define IP6F_RESERVED_MASK UINT_C(0x0006) /* 予約を取出すマスク */
239#define IP6F_MORE_FRAG UINT_C(0x0001) /* 中間フラグメント */
240
241#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
242
243#define IP6F_OFF_MASK UINT_C(0xf8ff) /* オフセットを取出すマスク */
244#define IP6F_RESERVED_MASK UINT_C(0x0600) /* 予約を取出すマスク */
245#define IP6F_MORE_FRAG UINT_C(0x0100) /* 中間フラグメント */
246
247#endif /* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
248
249#endif /* of #ifdef _NET_CFG_BYTE_ORDER */
250
251/*
252 * 制限値
253 */
254
255#define IPV6_MAXHLIM UINT_C(255) /* ホップリミットの最大値 */
256#define IPV6_DEFHLIM UINT_C(64) /* ホップリミットの規定値 */
257#define IPV6_FRAGTTL UINT_C(60) /* 分割されたデータグラムの生存時間(秒) */
258#define IPV6_MMTU UINT_C(1280) /* 最小 MTU。ペイロード (1024) + ヘッダ (256) */
259#define IPV6_MAXPACKET UINT_C(65535) /* ジャンボペイロードを除く最大パケットサイズ */
260
261/*
262 * IPv6 と IPv4 をコンパイル時に選択するためのマクロ
263 */
264
265/*
266 * ホップリミットの規定値は、ルータ通知により変更されることがある
267 */
268
269#if NUM_ND6_DEF_RTR_ENTRY > 0
270
271/* ルータ通知を受信する場合は、通知された値 */
272
273#define IP6_DEFTTL ip6_defhlim
274
275#else /* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
276
277/* ルータ通知を受信しない場合の値は既定値 */
278
279#define IP6_DEFTTL IPV6_DEFHLIM
280
281#endif /* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
282
283/* IPv4 と IPv6 をコンパイル時に選択するためのマクロ */
284
285#ifdef _IP6_CFG
286
287#define IP_HDR_SIZE IP6_HDR_SIZE
288#define T_IP_HDR T_IP6_HDR
289#define IP_DEFTTL IP6_DEFTTL
290
291#endif /* of #ifdef _IP6_CFG */
292
293#endif /* of #ifndef _IP6_H_ */
Note: See TracBrowser for help on using the repository browser.