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