in6_ifattach.c (95023) | in6_ifattach.c (108172) |
---|---|
1/* $FreeBSD: head/sys/netinet6/in6_ifattach.c 95023 2002-04-19 04:46:24Z suz $ */ | 1/* $FreeBSD: head/sys/netinet6/in6_ifattach.c 108172 2002-12-22 05:35:03Z hsu $ */ |
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 */ | 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 IFNET_RLOCK(); |
|
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))); | 385 for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next) 386 { 387 if (ifp == ifp0) 388 continue; 389 if (get_hw_ifid(ifp, in6) != 0) 390 continue; 391 392 /* 393 * to borrow ifid from other interface, ifid needs to be 394 * globally unique 395 */ 396 if (IFID_UNIVERSAL(in6)) { 397 nd6log((LOG_DEBUG, 398 "%s: borrow interface identifier from %s\n", 399 if_name(ifp0), if_name(ifp))); |
400 IFNET_RUNLOCK(); |
|
399 goto success; 400 } 401 } | 401 goto success; 402 } 403 } |
404 IFNET_RUNLOCK(); |
|
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 | 405 406 /* last resort: get from random number source */ 407 if (get_rand_ifid(ifp, in6) == 0) { 408 nd6log((LOG_DEBUG, 409 "%s: interface identifier generated by random number\n", 410 if_name(ifp0))); 411 goto success; 412 } --- 273 unchanged lines hidden (view full) --- 686 int error; 687 688 bzero(&mltaddr, sizeof(mltaddr)); 689 mltaddr.sin6_family = AF_INET6; 690 mltaddr.sin6_len = sizeof(struct sockaddr_in6); 691 if (in6_nigroup(NULL, name, namelen, &mltaddr.sin6_addr) != 0) 692 return; 693 |
694 IFNET_RLOCK(); |
|
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 } | 695 for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next) 696 { 697 mltaddr.sin6_addr.s6_addr16[1] = htons(ifp->if_index); 698 IN6_LOOKUP_MULTI(mltaddr.sin6_addr, ifp, in6m); 699 if (!in6m) { 700 if (!in6_addmulti(&mltaddr.sin6_addr, ifp, &error)) { 701 nd6log((LOG_ERR, "%s: failed to join %s " 702 "(errno=%d)\n", if_name(ifp), 703 ip6_sprintf(&mltaddr.sin6_addr), 704 error)); 705 } 706 } 707 } |
708 IFNET_RUNLOCK(); |
|
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 | 709} 710 711void 712in6_nigroup_detach(name, namelen) 713 const char *name; 714 int namelen; 715{ 716 struct ifnet *ifp; 717 struct sockaddr_in6 mltaddr; 718 struct in6_multi *in6m; 719 720 bzero(&mltaddr, sizeof(mltaddr)); 721 mltaddr.sin6_family = AF_INET6; 722 mltaddr.sin6_len = sizeof(struct sockaddr_in6); 723 if (in6_nigroup(NULL, name, namelen, &mltaddr.sin6_addr) != 0) 724 return; 725 |
726 IFNET_RLOCK(); |
|
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 } | 727 for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next) 728 { 729 mltaddr.sin6_addr.s6_addr16[1] = htons(ifp->if_index); 730 IN6_LOOKUP_MULTI(mltaddr.sin6_addr, ifp, in6m); 731 if (in6m) 732 in6_delmulti(in6m); 733 } |
734 IFNET_RUNLOCK(); |
|
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 --- | 735} 736 737/* 738 * XXX multiple loopback interface needs more care. for instance, 739 * nodelocal address needs to be configured onto only one of them. 740 * XXX multiple link-local address case 741 */ 742void --- 308 unchanged lines hidden --- |