* altifp - secondary EUI64 source */
| 418 | * altifp - secondary EUI64 source |
| 419 | */ |
| 420 | static int |
| 421 | in6_ifattach_linklocal(struct ifnet *ifp, struct ifnet *altifp) |
| 422 | { |
| 423 | struct in6_ifaddr *ia; |
| 424 | struct in6_aliasreq ifra; |
| 425 | struct nd_prefixctl pr0; |
| 426 | struct epoch_tracker et; |
| 427 | struct nd_prefix *pr; |
| 428 | int error; |
| 429 | |
| 430 | /* |
| 431 | * configure link-local address. |
| 432 | */ |
| 433 | in6_prepare_ifra(&ifra, NULL, &in6mask64); |
| 434 | |
| 435 | ifra.ifra_addr.sin6_addr.s6_addr32[0] = htonl(0xfe800000); |
| 436 | ifra.ifra_addr.sin6_addr.s6_addr32[1] = 0; |
| 437 | if ((ifp->if_flags & IFF_LOOPBACK) != 0) { |
| 438 | ifra.ifra_addr.sin6_addr.s6_addr32[2] = 0; |
| 439 | ifra.ifra_addr.sin6_addr.s6_addr32[3] = htonl(1); |
| 440 | } else { |
| 441 | NET_EPOCH_ENTER(et); |
| 442 | error = get_ifid(ifp, altifp, &ifra.ifra_addr.sin6_addr); |
| 443 | NET_EPOCH_EXIT(et); |
| 444 | if (error != 0) { |
| 445 | nd6log((LOG_ERR, |
| 446 | "%s: no ifid available\n", if_name(ifp))); |
| 447 | return (-1); |
| 448 | } |
| 449 | } |
| 450 | if (in6_setscope(&ifra.ifra_addr.sin6_addr, ifp, NULL)) |
| 451 | return (-1); |
| 452 | |
| 453 | /* link-local addresses should NEVER expire. */ |
| 454 | ifra.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME; |
| 455 | ifra.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME; |
| 456 | |
| 457 | /* |
| 458 | * Now call in6_update_ifa() to do a bunch of procedures to configure |
| 459 | * a link-local address. We can set the 3rd argument to NULL, because |
| 460 | * we know there's no other link-local address on the interface |
| 461 | * and therefore we are adding one (instead of updating one). |
| 462 | */ |
| 463 | if ((error = in6_update_ifa(ifp, &ifra, NULL, |
| 464 | IN6_IFAUPDATE_DADDELAY)) != 0) { |
| 465 | /* |
| 466 | * XXX: When the interface does not support IPv6, this call |
| 467 | * would fail in the SIOCSIFADDR ioctl. I believe the |
| 468 | * notification is rather confusing in this case, so just |
| 469 | * suppress it. (jinmei@kame.net 20010130) |
| 470 | */ |
| 471 | if (error != EAFNOSUPPORT) |
| 472 | nd6log((LOG_NOTICE, "in6_ifattach_linklocal: failed to " |
| 473 | "configure a link-local address on %s " |
| 474 | "(errno=%d)\n", |
| 475 | if_name(ifp), error)); |
| 476 | return (-1); |
| 477 | } |
no test coverage detected