source: azure_iot_hub/trunk/asp3_dcre/tinet/netinet6/in6_var.h@ 388

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

Azure IoT Hub Device C SDK を使ったサンプルの追加

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