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.c 388 2019-05-22 11:25:18Z coas-nagasima $
|
---|
44 | */
|
---|
45 |
|
---|
46 | /* $FreeBSD: src/sys/netinet6/in6.c,v 1.21 2002/04/19 04:46:22 suz Exp $ */
|
---|
47 | /* $KAME: in6.c,v 1.259 2002/01/21 11:37:50 keiichi 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, 1991, 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.c 8.2 (Berkeley) 11/15/93
|
---|
111 | */
|
---|
112 |
|
---|
113 | #include <string.h>
|
---|
114 |
|
---|
115 | #ifdef TARGET_KERNEL_ASP
|
---|
116 |
|
---|
117 | #include <kernel.h>
|
---|
118 | #include <sil.h>
|
---|
119 |
|
---|
120 | #endif /* of #ifdef TARGET_KERNEL_ASP */
|
---|
121 |
|
---|
122 | #ifdef TARGET_KERNEL_JSP
|
---|
123 |
|
---|
124 | #include <s_services.h>
|
---|
125 | #include <t_services.h>
|
---|
126 | #include "kernel_id.h"
|
---|
127 |
|
---|
128 | #endif /* of #ifdef TARGET_KERNEL_JSP */
|
---|
129 |
|
---|
130 | #include <tinet_defs.h>
|
---|
131 | #include <tinet_config.h>
|
---|
132 |
|
---|
133 | #include <net/if.h>
|
---|
134 | #include <net/if_types.h>
|
---|
135 | #include <net/if_ppp.h>
|
---|
136 | #include <net/if_loop.h>
|
---|
137 | #include <net/ethernet.h>
|
---|
138 | #include <net/ppp_ipcp.h>
|
---|
139 | #include <net/net.h>
|
---|
140 | #include <net/net_endian.h>
|
---|
141 | #include <net/net_buf.h>
|
---|
142 | #include <net/net_timer.h>
|
---|
143 | #include <net/net_count.h>
|
---|
144 |
|
---|
145 | #include <netinet/in.h>
|
---|
146 | #include <netinet/in_var.h>
|
---|
147 |
|
---|
148 | #include <netinet6/in6.h>
|
---|
149 | #include <netinet6/in6_var.h>
|
---|
150 | #include <netinet6/nd6.h>
|
---|
151 | #include <netinet6/in6_ifattach.h>
|
---|
152 |
|
---|
153 | #include <net/if_var.h>
|
---|
154 |
|
---|
155 | #ifdef _IP6_CFG
|
---|
156 |
|
---|
157 | /*
|
---|
158 | * å
|
---|
159 | ¨åå¤æ°
|
---|
160 | */
|
---|
161 |
|
---|
162 | const T_IN6_ADDR in6_addr_unspecified =
|
---|
163 | IPV6_ADDR_UNSPECIFIED_INIT;
|
---|
164 |
|
---|
165 | const T_IN6_ADDR in6_addr_linklocal_allnodes =
|
---|
166 | IPV6_ADDR_LINKLOCAL_ALLNODES_INIT;
|
---|
167 |
|
---|
168 | const T_IN6_ADDR in6_addr_linklocal_allrouters =
|
---|
169 | IPV6_ADDR_LINKLOCAL_ALLROUTERS_INIT;
|
---|
170 |
|
---|
171 | /*
|
---|
172 | * in6_addmulti -- ãã«ããã£ã¹ãã¢ãã¬ã¹ãç»é²ããã
|
---|
173 | */
|
---|
174 |
|
---|
175 | static ER
|
---|
176 | in6_addmulti (T_IFNET *ifp, T_IN6_ADDR *maddr)
|
---|
177 | {
|
---|
178 | ER error = E_OK;
|
---|
179 |
|
---|
180 | if ((error = if_addmulti(ifp, maddr, AT_INET6)) != E_OK)
|
---|
181 | return error;
|
---|
182 |
|
---|
183 | return error;
|
---|
184 | }
|
---|
185 |
|
---|
186 | /*
|
---|
187 | * in6_ifinit -- ã¤ã³ã¿ãã§ã¼ã¹ã«ã¢ãã¬ã¹æ
|
---|
188 | å ±ãè¨å®ããåæåããã
|
---|
189 | */
|
---|
190 |
|
---|
191 | static ER
|
---|
192 | in6_ifinit (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr, uint_t prefix_len)
|
---|
193 | {
|
---|
194 | /* ã¢ãã¬ã¹ã¨ãã¬ãã£ãã¯ã¹é·ãè¨å®ããã*/
|
---|
195 | ia->addr = *addr;
|
---|
196 | ia->prefix_len = prefix_len;
|
---|
197 |
|
---|
198 | /* ãã©ã°ãåæåããã*/
|
---|
199 | ia->flags = 0;
|
---|
200 |
|
---|
201 | /*
|
---|
202 | * åãã¦ã¢ãã¬ã¹ãè¨å®ãããã¨ããã¤ã³ã¿ãã§ã¼ã¹ç¬èªã®åæåãè¡ãã
|
---|
203 | */
|
---|
204 |
|
---|
205 | return E_OK;
|
---|
206 | }
|
---|
207 |
|
---|
208 | /*
|
---|
209 | * in6_ifainit -- ã¤ã³ã¿ãã§ã¼ã¹ã¢ãã¬ã¹æ§é ä½ã®åæå
|
---|
210 | */
|
---|
211 |
|
---|
212 | void
|
---|
213 | in6_ifainit (void)
|
---|
214 | {
|
---|
215 | T_IN6_IFADDR *ia = NULL;
|
---|
216 | T_IFNET *ifp = IF_GET_IFNET();
|
---|
217 | int_t ix;
|
---|
218 |
|
---|
219 | for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
|
---|
220 | ia = &ifp->in6_ifaddrs[ix];
|
---|
221 | memset(ia, sizeof(T_IN6_IFADDR), 0);
|
---|
222 | ia->router_index = IN6_RTR_IX_UNREACH;
|
---|
223 | ia->prefix_index = ND6_PREFIX_IX_INVALID;
|
---|
224 | }
|
---|
225 | }
|
---|
226 |
|
---|
227 | /*
|
---|
228 | * in6_if2idlen -- ã¤ã³ã¿ãã§ã¼ã¹ ID é·ãè¿ãã
|
---|
229 | */
|
---|
230 |
|
---|
231 | int_t
|
---|
232 | in6_if2idlen (T_IFNET *ifp)
|
---|
233 | {
|
---|
234 | #if IF_TYPE == IFT_ETHER
|
---|
235 | return 64;
|
---|
236 | #else
|
---|
237 | return 64;
|
---|
238 | #endif
|
---|
239 | }
|
---|
240 |
|
---|
241 | /*
|
---|
242 | * in6_addr2ifaix -- ã¢ãã¬ã¹ããã¤ã³ã¿ãã§ã¼ã¹ã¢ãã¬ã¹æ
|
---|
243 | å ±ã®ã¤ã³ããã¯ã¹ã«å¤æããã
|
---|
244 | */
|
---|
245 |
|
---|
246 | int_t
|
---|
247 | in6_addr2ifaix (const T_IN6_ADDR *addr)
|
---|
248 | {
|
---|
249 | T_IFNET *ifp = IF_GET_IFNET();
|
---|
250 | T_IN6_IFADDR *ia;
|
---|
251 | int_t ix;
|
---|
252 |
|
---|
253 | for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
|
---|
254 | ia = &ifp->in6_ifaddrs[ix];
|
---|
255 | if ((ia->flags & IN6_IFF_DEFINED) != 0 &&
|
---|
256 | in6_are_prefix_equal(addr, &ia->addr, ia->prefix_len))
|
---|
257 | return ix;
|
---|
258 | }
|
---|
259 |
|
---|
260 | return IPV6_IFADDR_IX_INVALID;
|
---|
261 | }
|
---|
262 |
|
---|
263 | /*
|
---|
264 | * in6_addr2maix -- ã¢ãã¬ã¹ãããã«ããã£ã¹ãã¢ãã¬ã¹ã®ã¤ã³ããã¯ã¹ã«å¤æããã
|
---|
265 | */
|
---|
266 |
|
---|
267 | int_t
|
---|
268 | in6_addr2maix (const T_IN6_ADDR *addr)
|
---|
269 | {
|
---|
270 | if (addr->s6_addr8[0] == 0xff) {
|
---|
271 | if (addr->s6_addr8[1] == 0x02) {
|
---|
272 | if (addr->s6_addr8[11] == 0x01 && addr->s6_addr8[12] == 0xff)
|
---|
273 | return IPV6_MADDR_IX_SOL_NODE;
|
---|
274 | else
|
---|
275 | return IPV6_MADDR_IX_LL_ALL_NODE;
|
---|
276 | }
|
---|
277 | else
|
---|
278 | return IPV6_MADDR_IX_EXTRA;
|
---|
279 | }
|
---|
280 | else
|
---|
281 | return IPV6_MADDR_IX_EXTRA;
|
---|
282 | }
|
---|
283 |
|
---|
284 | /*
|
---|
285 | * in6_update_ifa -- ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹æ
|
---|
286 | å ±ãæ´æ°ããã
|
---|
287 | */
|
---|
288 |
|
---|
289 | ER
|
---|
290 | in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr,
|
---|
291 | uint_t prefix_len, uint32_t vltime, uint32_t pltime,
|
---|
292 | int_t router_index, int_t prefix_index, uint_t flags)
|
---|
293 | {
|
---|
294 | T_IN6_ADDR llsol;
|
---|
295 | ER error = E_OK;
|
---|
296 | SYSTIM now;
|
---|
297 |
|
---|
298 | /* å¼æ°ããã§ãã¯ããã*/
|
---|
299 | if (addr == NULL)
|
---|
300 | return E_PAR;
|
---|
301 |
|
---|
302 | /*
|
---|
303 | * æå¹æéããã§ãã¯ããã
|
---|
304 | * vltime (æå¹æé) 㨠pltime (æ¨å¥¨æå¹æé) ã®åä½ã¯ [s]ã
|
---|
305 | */
|
---|
306 | syscall(get_tim(&now));
|
---|
307 | now /= SYSTIM_HZ;
|
---|
308 |
|
---|
309 | if (((vltime != ND6_INFINITE_LIFETIME) && (vltime + now < now)) || vltime == 0)
|
---|
310 | return E_PAR;
|
---|
311 |
|
---|
312 | if ((pltime != ND6_INFINITE_LIFETIME) && (pltime + now < now))
|
---|
313 | return E_PAR;
|
---|
314 |
|
---|
315 | /* ã¤ã³ã¿ãã§ã¼ã¹ãåæåããã*/
|
---|
316 | if ((error = in6_ifinit(ifp, ia, addr, prefix_len)) != E_OK)
|
---|
317 | return error;
|
---|
318 |
|
---|
319 | if (IN6_IS_ADDR_LINKLOCAL(addr)) {
|
---|
320 |
|
---|
321 | /* è¦è«ãã«ããã£ã¹ãã¢ãã¬ã¹ãç»é²ããã*/
|
---|
322 | llsol.s6_addr32[0] = IPV6_ADDR_INT32_MLL;
|
---|
323 | llsol.s6_addr32[1] = 0x00000000;
|
---|
324 | llsol.s6_addr32[2] = IPV6_ADDR_INT32_ONE;
|
---|
325 | llsol.s6_addr32[3] = addr->s6_addr32[3];
|
---|
326 | llsol.s6_addr8[12] = 0xff;
|
---|
327 | if ((error = in6_addmulti(ifp, &llsol)) != E_OK)
|
---|
328 | return error;
|
---|
329 |
|
---|
330 | /* å
|
---|
331 | ¨ãã¼ãã»ãªã³ã¯ãã¼ã«ã«ã»ãã«ããã£ã¹ãã¢ãã¬ã¹ãç»é²ããã*/
|
---|
332 | llsol.s6_addr32[2] = 0x00000000;
|
---|
333 | llsol.s6_addr32[3] = IPV6_ADDR_INT32_ONE;
|
---|
334 | if ((error = in6_addmulti(ifp, &llsol)) != E_OK)
|
---|
335 | return error;
|
---|
336 |
|
---|
337 | }
|
---|
338 |
|
---|
339 | /* ã«ã¼ã¿ã¤ã³ããã¯ã¹ãè¨å®ããã*/
|
---|
340 | ia->router_index = router_index;
|
---|
341 |
|
---|
342 | /* ãã¬ãã£ãã¯ã¹ã¤ã³ããã¯ã¹ãè¨å®ããã*/
|
---|
343 | ia->prefix_index = prefix_index;
|
---|
344 |
|
---|
345 | /* ãã©ã°ãè¨å®ããã*/
|
---|
346 | ia->flags = flags & ~(IN6_IFF_DUPLICATED | IN6_IFF_NODAD);
|
---|
347 | ia->flags |= IN6_IFF_DEFINED;
|
---|
348 |
|
---|
349 | /*
|
---|
350 | * ã¢ãã¬ã¹æå¹æéãè¨å®ããã
|
---|
351 | * vltime (æå¹æé) 㨠pltime (æ¨å¥¨æå¹æé) ã®åä½ã¯ [s]ã
|
---|
352 | */
|
---|
353 | syscall(get_tim(&now));
|
---|
354 | now /= SYSTIM_HZ;
|
---|
355 |
|
---|
356 | ia->lifetime.vltime = vltime;
|
---|
357 | if (vltime != ND6_INFINITE_LIFETIME)
|
---|
358 | ia->lifetime.expire = now + vltime;
|
---|
359 | else
|
---|
360 | ia->lifetime.expire = 0;
|
---|
361 |
|
---|
362 | ia->lifetime.pltime = pltime;
|
---|
363 | if (pltime != ND6_INFINITE_LIFETIME)
|
---|
364 | ia->lifetime.preferred = now + pltime;
|
---|
365 | else
|
---|
366 | ia->lifetime.preferred = 0;
|
---|
367 |
|
---|
368 | /* è¿é£æ¢ç´¢ã®åæè¨å®ãè¡ãã*/
|
---|
369 | nd6_ifattach(ifp);
|
---|
370 |
|
---|
371 | /* éè¤ã¢ãã¬ã¹æ¤åºãè¡ãã*/
|
---|
372 | if ((flags & IN6_IFF_NODAD) == 0) {
|
---|
373 | ia->flags |= IN6_IFF_TENTATIVE;
|
---|
374 | nd6_dad_start(ifp, ia, NULL);
|
---|
375 | }
|
---|
376 |
|
---|
377 | return error;
|
---|
378 | }
|
---|
379 |
|
---|
380 | /*
|
---|
381 | * in6ifa_ifpwithix -- ã¤ã³ããã¯ã¹çªå·ããããããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã«
|
---|
382 | * å²ãå½ã¦ããã¦ããã¢ãã¬ã¹ãæ¢ç´¢ããã
|
---|
383 | */
|
---|
384 |
|
---|
385 | T_IN6_IFADDR *
|
---|
386 | in6ifa_ifpwithix (T_IFNET *ifp, int_t ix)
|
---|
387 | {
|
---|
388 | return ix < NUM_IN6_IFADDR_ENTRY? &ifp->in6_ifaddrs[ix] : NULL;
|
---|
389 | }
|
---|
390 |
|
---|
391 | /*
|
---|
392 | * in6ifa_ifpwithrtrix -- ã«ã¼ã¿ã®ã¤ã³ããã¯ã¹çªå·ããããããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã«
|
---|
393 | * å²ãå½ã¦ããã¦ããã¢ãã¬ã¹ãæ¢ç´¢ããã
|
---|
394 | */
|
---|
395 |
|
---|
396 | T_IN6_IFADDR *
|
---|
397 | in6ifa_ifpwithrtrix (T_IFNET *ifp, int_t router_index)
|
---|
398 | {
|
---|
399 | int_t ix;
|
---|
400 |
|
---|
401 | for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; )
|
---|
402 | if (ifp->in6_ifaddrs[ix].router_index == router_index)
|
---|
403 | return &ifp->in6_ifaddrs[ix];
|
---|
404 | return NULL;
|
---|
405 | }
|
---|
406 |
|
---|
407 | /*
|
---|
408 | * in6_ifawithifp -- å®å
|
---|
409 | ã¢ãã¬ã¹ã«ãµããããéä¿¡å
|
---|
410 | ã¢ãã¬ã¹æ
|
---|
411 | å ±ãã
|
---|
412 | * ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããæ¢ç´¢ããã
|
---|
413 | */
|
---|
414 |
|
---|
415 | T_IN6_IFADDR *
|
---|
416 | in6_ifawithifp (T_IFNET *ifp, const T_IN6_ADDR *dst)
|
---|
417 | {
|
---|
418 | uint_t scope;
|
---|
419 | int_t ix;
|
---|
420 |
|
---|
421 | /* å®å
|
---|
422 | ã¢ãã¬ã¹ã¨åãã¹ã³ã¼ãã®ã¢ãã¬ã¹ãè¿ãã*/
|
---|
423 | if ((ix = in6_addr2ifaix(dst)) != IPV6_IFADDR_IX_INVALID)
|
---|
424 | return &ifp->in6_ifaddrs[ix];
|
---|
425 | else if ((ix = in6_addr2maix(dst)) == IPV6_MADDR_IX_SOL_NODE ||
|
---|
426 | ix == IPV6_MADDR_IX_LL_ALL_NODE)
|
---|
427 | return &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
|
---|
428 | else {
|
---|
429 | scope = in6_addrscope(dst);
|
---|
430 | for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
|
---|
431 | if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
|
---|
432 | (ifp->in6_ifaddrs[ix].flags & IN6_IFF_DETACHED) == 0 &&
|
---|
433 | in6_addrscope(&ifp->in6_ifaddrs[ix].addr) == scope) {
|
---|
434 | return &ifp->in6_ifaddrs[ix];
|
---|
435 | }
|
---|
436 | }
|
---|
437 | return NULL;
|
---|
438 | }
|
---|
439 | }
|
---|
440 |
|
---|
441 | /*
|
---|
442 | * in6_addrwithifp -- å®å
|
---|
443 | ã¢ãã¬ã¹ã«ãµããããéä¿¡å
|
---|
444 | ã¢ãã¬ã¹ãã
|
---|
445 | * ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããæ¢ç´¢ããã
|
---|
446 | */
|
---|
447 |
|
---|
448 | const T_IN6_ADDR *
|
---|
449 | in6_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, const T_IN6_ADDR *dst)
|
---|
450 | {
|
---|
451 | T_IN6_IFADDR *ifaddr;
|
---|
452 |
|
---|
453 | if ((ifaddr = in6_ifawithifp(ifp, dst)) == NULL)
|
---|
454 | return NULL;
|
---|
455 | else {
|
---|
456 | *src = ifaddr->addr;
|
---|
457 | return src;
|
---|
458 | }
|
---|
459 | }
|
---|
460 |
|
---|
461 | /*
|
---|
462 | * in6_if_up -- ã¤ã³ã¿ãã§ã¼ã¹èµ·åå¾ã®éè¤ã¢ãã¬ã¹æ¤åºãè¡ãã
|
---|
463 | */
|
---|
464 |
|
---|
465 | void
|
---|
466 | in6_if_up (T_IFNET *ifp)
|
---|
467 | {
|
---|
468 | #if 0 /* ä¿ç */
|
---|
469 | int_t dad_delay, ix;
|
---|
470 | #endif /* of #if 0 */
|
---|
471 |
|
---|
472 | in6_ifattach(ifp);
|
---|
473 |
|
---|
474 | #if 0 /* ä¿ç */
|
---|
475 | /* éè¤ã¢ãã¬ã¹æ¤åºãè¡ãã*/
|
---|
476 | dad_delay = 0;
|
---|
477 | for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; )
|
---|
478 | if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
|
---|
479 | (ifp->in6_ifaddrs[ix].flags & IN6_IFF_TENTATIVE))
|
---|
480 | nd6_dad_start(ifp, &ifp->in6_ifaddrs[ix], &dad_delay);
|
---|
481 | #endif /* of #if 0 */
|
---|
482 |
|
---|
483 | #if NUM_ND6_RTR_SOL_RETRY > 0
|
---|
484 |
|
---|
485 | /* ã«ã¼ã¿è¦è«ãåºåããã*/
|
---|
486 | nd6_rtrsol_ctl();
|
---|
487 |
|
---|
488 | #endif /* of #if NUM_ND6_RTR_SOL_RETRY > 0 */
|
---|
489 | }
|
---|
490 |
|
---|
491 | /*
|
---|
492 | * in6_are_prefix_equal -- ãã¬ãã£ãã¯ã¹ãåä¸ã調ã¹ãã
|
---|
493 | */
|
---|
494 |
|
---|
495 | bool_t
|
---|
496 | in6_are_prefix_equal (const T_IN6_ADDR *addr, const T_IN6_ADDR *prefix, uint_t prefix_len)
|
---|
497 | {
|
---|
498 | uint_t bitlen, bytelen;
|
---|
499 |
|
---|
500 | bytelen = prefix_len / 8;
|
---|
501 | if (memcmp(&addr->s6_addr, &prefix->s6_addr, bytelen))
|
---|
502 | return false;
|
---|
503 |
|
---|
504 | bitlen = prefix_len % 8;
|
---|
505 | if ( addr->s6_addr[bytelen] >> (8 - bitlen) !=
|
---|
506 | prefix->s6_addr[bytelen] >> (8 - bitlen))
|
---|
507 | return false;
|
---|
508 |
|
---|
509 | return true;
|
---|
510 | }
|
---|
511 |
|
---|
512 | /*
|
---|
513 | * in6_ifaddr_timer -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹ã®ç®¡çã¿ã¤ãã¼
|
---|
514 | */
|
---|
515 |
|
---|
516 | void
|
---|
517 | in6_ifaddr_timer (T_IFNET *ifp)
|
---|
518 | {
|
---|
519 | T_IN6_IFADDR *ia;
|
---|
520 | SYSTIM now;
|
---|
521 | int_t ix;
|
---|
522 |
|
---|
523 | syscall(get_tim(&now));
|
---|
524 | for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
|
---|
525 | ia = &ifp->in6_ifaddrs[ix];
|
---|
526 |
|
---|
527 | if ((ia->flags & IN6_IFF_DEFINED) == 0)
|
---|
528 | ;
|
---|
529 | else if (IFA6_IS_INVALID(ia, now)) {
|
---|
530 |
|
---|
531 | /*
|
---|
532 | * æå¹æéãéããã®ã§åé¤ããã
|
---|
533 | */
|
---|
534 | ia->flags &= ~IN6_IFF_DEFINED;
|
---|
535 | }
|
---|
536 |
|
---|
537 | else if (IFA6_IS_DEPRECATED(ia, now)) {
|
---|
538 |
|
---|
539 | /*
|
---|
540 | * æ¨å¥¨æå¹æéãéããã®ã§éæ¨å¥¨ã«ããã
|
---|
541 | */
|
---|
542 | ia->flags |= IN6_IFF_DEPRECATED;
|
---|
543 | }
|
---|
544 | }
|
---|
545 | }
|
---|
546 |
|
---|
547 | #endif /* of #ifdef _IP6_CFG */
|
---|