summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/in6_src.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet6/in6_src.c')
-rw-r--r--sys/netinet6/in6_src.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index 765a692..7bf28d2 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -1,5 +1,5 @@
/* $FreeBSD$ */
-/* $KAME: in6_src.c,v 1.27 2000/06/21 08:07:13 itojun Exp $ */
+/* $KAME: in6_src.c,v 1.37 2001/03/29 05:34:31 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -70,6 +70,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/protosw.h>
#include <sys/socket.h>
@@ -97,9 +98,9 @@
#include <net/net_osdep.h>
/*
- * Return an IPv6 address, which is the most appropriate for given
+ * Return an IPv6 address, which is the most appropriate for a given
* destination and user specified options.
- * If necessary, this function lookups the routing table and return
+ * If necessary, this function lookups the routing table and returns
* an entry to the caller for later use.
*/
struct in6_addr *
@@ -241,12 +242,15 @@ in6_selectsrc(dstsock, opts, mopts, ro, laddr, errorp)
}
if (ro->ro_rt == (struct rtentry *)0 ||
ro->ro_rt->rt_ifp == (struct ifnet *)0) {
+ struct sockaddr_in6 *sa6;
+
/* No route yet, so try to acquire one */
bzero(&ro->ro_dst, sizeof(struct sockaddr_in6));
- ro->ro_dst.sin6_family = AF_INET6;
- ro->ro_dst.sin6_len = sizeof(struct sockaddr_in6);
- ro->ro_dst.sin6_addr = *dst;
- ro->ro_dst.sin6_scope_id = dstsock->sin6_scope_id;
+ sa6 = (struct sockaddr_in6 *)&ro->ro_dst;
+ sa6->sin6_family = AF_INET6;
+ sa6->sin6_len = sizeof(struct sockaddr_in6);
+ sa6->sin6_addr = *dst;
+ sa6->sin6_scope_id = dstsock->sin6_scope_id;
if (IN6_IS_ADDR_MULTICAST(dst)) {
ro->ro_rt = rtalloc1(&((struct route *)ro)
->ro_dst, 0, 0UL);
@@ -529,15 +533,8 @@ in6_recoverscope(sin6, in6, ifp)
/* sanity check */
if (scopeid < 0 || if_index < scopeid)
return ENXIO;
-#ifndef FAKE_LOOPBACK_IF
- if (ifp && (ifp->if_flags & IFF_LOOPBACK) == 0 &&
- ifp->if_index != scopeid) {
- return ENXIO;
- }
-#else
if (ifp && ifp->if_index != scopeid)
return ENXIO;
-#endif
sin6->sin6_addr.s6_addr16[1] = 0;
sin6->sin6_scope_id = scopeid;
}
@@ -545,3 +542,15 @@ in6_recoverscope(sin6, in6, ifp)
return 0;
}
+
+/*
+ * just clear the embedded scope identifer.
+ * XXX: currently used for bsdi4 only as a supplement function.
+ */
+void
+in6_clearscope(addr)
+ struct in6_addr *addr;
+{
+ if (IN6_IS_SCOPE_LINKLOCAL(addr))
+ addr->s6_addr16[1] = 0;
+}
OpenPOWER on IntegriCloud