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