diff options
author | bz <bz@FreeBSD.org> | 2011-08-20 16:43:47 +0000 |
---|---|---|
committer | bz <bz@FreeBSD.org> | 2011-08-20 16:43:47 +0000 |
commit | fa01a4aee0c4b294791a3b7515a6776750af5f04 (patch) | |
tree | 8eea3d077593eade987ccc22607e52ebbb24b2e5 /sys/netinet6/in6.c | |
parent | 06456f1cfdd3fc235d3a97bdbb1e110e74630ddc (diff) | |
download | FreeBSD-src-fa01a4aee0c4b294791a3b7515a6776750af5f04.zip FreeBSD-src-fa01a4aee0c4b294791a3b7515a6776750af5f04.tar.gz |
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)
Diffstat (limited to 'sys/netinet6/in6.c')
-rw-r--r-- | sys/netinet6/in6.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 39e77e9..9bf7a8f 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -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) { |