Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet6 Add in6_localaddr(). From KAME via FreeBSD.



details:   https://anonhg.NetBSD.org/src/rev/44a787464a88
branches:  trunk
changeset: 543570:44a787464a88
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Feb 27 22:06:38 2003 +0000

description:
Add in6_localaddr().  From KAME via FreeBSD.

diffstat:

 sys/netinet6/in6.c |  24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diffs (45 lines):

diff -r dd619b0f702a -r 44a787464a88 sys/netinet6/in6.c
--- a/sys/netinet6/in6.c        Thu Feb 27 20:38:34 2003 +0000
+++ b/sys/netinet6/in6.c        Thu Feb 27 22:06:38 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6.c,v 1.73 2003/02/24 03:01:03 matt Exp $    */
+/*     $NetBSD: in6.c,v 1.74 2003/02/27 22:06:38 thorpej Exp $ */
 /*     $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $   */
 
 /*
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.73 2003/02/24 03:01:03 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.74 2003/02/27 22:06:38 thorpej Exp $");
 
 #include "opt_inet.h"
 
@@ -2087,6 +2087,26 @@
 }
 
 /*
+ * Determine if an address is on a local network.
+ */
+int
+in6_localaddr(in6)
+       struct in6_addr *in6;
+{
+       struct in6_ifaddr *ia;
+
+       if (IN6_IS_ADDR_LOOPBACK(in6) || IN6_IS_ADDR_LINKLOCAL(in6))
+               return (1);
+
+       for (ia = in6_ifaddr; ia; ia = ia->ia_next)
+               if (IN6_ARE_MASKED_ADDR_EQUAL(in6, &ia->ia_addr.sin6_addr,
+                                             &ia->ia_prefixmask.sin6_addr))
+                       return (1);
+
+       return (0);
+}
+
+/*
  * Get a scope of the address. Node-local, link-local, site-local or global.
  */
 int



Home | Main Index | Thread Index | Old Index