source: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_var.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: 12.8 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 * 上記著作権者
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_var.h 270 2017-02-09 04:03:47Z coas-nagasima $
44 */
45
46/* $FreeBSD: src/sys/netinet6/ip6_var.h,v 1.10 2002/10/16 01:54:45 sam Exp $ */
47/* $KAME: ip6_var.h,v 1.62 2001/05/03 14:51:48 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_var.h 8.1 (Berkeley) 6/10/93
111 */
112
113#ifndef _IP6_VAR_H_
114#define _IP6_VAR_H_
115
116#ifdef SUPPORT_INET6
117
118/*
119 * IPv6 ヘッダ・ペイロードアクセスマクロ
120 */
121
122#define IF_IP6_HDR_SIZE (IF_HDR_SIZE + IP6_HDR_SIZE)
123
124#define GET_IP6_HDR(nbuf) ((T_IP6_HDR*)((nbuf)->buf + IF_HDR_SIZE))
125#define GET_IP6_SDU(nbuf) ((uint8_t*)((nbuf)->buf) + GET_IF_IP6_HDR_SIZE(nbuf))
126#define GET_IP6_NEXT_HDR(nbuf) ((uint8_t*)((nbuf)->buf) + IF_IP6_HDR_SIZE)
127
128#define GET_IP6_HDR_SIZE(iph) (get_ip6_hdr_size(iph))
129#define GET_IP6_SDU_SIZE(iph) (ntohs((iph)->plen))
130#define GET_IF_IP6_HDR_SIZE(nbuf) (IF_HDR_SIZE + (GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf))))
131
132#define SET_IP6_SDU_SIZE(iph,slen) ((iph)->plen=htons(slen))
133
134/* ip6_output のフラグ */
135
136#define IPV6_OUT_FLG_DAD 0x0100 /* 重複アドレス検出 */
137#define IPV6_OUT_FLG_HOP_LIMIT 0x0200 /* ホップリミット指定 */
138
139/* ホップリミットフラグが付く時、ホップリミット値を操作するマクロ */
140
141#define IPV6_OUT_GET_HOP_LIMIT(f) ((f)&0x00ff)
142#define IPV6_OUT_SET_HOP_LIMIT(f,l) ((f)|(l))
143
144/*
145 * ip6_unknown_opt -- 未知のオプションの処理
146 *
147 * 戻り値:
148 *
149 * 0 以上 正常、オプション長。
150 * IP6_OPT_RET_ERR (-1) エラー、呼出側でネットワークバッファを開放する。
151 * IP6_OPT_RET_REL (-2) エラー、ネットワークバッファは開放されている。
152 */
153
154#define IP6_OPT_RET_ERR (-1)
155#define IP6_OPT_RET_REL (-2)
156
157/*
158 * IPv4 と IPv6 をコンパイル時に選択するためのマクロ
159 */
160
161#define T_TCP_IP_Q_HDR T_TCP_IP6_Q_HDR
162
163#define IF_IP_HDR_SIZE IF_IP6_HDR_SIZE
164
165#define GET_IP_HDR(nbuf) GET_IP6_HDR(nbuf)
166#define GET_IP_SDU(nbuf) GET_IP6_SDU(nbuf)
167
168#define GET_IP_HDR_SIZE(iph) GET_IP6_HDR_SIZE(iph)
169#define GET_IP_SDU_SIZE(iph) GET_IP6_SDU_SIZE(iph)
170#define GET_IF_IP_HDR_SIZE(nbuf) GET_IF_IP6_HDR_SIZE(nbuf)
171
172#define SET_IP_SDU_SIZE(iph,len) SET_IP6_SDU_SIZE(iph,len)
173
174#define IP_OUTPUT(nbuf,tmout) ip6_output(nbuf,0,tmout)
175#define IP_INIT() ip6_init()
176#define IP_REMOVE_OPTIONS(nbuf) ip6_remove_exthdrs(nbuf)
177
178/*
179 * IPv6 の MMTU サイズのネットワークバッファ
180 */
181
182typedef struct t_net_buf_ipv6_mmtu {
183 uint16_t len; /* データの長さ */
184 uint8_t idix; /* mpfid のインデックス */
185 uint8_t unit; /* インタフェース番号 */
186#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
187 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
188#endif
189#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
190 uint8_t halign[4 - IF_HDR_ALIGN];
191#endif
192 uint8_t buf[IF_HDR_SIZE + IPV6_MMTU];
193 /* バッファ本体 */
194 } T_NET_BUF_IPV6_MMTU;
195
196/*
197 * 65536 オクテットサイズのネットワークバッファ
198 */
199
200typedef struct t_net_buf6_65536 {
201 uint16_t len; /* データの長さ */
202 uint8_t idix; /* mpfid のインデックス */
203 uint8_t flags; /* フラグ */
204#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
205 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
206#endif
207#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
208 uint8_t halign[4 - IF_HDR_ALIGN];
209#endif
210 uint8_t buf[IF_IP6_HDR_SIZE + 65536];
211 /* バッファ本体 */
212#if defined(IF_PDU_HDR_PADDING)
213 uint8_t padding[IF_PDU_HDR_PADDING];
214#endif /* ヘッダの余分 */
215 } T_NET_BUF6_65536;
216
217#ifdef IP6_CFG_FRAGMENT
218
219/*
220 * 再構成キュー用 IPv6 ヘッダの定義
221 */
222
223typedef struct t_qip6_hdr {
224 uint32_t vcf; /* Version: 4 bit */
225 /* Traffic Class: 8 bit */
226 /* Flow Label: 20 bit */
227 uint16_t plen; /* Payload Length */
228 uint8_t next; /* Next Header */
229 uint8_t hlim; /* Hop Limit */
230 T_IN6_ADDR src; /* Source Address */
231 T_NET_BUF *next_frag; /* 次の IPv6 フラグメント */
232 uint16_t foff; /* 断片ヘッダのオフセット */
233 uint16_t flen; /* 断片長 */
234 uint16_t ftim; /* 再構成タイムアウト */
235 uint16_t dummy1;
236 uint8_t dummy2[sizeof(T_IN6_ADDR) - (sizeof(T_NET_BUF*) + sizeof(uint16_t) * 4)];
237 } __attribute__((packed, aligned(2)))T_QIP6_HDR;
238
239#define QIP6_HDR_SIZE (sizeof(T_QIP6_HDR))
240#define IF_QIP6_HDR_SIZE (IF_HDR_SIZE + QIP6_HDR_SIZE)
241
242#define GET_QIP6_HDR(nbuf) ((T_QIP6_HDR*)((nbuf)->buf + IF_HDR_SIZE))
243#define GET_QIP6_SDU(nbuf) ((uint8_t*)(nbuf)->buf + GET_IF_QIP6_HDR_SIZE(nbuf))
244
245#define GET_QIP6_HDR_SIZE(iph) ((uint8_t)IP6_VHL_HL((iph)->vhl) << 2)
246#define GET_IF_QIP6_HDR_SIZE(nbuf) (IF_HDR_SIZE + (GET_QIP6_HDR_SIZE(GET_QIP6_HDR(nbuf))))
247
248/*
249 * データグラム再構成用ネットワークバッファ
250 */
251
252typedef struct t_net_buf6_reassm {
253 uint16_t len; /* データの長さ */
254 uint8_t idix; /* mpfid のインデックス */
255 uint8_t flags; /* フラグ */
256#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
257 uint8_t nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
258#endif
259#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
260 uint8_t align[4 - IF_HDR_ALIGN];
261#endif
262 uint8_t buf[IP6_CFG_FRAG_REASSM_SIZE];
263 /* バッファ本体 */
264 } T_NET_BUF6_REASSM;
265
266#endif /* of #ifdef IP6_CFG_FRAGMENT */
267
268/*
269 * TCP の再構成キューにおける IPv6 ヘッダの定義
270 */
271
272typedef struct t_tcp_ip6_q_hdr {
273 uint8_t vc; /* Version: 4 bit */
274 uint8_t cf; /* Traffic Class: 8 bit */
275 /* Flow Label: 4 bit (20 bit) */
276 uint16_t thoff; /* TCP ヘッダのオフセット */
277 uint16_t plen; /* Payload Length */
278 uint8_t next; /* Next Header */
279 uint8_t hlim; /* Hop Limit */
280 T_IN6_ADDR src; /* Source Address */
281 T_IN6_ADDR dst; /* Destination Address */
282 } __attribute__((packed, aligned(2)))T_TCP_IP6_Q_HDR;
283
284#ifdef SUPPORT_MIB
285
286/*
287 * SNMP の 管理情
288報ベース (MIB)
289 */
290
291typedef struct t_in6_ifstat {
292 uint32_t ipv6IfStatsInReceives;
293 uint32_t ipv6IfStatsInHdrErrors;
294/* uint32_t ipv6IfStatsInTooBigErrors;*/
295/* uint32_t ipv6IfStatsInNoRoutes;*/
296 uint32_t ipv6IfStatsInAddrErrors;
297 uint32_t ipv6IfStatsInUnknownProtos;
298 uint32_t ipv6IfStatsInTruncatedPkts;
299/* uint32_t ipv6IfStatsInDiscards;*/
300/* uint32_t ipv6IfStatsInDelivers;*/
301/* uint32_t ipv6IfStatsOutForwDatagrams;*/
302 uint32_t ipv6IfStatsOutRequests;
303 uint32_t ipv6IfStatsOutDiscards;
304 uint32_t ipv6IfStatsOutFragOKs;
305 uint32_t ipv6IfStatsOutFragFails;
306 uint32_t ipv6IfStatsOutFragCreates;
307 uint32_t ipv6IfStatsReasmReqds;
308 uint32_t ipv6IfStatsReasmOKs;
309 uint32_t ipv6IfStatsReasmFails;
310 uint32_t ipv6IfStatsInMcastPkts;
311 uint32_t ipv6IfStatsOutMcastPkts;
312} T_IN6_IFSTAT;
313
314extern T_IN6_IFSTAT in6_ifstat;
315
316#endif /* of #ifdef SUPPORT_MIB */
317
318/*
319 * 関数
320 */
321
322extern ER ip6_output (T_NET_BUF *output, uint16_t flags, TMO tmout);
323extern void ip6_init (void);
324extern uint8_t *ip6_get_prev_hdr (T_NET_BUF *nbuf, uint_t off);
325extern uint_t get_ip6_hdr_size (T_IP6_HDR *iph);
326extern ER_UINT ip6_nexthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp);
327extern ER_UINT ip6_lasthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp);
328extern ER_UINT ip6_unknown_opt (T_NET_BUF *input, uint8_t *opt);
329extern uint_t dest6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
330extern uint_t route6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
331extern uint_t frag6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
332extern void frag6_timer (void);
333extern ER ip6_remove_exthdrs (T_NET_BUF *nbuf);
334
335#endif /* of #ifdef SUPPORT_INET6 */
336
337#endif /* of #ifndef _IP6_VAR_H_ */
Note: See TracBrowser for help on using the repository browser.