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/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 | #ifdef SUPPORT_INET6
|
---|
105 |
|
---|
106 | /*
|
---|
107 | * アドレス有効時間構造体
|
---|
108 | */
|
---|
109 |
|
---|
110 | typedef struct in6_addr_lifetime {
|
---|
111 |
|
---|
112 | /*
|
---|
113 | * expire と perferred は、システムが起動してからの経過時間
|
---|
114 | */
|
---|
115 | uint32_t expire; /* 有効時間が切れる時刻 [s] */
|
---|
116 | uint32_t preferred; /* 推奨有効時間が切れる時刻 [s] */
|
---|
117 |
|
---|
118 | /*
|
---|
119 | * vltime と pltime は、追加/変更してからの相対時間
|
---|
120 | */
|
---|
121 | uint32_t vltime; /* 有効時間 [ms] */
|
---|
122 | uint32_t pltime; /* 推奨有効時間 [ms] */
|
---|
123 | } __attribute__((packed, aligned(2)))T_IN6_ADDR_LIFETIME;
|
---|
124 |
|
---|
125 | /*
|
---|
126 | * インタフェースアドレス構造体
|
---|
127 | */
|
---|
128 |
|
---|
129 | typedef struct t_in6_ifaddr {
|
---|
130 | T_IN6_ADDR addr; /* IPv6 アドレス */
|
---|
131 | T_IN6_ADDR_LIFETIME lifetime; /* 有効時間 */
|
---|
132 | uint8_t flags; /* フラグ */
|
---|
133 | uint8_t prefix_len; /* プレフィックス長 */
|
---|
134 | uint8_t router_index; /* ルータインデックス */
|
---|
135 | uint8_t prefix_index; /* プレフィックスインデックス */
|
---|
136 | uint8_t na_icount; /* 重複アドレス検出 (DAD) 通知の入力回数 */
|
---|
137 | uint8_t ns_icount; /* 重複アドレス検出 (DAD) 要請の入力回数 */
|
---|
138 | uint8_t ns_ocount; /* 重複アドレス検出 (DAD) 要請の出力回数 */
|
---|
139 | } __attribute__((packed, aligned(2)))T_IN6_IFADDR;
|
---|
140 |
|
---|
141 | /*
|
---|
142 | * アドレス状態フラグ
|
---|
143 | */
|
---|
144 |
|
---|
145 | #define IN6_IFF_ANYCAST UINT_C(0x01) /* エニーキャスト */
|
---|
146 | #define IN6_IFF_DEFINED UINT_C(0x02) /* 定義済み */
|
---|
147 | #define IN6_IFF_TENTATIVE UINT_C(0x04) /* 重複検出中 */
|
---|
148 | #define IN6_IFF_DUPLICATED UINT_C(0x08) /* 重複を検出した */
|
---|
149 | #define IN6_IFF_DEPRECATED UINT_C(0x10) /* 非推奨 */
|
---|
150 | #define IN6_IFF_NODAD UINT_C(0x20) /* 重複検出不要 */
|
---|
151 | #define IN6_IFF_AUTOCONF UINT_C(0x40) /* 自動設定された */
|
---|
152 | #define IN6_IFF_DETACHED UINT_C(0x80) /* 非使用 */
|
---|
153 |
|
---|
154 | /*
|
---|
155 | * アドレスの有効性チェック
|
---|
156 | */
|
---|
157 |
|
---|
158 | #define IFA6_IS_READY(a) (((a)->flags & IN6_IFF_DEFINED) != 0 && \
|
---|
159 | ((a)->flags & (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED|IN6_IFF_DETACHED)) == 0)
|
---|
160 | #define IFA6_IS_NOTREADY(a) (((a)->flags & IN6_IFF_DEFINED) == 0 || \
|
---|
161 | ((a)->flags & (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED|IN6_IFF_DETACHED)) != 0)
|
---|
162 |
|
---|
163 | #define IFA6_IS_DEPRECATED(a,n) \
|
---|
164 | ((a)->lifetime.preferred != 0 && (int32_t)((a)->lifetime.preferred - ((n / SYSTIM_HZ))) < 0)
|
---|
165 |
|
---|
166 | #define IFA6_IS_INVALID(a,n) \
|
---|
167 | ((a)->lifetime.expire != 0 && (int32_t)((a)->lifetime.expire - ((n / SYSTIM_HZ))) < 0)
|
---|
168 |
|
---|
169 | /*
|
---|
170 | * ルータのインデックス
|
---|
171 | */
|
---|
172 |
|
---|
173 | #define IN6_RTR_IX_UNREACH 0xff
|
---|
174 |
|
---|
175 | /*
|
---|
176 | * 制限値
|
---|
177 | */
|
---|
178 |
|
---|
179 | #define IP6_HDR_NEST_LIMIT 50 /* IPv6 ヘッダのネスト制限値 */
|
---|
180 |
|
---|
181 | /*
|
---|
182 | * アドレス情報配列のインデックス
|
---|
183 | */
|
---|
184 |
|
---|
185 | #define IPV6_IFADDR_IX_LINKLOCAL 0
|
---|
186 | #define IPV6_IFADDR_IX_INVALID 0xff
|
---|
187 |
|
---|
188 | /*
|
---|
189 | * IPv6 マルチキャストアドレス配列のインデックス
|
---|
190 | */
|
---|
191 |
|
---|
192 | #define IPV6_MADDR_IX_SOL_NODE 0 /* 要請マルチキャスト・アドレス */
|
---|
193 | #define IPV6_MADDR_IX_LL_ALL_NODE 1 /* 全ノード・リンクローカル・マルチキャストアドレス */
|
---|
194 | #define IPV6_MADDR_IX_EXTRA 2
|
---|
195 |
|
---|
196 | #define MAX_IN6_MADDR_CNT MAX_IF_MADDR_CNT
|
---|
197 | /* IPv6 マルチキャストアドレス配列の最大サイズ */
|
---|
198 |
|
---|
199 | /*
|
---|
200 | * ルーティングの制御
|
---|
201 | */
|
---|
202 |
|
---|
203 | /* ルーティング表エントリ構造体 */
|
---|
204 |
|
---|
205 | typedef struct t_in6_rtentry {
|
---|
206 | T_IN6_ADDR target; /* 目標ネットワークアドレス */
|
---|
207 | T_IN6_ADDR gateway; /* ゲートウェイの IP アドレス */
|
---|
208 | uint32_t expire; /* 有効時間が切れる時刻 [s] */
|
---|
209 | uint8_t flags; /* フラグ */
|
---|
210 | uint8_t prefix_len; /* プレフィックス長 */
|
---|
211 | } __attribute__((packed, aligned(2)))T_IN6_RTENTRY;
|
---|
212 |
|
---|
213 | /*
|
---|
214 | * ホストキャッシュ
|
---|
215 | */
|
---|
216 |
|
---|
217 | /* ホストキャッシュ構造体 */
|
---|
218 |
|
---|
219 | typedef struct t_in6_hostcache_entry {
|
---|
220 | T_IN6_ADDR dst; /* 目標ネットワークアドレス */
|
---|
221 | uint32_t expire; /* 有効時間が切れる時刻 [s] */
|
---|
222 | uint32_t mtu; /* Path MTU */
|
---|
223 | } __attribute__((packed, aligned(2)))T_IN6_HOSTCACHE_ENTRY;
|
---|
224 |
|
---|
225 | #define IN6_HOSTCACHE_EXPIRE (60*60*SYSTIM_HZ) /* 有効時間 */
|
---|
226 | #define IN6_HOSTCACHE_PRUNE (5*60*SYSTIM_HZ) /* 更新間隔 */
|
---|
227 | #define IN6_HOSTCACHE_INCREASE (10*60*SYSTIM_HZ) /* 増加する場合の保護時間 */
|
---|
228 |
|
---|
229 | #define IN6_IS_HOSTCACHE_FREE(e) IN6_IS_ADDR_UNSPECIFIED(&((e)->dst))
|
---|
230 | #define IN6_IS_HOSTCACHE_BUSY(e) (!IN6_IS_HOSTCACHE_FREE(e))
|
---|
231 |
|
---|
232 | /*
|
---|
233 | * IPv4 と IPv6 をコンパイル時に選択するためのマクロ
|
---|
234 | */
|
---|
235 |
|
---|
236 | #define IN_SET_HEADER(nbuf,len,dst,src,next,hlim) \
|
---|
237 | in6_set_header(nbuf,len,dst,src,next,hlim)
|
---|
238 | #define IN_GET_DATAGRAM(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout) \
|
---|
239 | in6_get_datagram(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)
|
---|
240 | #define IN_CKSUM(nbuf,proto,off,len) in6_cksum(nbuf,proto,off,len)
|
---|
241 | #define IN_IS_DSTADDR_ACCEPT(myaddr,dstaddr) \
|
---|
242 | in6_is_dstaddr_accept(myaddr,dstaddr)
|
---|
243 | #define IN_IFAWITHIFP(ifp,dst) in6_ifawithifp(ifp,dst)
|
---|
244 | #define T_IN_IFADDR T_IN6_IFADDR
|
---|
245 | #define T_IN_RTENTRY T_IN6_RTENTRY
|
---|
246 |
|
---|
247 | /*
|
---|
248 | * 前方参照
|
---|
249 | */
|
---|
250 |
|
---|
251 | #ifndef T_IFNET_DEFINED
|
---|
252 |
|
---|
253 | typedef struct t_ifnet T_IFNET;
|
---|
254 |
|
---|
255 | #define T_IFNET_DEFINED
|
---|
256 |
|
---|
257 | #endif /* of #ifndef T_IFNET_DEFINED */
|
---|
258 |
|
---|
259 | /*
|
---|
260 | * 変数
|
---|
261 | */
|
---|
262 |
|
---|
263 | extern uint32_t linkmtu;
|
---|
264 |
|
---|
265 | /*
|
---|
266 | * 関数
|
---|
267 | */
|
---|
268 |
|
---|
269 | extern void in6_ifainit (void);
|
---|
270 | extern int_t in6_addr2maix (T_IN6_ADDR *addr);
|
---|
271 | extern ER in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, T_IN6_ADDR *addr,
|
---|
272 | uint_t prefix_len, uint32_t vltime, uint32_t pltime,
|
---|
273 | int_t router_index, int_t prefix_index, uint_t flags);
|
---|
274 | extern ER in6_set_header (T_NET_BUF *nbuf, uint_t len,
|
---|
275 | T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
|
---|
276 | uint8_t next, uint8_t hlim);
|
---|
277 | extern ER in6_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
|
---|
278 | T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
|
---|
279 | uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout);
|
---|
280 | extern uint16_t in6_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len);
|
---|
281 | extern T_IN6_IFADDR *in6ifa_ifpwithix (T_IFNET *ifp, int_t ix);
|
---|
282 | extern T_IN6_IFADDR *in6ifa_ifpwithrtrix (T_IFNET *ifp, int_t rtr_ix);
|
---|
283 | extern T_IN6_IFADDR *in6_ifawithifp (T_IFNET *ifp, T_IN6_ADDR *dst);
|
---|
284 | extern void ip6_input (T_NET_BUF *input);
|
---|
285 | extern T_IN6_IFADDR *in6_lookup_ifaddr (T_IFNET *ifp, T_IN6_ADDR *addr);
|
---|
286 | extern bool_t in6_lookup_multi (T_IFNET *ifp, T_IN6_ADDR *maddr);
|
---|
287 | extern bool_t in6_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_IN6_ADDR *dstaddr);
|
---|
288 | extern T_IN6_ADDR *in6_rtalloc (T_IFNET *ifp, T_IN6_ADDR *dst);
|
---|
289 | extern int_t in6_if2idlen (T_IFNET *ifp);
|
---|
290 | extern int_t in6_addr2ifaix (T_IN6_ADDR *addr);
|
---|
291 | extern void in6_plen2pmask (T_IN6_ADDR *mask, uint_t prefix_len);
|
---|
292 | extern bool_t in6_are_prefix_equal (T_IN6_ADDR *addr, T_IN6_ADDR *prefix,
|
---|
293 | uint_t prefix_len);
|
---|
294 | extern void in6_ifaddr_timer (T_IFNET *ifp);
|
---|
295 | extern T_IN6_RTENTRY *in6_gateway_lookup (T_IN6_ADDR *src);
|
---|
296 | extern void in6_rtredirect (T_IN6_ADDR *gateway, T_IN6_ADDR *target,
|
---|
297 | uint_t prefix_len, uint8_t flags, uint32_t tmo);
|
---|
298 | extern void in6_init (void);
|
---|
299 | extern void in6_if_up (T_IFNET *ifp);
|
---|
300 | extern void in6_hostcache_update (T_IN6_ADDR *dst, uint32_t mtu);
|
---|
301 | extern uint32_t in6_hostcache_getmtu (T_IN6_ADDR *dst);
|
---|
302 | extern uint_t in6_addrscope (T_IN6_ADDR *addr);
|
---|
303 | extern const T_NET_BUF**ip6_get_frag_queue (void);
|
---|
304 |
|
---|
305 | #endif /* of #ifdef SUPPORT_INET6 */
|
---|
306 |
|
---|
307 | #endif /* of #ifndef _IN6_VAR_H_ */
|
---|