1/*- 2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 47 unchanged lines hidden (view full) --- 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * SUCH DAMAGE. 59 * 60 * @(#)in.c 8.2 (Berkeley) 11/15/93 61 */ 62 63#include <sys/cdefs.h> |
64__FBSDID("$FreeBSD: head/sys/netinet6/in6.c 252511 2013-07-02 16:58:15Z hrs $"); |
65 66#include "opt_compat.h" 67#include "opt_inet.h" 68#include "opt_inet6.h" 69 70#include <sys/param.h> 71#include <sys/errno.h> 72#include <sys/jail.h> --- 1909 unchanged lines hidden (view full) --- 1982 } 1983 } 1984 IF_ADDR_RUNLOCK(ifp); 1985 1986 return ((struct in6_ifaddr *)ifa); 1987} 1988 1989/* |
1990 * Find a link-local scoped address on ifp and return it if any. 1991 */ 1992struct in6_ifaddr * 1993in6ifa_llaonifp(struct ifnet *ifp) 1994{ 1995 struct sockaddr_in6 *sin6; 1996 struct ifaddr *ifa; 1997 1998 if (ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) 1999 return (NULL); 2000 if_addr_rlock(ifp); 2001 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { 2002 if (ifa->ifa_addr->sa_family != AF_INET6) 2003 continue; 2004 sin6 = (struct sockaddr_in6 *)ifa->ifa_addr; 2005 if (IN6_IS_SCOPE_LINKLOCAL(&sin6->sin6_addr) || 2006 IN6_IS_ADDR_MC_INTFACELOCAL(&sin6->sin6_addr) || 2007 IN6_IS_ADDR_MC_NODELOCAL(&sin6->sin6_addr)) 2008 break; 2009 } 2010 if_addr_runlock(ifp); 2011 2012 return ((struct in6_ifaddr *)ifa); 2013} 2014 2015/* |
2016 * Convert IP6 address to printable (loggable) representation. Caller 2017 * has to make sure that ip6buf is at least INET6_ADDRSTRLEN long. 2018 */ 2019static char digits[] = "0123456789abcdef"; 2020char * 2021ip6_sprintf(char *ip6buf, const struct in6_addr *addr) 2022{ 2023 int i, cnt = 0, maxcnt = 0, idx = 0, index = 0; --- 823 unchanged lines hidden --- |