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 |
|
---|
126 | struct 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 |
|
---|
141 | typedef 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 |
|
---|
245 | typedef 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 |
|
---|
262 | typedef 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 |
|
---|
274 | typedef 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 |
|
---|
290 | typedef 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 |
|
---|
301 | extern const T_IN6_ADDR in6_addr_unspecified;
|
---|
302 | extern const T_IN6_ADDR in6_addr_linklocal_allnodes;
|
---|
303 | extern const T_IN6_ADDR in6_addr_linklocal_allrouters;
|
---|
304 |
|
---|
305 | #define ipv6_addrany in6_addr_unspecified
|
---|
306 |
|
---|
307 | /*
|
---|
308 | * TINET ç¬èª API
|
---|
309 | */
|
---|
310 |
|
---|
311 | extern char *ipv62str (char *buf, const T_IN6_ADDR *p_addr);
|
---|
312 | extern uint_t in6_get_maxnum_ifaddr (void);
|
---|
313 | extern const T_IN6_ADDR *in6_get_ifaddr (int_t index);
|
---|
314 | extern ER in6_upd_ifaddr (T_IN6_ADDR *addr, uint_t prefixlen,
|
---|
315 | uint32_t vltime, uint32_t pltime);
|
---|
316 | extern ER in6_del_ifaddr (T_IN6_ADDR *addr);
|
---|
317 | extern T_IN6_ADDR *in6_make_ipv4mapped (T_IN6_ADDR *dst, T_IN4_ADDR src);
|
---|
318 | extern bool_t in6_is_addr_ipv4mapped (const T_IN6_ADDR *addr);
|
---|
319 |
|
---|
320 | #endif /* of #ifndef _IN6_H_ */
|
---|