From 9fb2be44da1186332cab222f76bf09c57898e288 Mon Sep 17 00:00:00 2001
From: Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org>
Date: Tue, 9 Jul 2002 11:49:03 +0000
Subject: getifaddrs(3) grabs link-local addrs in kernel internal form, convert
 them into proper sockaddr_in6.

---
 sbin/pfctl/parse.y | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

(limited to 'sbin')

diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 421d9d1495d..9d71cf4d506 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -1,4 +1,4 @@
-/*	$OpenBSD: parse.y,v 1.114 2002/07/09 10:39:08 henning Exp $	*/
+/*	$OpenBSD: parse.y,v 1.115 2002/07/09 11:49:02 itojun Exp $	*/
 
 /*
  * Copyright (c) 2001 Markus Friedl.  All rights reserved.
@@ -2553,6 +2553,18 @@ ifa_load(void)
 			ifalist[ifalistlen++] = ifa;
 			qsort(ifalist, ifalistlen, sizeof(void *), ifa_comp);
 		}
+#ifdef __KAME__
+		if (ifa->ifa_addr->sa_family == AF_INET6 &&
+		    IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr)) {
+			struct sockaddr_in6 *sin6;
+
+			sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
+			sin6->sin6_scope_id = sin6->sin6_addr.s6_addr[2] << 8 |
+			    sin6->sin6_addr.s6_addr[3];
+			sin6->sin6_addr.s6_addr[2] = 0;
+			sin6->sin6_addr.s6_addr[3] = 0;
+		}
+#endif
 		if (ifa->ifa_addr->sa_family == AF_INET ||
 		    ifa->ifa_addr->sa_family == AF_INET6) {
 			ifatab[ifatablen++] = ifa;
-- 
cgit v1.2.3