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 | * ä¸è¨èä½æ¨©è
|
---|
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.h 270 2017-02-09 04:03:47Z coas-nagasima $
|
---|
44 | */
|
---|
45 |
|
---|
46 | /* $FreeBSD: src/sys/netinet/ip6.h,v 1.2.2.2 2001/07/03 11:01:46 ume Exp $ */
|
---|
47 | /* $KAME: ip6.h,v 1.18 2001/03/29 05:34:30 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.h 8.1 (Berkeley) 6/10/93
|
---|
111 | */
|
---|
112 |
|
---|
113 | #ifndef _IP6_H_
|
---|
114 | #define _IP6_H_
|
---|
115 |
|
---|
116 | #ifdef SUPPORT_INET6
|
---|
117 |
|
---|
118 | /*
|
---|
119 | * IPv6 ã®å®ç¾©ãRFC2460 åç
|
---|
120 | §
|
---|
121 | */
|
---|
122 |
|
---|
123 | #define IPV6_VERSION 6
|
---|
124 |
|
---|
125 | /*
|
---|
126 | * IPv6 ãããã®å®ç¾©
|
---|
127 | */
|
---|
128 |
|
---|
129 | typedef struct t_ip6_hdr {
|
---|
130 | uint32_t vcf; /* Version: 4 bit */
|
---|
131 | /* Traffic Class: 8 bit */
|
---|
132 | /* Flow Label: 20 bit */
|
---|
133 | uint16_t plen; /* Payload Length */
|
---|
134 | uint8_t next; /* Next Header */
|
---|
135 | uint8_t hlim; /* Hop Limit */
|
---|
136 | T_IN6_ADDR src; /* Source Address */
|
---|
137 | T_IN6_ADDR dst; /* Destination Address */
|
---|
138 | } __attribute__((packed, aligned(2)))T_IP6_HDR;
|
---|
139 |
|
---|
140 | #define IP6_HDR_SIZE (sizeof(T_IP6_HDR))
|
---|
141 |
|
---|
142 | /*
|
---|
143 | * IPv6 ãããæ§é ä½ã¡ã³ãã¢ã¯ã»ã¹ãã¯ã
|
---|
144 | */
|
---|
145 |
|
---|
146 | #define IP6_MAKE_VCF(v,cf) (((uint32_t)(v)<<28)|(cf))
|
---|
147 | #define IP6_VCF_V(vcf) ((uint32_t)(vcf)>>28)
|
---|
148 | #define IP6_VCF_C(vcf) (((uint32_t)(vcf)>>20)&ULONG_C(0xff))
|
---|
149 | #define IP6_VCF_F(vcf) ((uint32_t)(vcf)&ULONG_C(0x000fffff))
|
---|
150 | #define IP6_VCF_CF(vcf) ((uint32_t)(vcf)&ULONG_C(0x0fffffff))
|
---|
151 |
|
---|
152 | /*
|
---|
153 | * æ¡å¼µããã
|
---|
154 | */
|
---|
155 |
|
---|
156 | typedef struct t_ip6_ext_hdr {
|
---|
157 | uint8_t next; /* Next Header */
|
---|
158 | uint8_t len; /* 8 ãªã¯ãããåä½ã®é·ã */
|
---|
159 | } __attribute__((packed, aligned(2)))T_IP6_EXT_HDR;
|
---|
160 |
|
---|
161 | /*
|
---|
162 | * ä¸ç¶ç¹ (Hop-by-Hop) ãªãã·ã§ã³ããã
|
---|
163 | */
|
---|
164 |
|
---|
165 | typedef struct t_ip6_hbh_hdr {
|
---|
166 | uint8_t next; /* Next Header */
|
---|
167 | uint8_t len; /* 8 ãªã¯ãããåä½ã®é·ãããã ãã
|
---|
168 | * ãã®ãªãã·ã§ã³ãããå
|
---|
169 | ¨ä½ã®ãªã¯ãããæ°ã
|
---|
170 | * 8 ã§å²ã£ãå¤ã® - 1 ãå
|
---|
171 | ¥ãã
|
---|
172 | */
|
---|
173 | } __attribute__((packed, aligned(2)))T_IP6_HBH_HDR;
|
---|
174 |
|
---|
175 | /*
|
---|
176 | * çµç¹ (Destination) ãªãã·ã§ã³ããã
|
---|
177 | */
|
---|
178 |
|
---|
179 | typedef struct t_ip6_dest_hdr {
|
---|
180 | uint8_t next; /* Next Header */
|
---|
181 | uint8_t len; /* 8 ãªã¯ãããåä½ã®é·ãããã ãã
|
---|
182 | * ãã®ãªãã·ã§ã³ãããå
|
---|
183 | ¨ä½ã®ãªã¯ãããæ°ã
|
---|
184 | * 8 ã§å²ã£ãå¤ã® - 1 ãå
|
---|
185 | ¥ãã
|
---|
186 | */
|
---|
187 | } __attribute__((packed, aligned(2)))T_IP6_DEST_HDR;
|
---|
188 |
|
---|
189 | /* ä¸ç¶ç¹ (Hop-by-Hop) ãªãã·ã§ã³ */
|
---|
190 |
|
---|
191 | #define IP6OPT_PAD1 UINT_C(0x00) /* 00 0 00000 */
|
---|
192 | #define IP6OPT_PADN UINT_C(0x01) /* 00 0 00001 */
|
---|
193 | #define IP6OPT_JUMBO UINT_C(0xc2) /* 11 0 00010 */
|
---|
194 | #define IP6OPT_NSAP_ADDR UINT_C(0xc3) /* 11 0 00011 */
|
---|
195 | #define IP6OPT_TUNNEL_LIMIT UINT_C(0x04) /* 00 0 00100 */
|
---|
196 | #define IP6OPT_RTR_ALERT UINT_C(0x05) /* 00 0 00101 */
|
---|
197 |
|
---|
198 | #define IP6OPT_MINLEN 2 /* ãªãã·ã§ã³ã®æçé· */
|
---|
199 |
|
---|
200 | /* æªç¥ã®ãªãã·ã§ã³ã®å¦çã®æå® */
|
---|
201 |
|
---|
202 | #define IP6OPT_TYPE_SKIP UINT_C(0x00) /* ç¡è¦ããã */
|
---|
203 | #define IP6OPT_TYPE_DISCARD UINT_C(0x40) /* ãã¼ã¿ã°ã©ã ãç ´æ£ããã */
|
---|
204 | #define IP6OPT_TYPE_FORCEICMP UINT_C(0x80) /* ç ´æ£ãã¦ãICMP ãè¿éããã */
|
---|
205 | #define IP6OPT_TYPE_ICMP UINT_C(0xc0)
|
---|
206 | /* ç ´æ£ãã¦ããã«ããã£ã¹ãã§ãªããã° ICMP ãè¿éããã */
|
---|
207 |
|
---|
208 | #define IP6OPT_TYPE(o) ((o)&UINT_C(0xc0))
|
---|
209 |
|
---|
210 | /*
|
---|
211 | * çµè·¯å¶å¾¡ããã
|
---|
212 | */
|
---|
213 |
|
---|
214 | typedef struct t_ip6_rt_hdr {
|
---|
215 | uint8_t next; /* Next Header */
|
---|
216 | uint8_t len; /* 8 ãªã¯ãããåä½ã®é·ãããã ãã
|
---|
217 | * ãã®ãªãã·ã§ã³ãããå
|
---|
218 | ¨ä½ã®ãªã¯ãããæ°ã
|
---|
219 | * 8 ã§å²ã£ãå¤ã® - 1 ãå
|
---|
220 | ¥ãã
|
---|
221 | */
|
---|
222 | uint8_t type; /* çµè·¯å¶å¾¡ã¿ã¤ã */
|
---|
223 | uint8_t segleft; /* ã»ã°ã¡ã³ãã®æ®ã */
|
---|
224 | } __attribute__((packed, aligned(2)))T_IP6_RT_HDR;
|
---|
225 |
|
---|
226 | /*
|
---|
227 | * ã¿ã¤ã 0 çµè·¯å¶å¾¡ããã
|
---|
228 | */
|
---|
229 |
|
---|
230 | typedef struct t_ip6_rt0_hdr {
|
---|
231 | uint8_t next; /* Next Header */
|
---|
232 | uint8_t len; /* 8 ãªã¯ãããåä½ã®é·ãããã ãã
|
---|
233 | * ãã®ãªãã·ã§ã³ãããå
|
---|
234 | ¨ä½ã®ãªã¯ãããæ°ã
|
---|
235 | * 8 ã§å²ã£ãå¤ã® - 1 ãå
|
---|
236 | ¥ãã
|
---|
237 | */
|
---|
238 | uint8_t type; /* çµè·¯å¶å¾¡ã¿ã¤ã */
|
---|
239 | uint8_t segleft; /* ã»ã°ã¡ã³ãã®æ®ã */
|
---|
240 | uint32_t reserved; /* äºç´ */
|
---|
241 | } __attribute__((packed, aligned(2)))T_IP6_RT0_HDR;
|
---|
242 |
|
---|
243 | /*
|
---|
244 | * æçããã
|
---|
245 | */
|
---|
246 |
|
---|
247 | typedef struct t_ip6_frag_hdr {
|
---|
248 | uint8_t next; /* Next Header */
|
---|
249 | uint8_t reserved;
|
---|
250 | uint16_t off_flag; /* ãªãã»ããã¨ãã©ã° */
|
---|
251 | uint32_t ident; /* åå²èå¥å */
|
---|
252 | } __attribute__((packed, aligned(2)))T_IP6_FRAG_HDR;
|
---|
253 |
|
---|
254 | /* æçãããã®ãªãã»ããã¨ãã©ã° */
|
---|
255 |
|
---|
256 | #ifdef _NET_CFG_BYTE_ORDER
|
---|
257 |
|
---|
258 | #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
|
---|
259 |
|
---|
260 | #define IP6F_OFF_MASK UINT_C(0xfff8) /* ãªãã»ãããååºããã¹ã¯ */
|
---|
261 | #define IP6F_RESERVED_MASK UINT_C(0x0006) /* äºç´ãååºããã¹ã¯ */
|
---|
262 | #define IP6F_MORE_FRAG UINT_C(0x0001) /* ä¸éãã©ã°ã¡ã³ã */
|
---|
263 |
|
---|
264 | #elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
|
---|
265 |
|
---|
266 | #define IP6F_OFF_MASK UINT_C(0xf8ff) /* ãªãã»ãããååºããã¹ã¯ */
|
---|
267 | #define IP6F_RESERVED_MASK UINT_C(0x0600) /* äºç´ãååºããã¹ã¯ */
|
---|
268 | #define IP6F_MORE_FRAG UINT_C(0x0100) /* ä¸éãã©ã°ã¡ã³ã */
|
---|
269 |
|
---|
270 | #endif /* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
|
---|
271 |
|
---|
272 | #endif /* of #ifdef _NET_CFG_BYTE_ORDER */
|
---|
273 |
|
---|
274 | /*
|
---|
275 | * å¶éå¤
|
---|
276 | */
|
---|
277 |
|
---|
278 | #define IPV6_MAXHLIM UINT_C(255) /* ããããªãããã®æå¤§å¤ */
|
---|
279 | #define IPV6_DEFHLIM UINT_C(64) /* ããããªãããã®è¦å®å¤ */
|
---|
280 | #define IPV6_FRAGTTL UINT_C(60) /* åå²ããããã¼ã¿ã°ã©ã ã®çåæéï¼ç§ï¼ */
|
---|
281 | #define IPV6_MMTU UINT_C(1280) /* æå° MTUããã¤ãã¼ã (1024) + ããã (256) */
|
---|
282 | #define IPV6_MAXPACKET UINT_C(65535) /* ã¸ã£ã³ããã¤ãã¼ããé¤ãæ大ãã±ãããµã¤ãº */
|
---|
283 |
|
---|
284 | /*
|
---|
285 | * IPv4 㨠IPv6 ãã³ã³ãã¤ã«æã«é¸æããããã®ãã¯ã
|
---|
286 | */
|
---|
287 |
|
---|
288 | /*
|
---|
289 | * ããããªãããã®è¦å®å¤ã¯ãã«ã¼ã¿éç¥ã«ããå¤æ´ããããã¨ããã
|
---|
290 | */
|
---|
291 |
|
---|
292 | #if NUM_ND6_DEF_RTR_ENTRY > 0
|
---|
293 |
|
---|
294 | /* ã«ã¼ã¿éç¥ãåä¿¡ããå ´åã¯ãéç¥ãããå¤ */
|
---|
295 |
|
---|
296 | #define IP_DEFTTL ip6_defhlim
|
---|
297 |
|
---|
298 | #else /* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
|
---|
299 |
|
---|
300 | /* ã«ã¼ã¿éç¥ãåä¿¡ããªãå ´åã®å¤ã¯æ¢å®å¤ */
|
---|
301 |
|
---|
302 | #define IP_DEFTTL IPV6_DEFHLIM
|
---|
303 |
|
---|
304 | #endif /* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
|
---|
305 |
|
---|
306 | #define IP_HDR_SIZE IP6_HDR_SIZE
|
---|
307 | #define T_IP_HDR T_IP6_HDR
|
---|
308 |
|
---|
309 | #endif /* of #ifdef SUPPORT_INET6 */
|
---|
310 |
|
---|
311 | #endif /* of #ifndef _IP6_H_ */
|
---|