source: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_var.h@ 331

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

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 14.8 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/netinet6/in6_var.h,v 1.3.2.2 2001/07/03 11:01:52 ume Exp $ */
35/* $KAME: in6_var.h,v 1.56 2001/03/29 05:34:31 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) 1985, 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 * @(#)in_var.h 8.1 (Berkeley) 6/10/93
99 */
100
101#ifndef _IN6_VAR_H_
102#define _IN6_VAR_H_
103
104/*
105 * アドレスの定義
106 */
107
108#ifdef _NET_CFG_BYTE_ORDER
109
110#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
111
112#define IPV6_ADDR_INT32_ONE ULONG_C(0x00000001)
113#define IPV6_ADDR_INT32_TWO ULONG_C(0x00000002)
114#define IPV6_ADDR_INT32_0000FFFF ULONG_C(0x0000ffff)
115#define IPV6_ADDR_INT32_MNL ULONG_C(0xff010000)
116#define IPV6_ADDR_INT32_MLL ULONG_C(0xff020000)
117#define IPV6_ADDR_INT32_ULL ULONG_C(0xfe800000)
118#define IPV6_ADDR_INT16_ULL UINT_C(0xfe80)
119#define IPV6_ADDR_INT16_USL UINT_C(0xfec0)
120#define IPV6_ADDR_INT16_MLL UINT_C(0xff02)
121
122#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
123
124#define IPV6_ADDR_INT32_ONE ULONG_C(0x01000000)
125#define IPV6_ADDR_INT32_TWO ULONG_C(0x02000000)
126#define IPV6_ADDR_INT32_0000FFFF ULONG_C(0xffff0000)
127#define IPV6_ADDR_INT32_MNL ULONG_C(0x000001ff)
128#define IPV6_ADDR_INT32_MLL ULONG_C(0x000002ff)
129#define IPV6_ADDR_INT32_ULL ULONG_C(0x000080fe)
130#define IPV6_ADDR_INT16_ULL UINT_C(0x80fe)
131#define IPV6_ADDR_INT16_USL UINT_C(0xc0fe)
132#define IPV6_ADDR_INT16_MLL UINT_C(0x02ff)
133
134#endif /* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
135
136#endif /* of #ifdef _NET_CFG_BYTE_ORDER */
137
138/*
139 * 特別なアドレスのチェック
140 */
141
142/* IPv4 互換 */
143
144#ifdef _NET_CFG_BYTE_ORDER
145#define IN6_IS_ADDR_V4COMPAT(a) \
146 (memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 4) == 0 && \
147 (a)->s6_addr32[3] > IPV6_ADDR_INT32_ONE)
148#endif
149
150/* IPv4 射影 */
151
152#ifdef _NET_CFG_BYTE_ORDER
153#define IN6_IS_ADDR_V4MAPPED(a) \
154 (((a)->s6_addr32[0] == ULONG_C(0x00000000)) && \
155 ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
156 ((a)->s6_addr32[2] == IPV6_ADDR_INT32_0000FFFF))
157#endif
158
159/* 要請マルチキャスト */
160
161#ifdef _NET_CFG_BYTE_ORDER
162#define IN6_IS_ADDR_NS_MULTICAST(a) \
163 (((a)->s6_addr32[0] == IPV6_ADDR_INT32_MLL) && \
164 ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
165 ((a)->s6_addr32[2] == IPV6_ADDR_INT32_ONE) && \
166 ((a)->s6_addr8[12] == UINT_C(0xff)))
167#endif
168
169#ifndef _MACRO_ONLY
170
171/*
172 * アドレス有効時間構造体
173 */
174
175typedef struct in6_addr_lifetime {
176
177 /*
178 * expire と perferred は、システムが起動してからの経過時間
179 */
180 uint32_t expire; /* 有効時間が切れる時刻 [s] */
181 uint32_t preferred; /* 推奨有効時間が切れる時刻 [s] */
182
183 /*
184 * vltime と pltime は、追加/変更してからの相対時間
185 */
186 uint32_t vltime; /* 有効時間 [ms] */
187 uint32_t pltime; /* 推奨有効時間 [ms] */
188 } __attribute__((packed, aligned(2)))T_IN6_ADDR_LIFETIME;
189
190/*
191 * インタフェースアドレス構造体
192 */
193
194typedef struct t_in6_ifaddr {
195 T_IN6_ADDR addr; /* IPv6 アドレス */
196 T_IN6_ADDR_LIFETIME lifetime; /* 有効時間 */
197 uint8_t flags; /* フラグ */
198 uint8_t prefix_len; /* プレフィックス長 */
199 uint8_t router_index; /* ルータインデックス */
200 uint8_t prefix_index; /* プレフィックスインデックス */
201 uint8_t na_icount; /* 重複アドレス検出 (DAD) 通知の入力回数 */
202 uint8_t ns_icount; /* 重複アドレス検出 (DAD) 要請の入力回数 */
203 uint8_t ns_ocount; /* 重複アドレス検出 (DAD) 要請の出力回数 */
204 } __attribute__((packed, aligned(2)))T_IN6_IFADDR;
205
206/*
207 * アドレス状態フラグ
208 */
209
210#define IN6_IFF_ANYCAST UINT_C(0x01) /* エニーキャスト */
211#define IN6_IFF_DEFINED UINT_C(0x02) /* 定義済み */
212#define IN6_IFF_TENTATIVE UINT_C(0x04) /* 重複検出中 */
213#define IN6_IFF_DUPLICATED UINT_C(0x08) /* 重複を検出した */
214#define IN6_IFF_DEPRECATED UINT_C(0x10) /* 非推奨 */
215#define IN6_IFF_NODAD UINT_C(0x20) /* 重複検出不要 */
216#define IN6_IFF_AUTOCONF UINT_C(0x40) /* 自動設定された */
217#define IN6_IFF_DETACHED UINT_C(0x80) /* 非使用 */
218
219/*
220 * アドレスの有効性チェック
221 */
222
223#define IFA6_IS_READY(a) (((a)->flags & IN6_IFF_DEFINED) != 0 && \
224 ((a)->flags & (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED|IN6_IFF_DETACHED)) == 0)
225#define IFA6_IS_NOTREADY(a) (((a)->flags & IN6_IFF_DEFINED) == 0 || \
226 ((a)->flags & (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED|IN6_IFF_DETACHED)) != 0)
227
228#define IFA6_IS_DEPRECATED(a,n) \
229 ((a)->lifetime.preferred != 0 && (int32_t)((a)->lifetime.preferred - ((n / SYSTIM_HZ))) < 0)
230
231#define IFA6_IS_INVALID(a,n) \
232 ((a)->lifetime.expire != 0 && (int32_t)((a)->lifetime.expire - ((n / SYSTIM_HZ))) < 0)
233
234/*
235 * ルータのインデックス
236 */
237
238#define IN6_RTR_IX_UNREACH 0xff
239
240/*
241 * 制限値
242 */
243
244#define IP6_HDR_NEST_LIMIT 50 /* IPv6 ヘッダのネスト制限値 */
245
246/*
247 * アドレス情報配列のインデックス
248 */
249
250#define IPV6_IFADDR_IX_LINKLOCAL 0
251#define IPV6_IFADDR_IX_INVALID 0xff
252
253/*
254 * IPv6 マルチキャストアドレス配列のインデックス
255 */
256
257#define IPV6_MADDR_IX_SOL_NODE 0 /* 要請マルチキャスト・アドレス */
258#define IPV6_MADDR_IX_LL_ALL_NODE 1 /* 全ノード・リンクローカル・マルチキャストアドレス */
259#define IPV6_MADDR_IX_EXTRA 2
260
261#define MAX_IN6_MADDR_CNT MAX_IF_MADDR_CNT
262 /* IPv6 マルチキャストアドレス配列の最大サイズ */
263
264/* ルーティング表エントリ構造体 */
265
266typedef struct t_in6_rtentry {
267 T_IN6_ADDR target; /* 目標ネットワークアドレス */
268 T_IN6_ADDR gateway; /* ゲートウェイの IP アドレス */
269 uint32_t expire; /* 有効時間が切れる時刻 [s] */
270 uint8_t flags; /* フラグ */
271 uint8_t prefix_len; /* プレフィックス長 */
272 } __attribute__((packed, aligned(2)))T_IN6_RTENTRY;
273
274/*
275 * ホストキャッシュ
276 */
277
278/* ホストキャッシュ構造体 */
279
280typedef struct t_in6_hostcache_entry {
281 T_IN6_ADDR dst; /* 目標ネットワークアドレス */
282 uint32_t expire; /* 有効時間が切れる時刻 [s] */
283 uint32_t mtu; /* Path MTU */
284 } __attribute__((packed, aligned(2)))T_IN6_HOSTCACHE_ENTRY;
285
286#define IN6_HOSTCACHE_EXPIRE (60*60*SYSTIM_HZ) /* 有効時間 */
287#define IN6_HOSTCACHE_PRUNE (5*60*SYSTIM_HZ) /* 更新間隔 */
288#define IN6_HOSTCACHE_INCREASE (10*60*SYSTIM_HZ) /* 増加する場合の保護時間 */
289
290#define IN6_IS_HOSTCACHE_FREE(e) IN6_IS_ADDR_UNSPECIFIED(&((e)->dst))
291#define IN6_IS_HOSTCACHE_BUSY(e) (!IN6_IS_HOSTCACHE_FREE(e))
292
293/*
294 * ルーティング表
295 */
296
297extern T_IN6_RTENTRY routing6_tbl[];
298
299/*
300 * 前方参照
301 */
302
303#ifndef T_IFNET_DEFINED
304
305typedef struct t_ifnet T_IFNET;
306
307#define T_IFNET_DEFINED
308
309#endif /* of #ifndef T_IFNET_DEFINED */
310
311/*
312 * 変数
313 */
314
315extern uint32_t linkmtu;
316
317/*
318 * 関数シミュレーションマクロ
319 */
320
321#define IN6_COPY_TO_HOST(dst,nbuf) memcpy(dst,&GET_IP6_HDR(nbuf)->src,sizeof(T_IN6_ADDR))
322#define INN6_IS_DSTADDR_ACCEPT(addr,nbuf) \
323 in6_is_dstaddr_accept(addr,&GET_IP6_HDR(nbuf)->dst)
324
325/*
326 * 関数
327 */
328
329extern void in6_ifainit (void);
330extern int_t in6_addr2maix (const T_IN6_ADDR *addr);
331extern ER in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr,
332 uint_t prefix_len, uint32_t vltime, uint32_t pltime,
333 int_t router_index, int_t prefix_index, uint_t flags);
334extern ER in6_set_header (T_NET_BUF *nbuf, uint_t len,
335 const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
336 uint8_t next, uint8_t hlim);
337extern ER in6_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
338 const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
339 uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout);
340extern uint16_t in6_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len);
341extern T_IN6_IFADDR *in6ifa_ifpwithix (T_IFNET *ifp, int_t ix);
342extern T_IN6_IFADDR *in6ifa_ifpwithrtrix (T_IFNET *ifp, int_t rtr_ix);
343extern T_IN6_IFADDR *in6_ifawithifp (T_IFNET *ifp, const T_IN6_ADDR *dst);
344extern const T_IN6_ADDR *in6_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, const T_IN6_ADDR *dst);
345extern void ip6_input (T_NET_BUF *input);
346extern T_IN6_IFADDR *in6_lookup_ifaddr (T_IFNET *ifp, const T_IN6_ADDR *addr);
347extern bool_t in6_lookup_multi (T_IFNET *ifp, const T_IN6_ADDR *maddr);
348extern bool_t in6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, const T_IN6_ADDR *dstaddr);
349extern bool_t inn6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, T_NET_BUF *input);
350extern const T_IN6_ADDR *in6_rtalloc (T_IFNET *ifp, const T_IN6_ADDR *dst);
351extern int_t in6_if2idlen (T_IFNET *ifp);
352extern int_t in6_addr2ifaix (const T_IN6_ADDR *addr);
353extern void in6_plen2pmask (T_IN6_ADDR *mask, uint_t prefix_len);
354extern bool_t in6_are_prefix_equal (const T_IN6_ADDR *addr, const T_IN6_ADDR *prefix,
355 uint_t prefix_len);
356extern void in6_ifaddr_timer (T_IFNET *ifp);
357extern T_IN6_RTENTRY *in6_gateway_lookup (const T_IN6_ADDR *src);
358extern void in6_rtredirect (const T_IN6_ADDR *gateway, const T_IN6_ADDR *target,
359 uint_t prefix_len, uint8_t flags, uint32_t tmo);
360extern void in6_init (void);
361extern void in6_if_up (T_IFNET *ifp);
362extern void in6_hostcache_update (T_IN6_ADDR *dst, uint32_t mtu);
363extern uint32_t in6_hostcache_getmtu (const T_IN6_ADDR *dst);
364extern uint_t in6_addrscope (const T_IN6_ADDR *addr);
365extern const T_NET_BUF**ip6_get_frag_queue (void);
366
367#endif /* of #ifndef _MACRO_ONLY */
368
369#endif /* of #ifndef _IN6_VAR_H_ */
Note: See TracBrowser for help on using the repository browser.