Deleted Added
full compact
1/* $FreeBSD: head/sys/netinet6/in6_ifattach.c 95023 2002-04-19 04:46:24Z suz $ */
2/* $KAME: in6_ifattach.c,v 1.118 2001/05/24 07:44:00 itojun Exp $ */
3
4/*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

--- 366 unchanged lines hidden (view full) ---

376 /* try secondary EUI64 source. this basically is for ATM PVC */
377 if (altifp && get_hw_ifid(altifp, in6) == 0) {
378 nd6log((LOG_DEBUG, "%s: got interface identifier from %s\n",
379 if_name(ifp0), if_name(altifp)));
380 goto success;
381 }
382
383 /* next, try to get it from some other hardware interface */
384 for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next)
385 {
386 if (ifp == ifp0)
387 continue;
388 if (get_hw_ifid(ifp, in6) != 0)
389 continue;
390
391 /*
392 * to borrow ifid from other interface, ifid needs to be
393 * globally unique
394 */
395 if (IFID_UNIVERSAL(in6)) {
396 nd6log((LOG_DEBUG,
397 "%s: borrow interface identifier from %s\n",
398 if_name(ifp0), if_name(ifp)));
399 goto success;
400 }
401 }
402
403 /* last resort: get from random number source */
404 if (get_rand_ifid(ifp, in6) == 0) {
405 nd6log((LOG_DEBUG,
406 "%s: interface identifier generated by random number\n",
407 if_name(ifp0)));
408 goto success;
409 }

--- 273 unchanged lines hidden (view full) ---

683 int error;
684
685 bzero(&mltaddr, sizeof(mltaddr));
686 mltaddr.sin6_family = AF_INET6;
687 mltaddr.sin6_len = sizeof(struct sockaddr_in6);
688 if (in6_nigroup(NULL, name, namelen, &mltaddr.sin6_addr) != 0)
689 return;
690
691 for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next)
692 {
693 mltaddr.sin6_addr.s6_addr16[1] = htons(ifp->if_index);
694 IN6_LOOKUP_MULTI(mltaddr.sin6_addr, ifp, in6m);
695 if (!in6m) {
696 if (!in6_addmulti(&mltaddr.sin6_addr, ifp, &error)) {
697 nd6log((LOG_ERR, "%s: failed to join %s "
698 "(errno=%d)\n", if_name(ifp),
699 ip6_sprintf(&mltaddr.sin6_addr),
700 error));
701 }
702 }
703 }
704}
705
706void
707in6_nigroup_detach(name, namelen)
708 const char *name;
709 int namelen;
710{
711 struct ifnet *ifp;
712 struct sockaddr_in6 mltaddr;
713 struct in6_multi *in6m;
714
715 bzero(&mltaddr, sizeof(mltaddr));
716 mltaddr.sin6_family = AF_INET6;
717 mltaddr.sin6_len = sizeof(struct sockaddr_in6);
718 if (in6_nigroup(NULL, name, namelen, &mltaddr.sin6_addr) != 0)
719 return;
720
721 for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next)
722 {
723 mltaddr.sin6_addr.s6_addr16[1] = htons(ifp->if_index);
724 IN6_LOOKUP_MULTI(mltaddr.sin6_addr, ifp, in6m);
725 if (in6m)
726 in6_delmulti(in6m);
727 }
728}
729
730/*
731 * XXX multiple loopback interface needs more care. for instance,
732 * nodelocal address needs to be configured onto only one of them.
733 * XXX multiple link-local address case
734 */
735void

--- 308 unchanged lines hidden ---