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