Date: Sat, 20 Aug 2011 16:43:47 +0000 (UTC) From: "Bjoern A. Zeeb" <bz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r225043 - head/sys/netinet6 Message-ID: <201108201643.p7KGhl1M060207@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bz Date: Sat Aug 20 16:43:47 2011 New Revision: 225043 URL: http://svn.freebsd.org/changeset/base/225043 Log: Add an in6_localip() helper function as in6_localaddr() is not doing what people think: returning true for an address in any connected subnet, not necessarily on the local machine. Sponsored by: Sandvine Incorporated MFC after: 2 weeks Approved by: re (kib) Modified: head/sys/netinet6/in6.c head/sys/netinet6/in6.h Modified: head/sys/netinet6/in6.c ============================================================================== --- head/sys/netinet6/in6.c Sat Aug 20 16:34:31 2011 (r225042) +++ head/sys/netinet6/in6.c Sat Aug 20 16:43:47 2011 (r225043) @@ -2017,6 +2017,27 @@ in6_localaddr(struct in6_addr *in6) return (0); } +/* + * Return 1 if an internet address is for the local host and configured + * on one of its interfaces. + */ +int +in6_localip(struct in6_addr *in6) +{ + struct in6_ifaddr *ia; + + IN6_IFADDR_RLOCK(); + TAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) { + if (IN6_ARE_ADDR_EQUAL(in6, &ia->ia_addr.sin6_addr)) { + IN6_IFADDR_RUNLOCK(); + return (1); + } + } + IN6_IFADDR_RUNLOCK(); + return (0); +} + + int in6_is_addr_deprecated(struct sockaddr_in6 *sa6) { Modified: head/sys/netinet6/in6.h ============================================================================== --- head/sys/netinet6/in6.h Sat Aug 20 16:34:31 2011 (r225042) +++ head/sys/netinet6/in6.h Sat Aug 20 16:43:47 2011 (r225043) @@ -631,6 +631,7 @@ struct cmsghdr; int in6_cksum __P((struct mbuf *, u_int8_t, u_int32_t, u_int32_t)); int in6_localaddr __P((struct in6_addr *)); +int in6_localip(struct in6_addr *); int in6_addrscope __P((struct in6_addr *)); struct in6_ifaddr *in6_ifawithifp __P((struct ifnet *, struct in6_addr *)); extern void in6_if_up __P((struct ifnet *));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108201643.p7KGhl1M060207>