svn commit: r246068 - user/ae/inet6/sys/netinet6
Andrey V. Elsukov
ae at FreeBSD.org
Tue Jan 29 10:54:50 UTC 2013
Author: ae
Date: Tue Jan 29 10:54:50 2013
New Revision: 246068
URL: http://svnweb.freebsd.org/changeset/base/246068
Log:
Add in6_srcaddrscope function. It returns scope of specified address
and will be used in the source address selection algorithm.
Modified:
user/ae/inet6/sys/netinet6/in6_src.c
Modified: user/ae/inet6/sys/netinet6/in6_src.c
==============================================================================
--- user/ae/inet6/sys/netinet6/in6_src.c Tue Jan 29 10:46:47 2013 (r246067)
+++ user/ae/inet6/sys/netinet6/in6_src.c Tue Jan 29 10:54:50 2013 (r246068)
@@ -143,6 +143,7 @@ static int walk_addrsel_policy(int (*)(s
void *);
static int dump_addrsel_policyent(struct in6_addrpolicy *, void *);
static struct in6_addrpolicy *match_addrsel_policy(struct sockaddr_in6 *);
+static int in6_srcaddrscope(const struct in6_addr *);
/*
* Return an IPv6 address, which is the most appropriate for a given
@@ -1175,3 +1176,20 @@ match_addrsel_policy(struct sockaddr_in6
return (bestpol);
}
+
+/*
+ * This function is similar to in6_addrscope, but has some difference,
+ * specific for the source address selection algorithm (RFC 6724).
+ */
+static int
+in6_srcaddrscope(const struct in6_addr *addr)
+{
+
+ /* 169.254/16 and 127/8 have link-local scope */
+ if (IN6_IS_ADDR_V4MAPPED(addr)) {
+ if (addr->s6_addr[12] == 127 || (
+ addr->s6_addr[12] == 169 && addr->s6_addr[13] == 254))
+ return (IPV6_ADDR_SCOPE_LINKLOCAL);
+ }
+ return (in6_addrscope(addr));
+}
More information about the svn-src-user
mailing list