aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet6/scope6.c
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2020-04-15 12:56:05 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2020-04-15 12:56:05 +0000
commit53a4886d5df61eb120f5b4f2c31de0ba390a751a (patch)
treee38bd98a363623a306433bd4a87c9145666a7008 /sys/netinet6/scope6.c
parent4afeb43d98298415cd4fea27cdbac630729c8adc (diff)
downloadsrc-53a4886d5df61eb120f5b4f2c31de0ba390a751a.tar.gz
src-53a4886d5df61eb120f5b4f2c31de0ba390a751a.zip
Notes
Diffstat (limited to 'sys/netinet6/scope6.c')
-rw-r--r--sys/netinet6/scope6.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/sys/netinet6/scope6.c b/sys/netinet6/scope6.c
index 2673b38c2c69..0653d537eec1 100644
--- a/sys/netinet6/scope6.c
+++ b/sys/netinet6/scope6.c
@@ -466,6 +466,28 @@ in6_getscope(const struct in6_addr *in6)
}
/*
+ * Returns scope zone id for the unicast address @in6.
+ *
+ * Returns 0 for global unicast and loopback addresses.
+ * Returns interface index for the link-local addresses.
+ */
+uint32_t
+in6_get_unicast_scopeid(const struct in6_addr *in6, const struct ifnet *ifp)
+{
+
+ if (IN6_IS_SCOPE_LINKLOCAL(in6))
+ return (ifp->if_index);
+ return (0);
+}
+
+void
+in6_set_unicast_scopeid(struct in6_addr *in6, uint32_t scopeid)
+{
+
+ in6->s6_addr16[1] = htons(scopeid & 0xffff);
+}
+
+/*
* Return pointer to ifnet structure, corresponding to the zone id of
* link-local scope.
*/