source: azure_iot_hub/trunk/asp3_dcre/tinet/netinet6/in6.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: 10.7 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.h 388 2019-05-22 11:25:18Z coas-nagasima $
44 */
45
46/* $FreeBSD: src/sys/netinet6/in6.h,v 1.7.2.4 2001/07/04 09:45:23 ume Exp $ */
47/* $KAME: in6.h,v 1.89 2001/05/27 13:28:35 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, 1990, 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.h 8.3 (Berkeley) 1/3/94
111 */
112
113#ifndef _IN6_H_
114#define _IN6_H_
115
116/*
117 * IPv6 アドレス構造
118 *
119 * RFC4291(RFC1884、RFC2373、RFC3513 のアップデート)
120 */
121
122/*
123 * IPv6 アドレス
124 */
125
126struct t_in6_addr {
127 union {
128 uint8_t __u6_addr8[16];
129 uint16_t __u6_addr16[8];
130 uint32_t __u6_addr32[4];
131 } __u6_addr;
132 };
133
134#define s6_addr __u6_addr.__u6_addr8
135#define s6_addr8 __u6_addr.__u6_addr8
136#define s6_addr16 __u6_addr.__u6_addr16
137#define s6_addr32 __u6_addr.__u6_addr32
138
139#ifndef T_IN6_ADDR_DEFINED
140
141typedef struct t_in6_addr T_IN6_ADDR;
142
143#define T_IN6_ADDR_DEFINED
144
145#endif /* of #ifndef T_IN6_ADDR_DEFINED */
146
147/*
148 * IPv6 アドレスの初期化データ
149 */
150
151#define IPV6_ADDR_UNSPECIFIED_INIT \
152 {{{ UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
153 UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
154 UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
155 UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00) }}}
156
157#define IPV6_ADDR_LINKLOCAL_ALLNODES_INIT \
158 {{{ UINT_C(0xff), UINT_C(0x02), UINT_C(0x00), UINT_C(0x00), \
159 UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
160 UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
161 UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x01) }}}
162
163#define IPV6_ADDR_LINKLOCAL_ALLROUTERS_INIT \
164 {{{ UINT_C(0xff), UINT_C(0x02), UINT_C(0x00), UINT_C(0x00), \
165 UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
166 UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
167 UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x02) }}}
168
169/*
170 * 特別なアドレスのチェック
171 */
172
173/* 無指定 */
174
175#define IN6_IS_ADDR_UNSPECIFIED(a) \
176 (memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR)) == 0)
177
178/* ループバック */
179
180#define IN6_IS_ADDR_LOOPBACK(a) \
181 (memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 1) == 0 && \
182 (a)->s6_addr8[15] == 0x01)
183
184/*
185 * スコープ ID
186 */
187
188#define IPV6_ADDR_SCOPE_NODELOCAL UINT_C(0x01)
189#define IPV6_ADDR_SCOPE_LINKLOCAL UINT_C(0x02)
190#define IPV6_ADDR_SCOPE_SITELOCAL UINT_C(0x05)
191#define IPV6_ADDR_SCOPE_ORGLOCAL UINT_C(0x08)
192#define IPV6_ADDR_SCOPE_GLOBAL UINT_C(0x0e)
193
194/*
195 * ユニキャスト・スコープ
196 *
197 * 注意: 上位 10 ビットのみチェックしなければならない。RFC2373 参ç…
198§
199 */
200
201/* リンクローカル */
202
203#define IN6_IS_ADDR_LINKLOCAL(a) \
204 (((a)->s6_addr8[0] == UINT_C(0xfe)) && (((a)->s6_addr8[1] & UINT_C(0xc0)) == UINT_C(0x80)))
205
206/* サイトローカル */
207
208#define IN6_IS_ADDR_SITELOCAL(a) \
209 (((a)->s6_addr8[0] == UINT_C(0xfe)) && (((a)->s6_addr8[1] & UINT_C(0xc0)) == UINT_C(0xc0)))
210
211/* 集約可能ユニキャスト (グローバル) */
212
213#define IN6_IS_ADDR_AGGREGATE_UNICAST(a) \
214 (((a)->s6_addr8[0] & UINT_C(0xe0)) == UINT_C(0x20))
215
216/*
217 * マルチキャスト
218 */
219
220#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr8[0] == UINT_C(0xff))
221
222/*
223 * 同一のチェック
224 */
225
226#define IN6_ARE_ADDR_EQUAL(a,b) (memcmp((a), (b), sizeof(T_IN6_ADDR)) == 0)
227
228/*
229 * 経路制御用定義
230 */
231
232#define IPV6_RTHDR_TYPE_0 UINT_C(0) /* IPv6 経路制御ヘッダタイプ 0 */
233
234/*
235 * 規定値と制限値
236 */
237
238#define IPV6_DEFAULT_MULTICAST_HOPS 1 /* マルチキャスト時のホップリミットの規定値 */
239#define ND6_INFINITE_LIFETIME 0xffffffff /* アドレスの無制限有効時間 */
240
241/*
242 * ITRON TCP/IPv6 アドレス/ポート番号の定義
243 */
244
245typedef struct t_ipv6ep {
246 T_IN6_ADDR ipaddr; /* IPv6 アドレス */
247 uint16_t portno; /* ポート番号 */
248 } T_IPV6EP;
249
250#define T_IPV6EP_DEFINED
251
252/*
253 * ITRON/TCP/IP 用 IP アドレスの定義
254 */
255
256#define IPV6_ADDRANY IPV6_ADDR_UNSPECIFIED_INIT
257
258/*
259 * 動的生成用 IPv6 TCP 受付口
260 */
261
262typedef struct t_tcp6_crep {
263 /* 標準 */
264 ATR repatr; /* 受付口属性 */
265 T_IPV6EP myaddr; /* 自分のアドレス */
266 /* 実装
267依存 */
268 } T_TCP6_CREP;
269
270/*
271 * 動的生成用 IPv6 UDP 通信端点
272 */
273
274typedef struct t_udp6_ccep {
275 /* 標準 */
276 ATR cepatr; /* UDP 通信端点属性 */
277 T_IPV6EP myaddr; /* 自分のアドレス */
278 FP callback; /* コールバック関数 */
279 /* 実装
280依存 */
281 } T_UDP6_CCEP;
282
283/*
284 * 前方参ç…
285§
286 */
287
288#ifndef T_IFNET_DEFINED
289
290typedef struct t_ifnet T_IFNET;
291
292#define T_IFNET_DEFINED
293
294#endif /* of #ifndef T_IFNET_DEFINED */
295
296/*
297 * å…
298¨åŸŸå¤‰æ•°
299 */
300
301extern const T_IN6_ADDR in6_addr_unspecified;
302extern const T_IN6_ADDR in6_addr_linklocal_allnodes;
303extern const T_IN6_ADDR in6_addr_linklocal_allrouters;
304
305#define ipv6_addrany in6_addr_unspecified
306
307/*
308 * TINET 独自 API
309 */
310
311extern char *ipv62str (char *buf, const T_IN6_ADDR *p_addr);
312extern uint_t in6_get_maxnum_ifaddr (void);
313extern const T_IN6_ADDR *in6_get_ifaddr (int_t index);
314extern ER in6_upd_ifaddr (T_IN6_ADDR *addr, uint_t prefixlen,
315 uint32_t vltime, uint32_t pltime);
316extern ER in6_del_ifaddr (T_IN6_ADDR *addr);
317extern T_IN6_ADDR *in6_make_ipv4mapped (T_IN6_ADDR *dst, T_IN4_ADDR src);
318extern bool_t in6_is_addr_ipv4mapped (const T_IN6_ADDR *addr);
319
320#endif /* of #ifndef _IN6_H_ */
Note: See TracBrowser for help on using the repository browser.