diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2003-10-03 21:22:33 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2003-10-03 21:22:33 +0000 |
commit | 3d30bd96a1d5aadbd4951cac9621cd40f358ea2c (patch) | |
tree | 706c2468bd5f24e1d9a793cff599620a012c8656 | |
parent | 03f4199ad2f7a2fdcef4ba726b8ad0fdbcba19c5 (diff) |
deal with KAME embedded scope-id for PF_KEY (Encap) route dump. deraadt ok
-rw-r--r-- | usr.bin/netstat/route.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 363f4033dda..a7f842bae75 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.56 2003/08/27 00:33:33 henric Exp $ */ +/* $OpenBSD: route.c,v 1.57 2003/10/03 21:22:32 itojun Exp $ */ /* $NetBSD: route.c,v 1.15 1996/05/07 02:55:06 thorpej Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94"; #else -static char *rcsid = "$OpenBSD: route.c,v 1.56 2003/08/27 00:33:33 henric Exp $"; +static char *rcsid = "$OpenBSD: route.c,v 1.57 2003/10/03 21:22:32 itojun Exp $"; #endif #endif /* not lint */ @@ -1043,7 +1043,25 @@ encap_print(struct rtentry *rt) s61.sin6_family = s62.sin6_family = AF_INET6; s61.sin6_len = s62.sin6_len = sizeof(s61); bcopy(&sen1.sen_ip6_src, &s61.sin6_addr, sizeof(struct in6_addr)); +#ifdef __KAME__ + if (IN6_IS_ADDR_LINKLOCAL(&s61.sin6_addr) || + IN6_IS_ADDR_MC_LINKLOCAL(&s61.sin6_addr)) { + s61.sin6_scope_id = + ((u_int16_t)s61.sin6_addr.s6_addr[2] << 8) | + s61.sin6_addr.s6_addr[3]; + s61.sin6_addr.s6_addr[2] = s61.sin6_addr.s6_addr[3] = 0; + } +#endif bcopy(&sen2.sen_ip6_src, &s62.sin6_addr, sizeof(struct in6_addr)); +#ifdef __KAME__ + if (IN6_IS_ADDR_LINKLOCAL(&s62.sin6_addr) || + IN6_IS_ADDR_MC_LINKLOCAL(&s62.sin6_addr)) { + s62.sin6_scope_id = + ((u_int16_t)s62.sin6_addr.s6_addr[2] << 8) | + s62.sin6_addr.s6_addr[3]; + s62.sin6_addr.s6_addr[2] = s62.sin6_addr.s6_addr[3] = 0; + } +#endif printf("%-42s %-5u ", netname6(&s61, &s62.sin6_addr), ntohs(sen1.sen_ip6_sport)); @@ -1053,7 +1071,25 @@ encap_print(struct rtentry *rt) s61.sin6_family = s62.sin6_family = AF_INET6; s61.sin6_len = s62.sin6_len = sizeof(s61); bcopy(&sen1.sen_ip6_dst, &s61.sin6_addr, sizeof(struct in6_addr)); +#ifdef __KAME__ + if (IN6_IS_ADDR_LINKLOCAL(&s61.sin6_addr) || + IN6_IS_ADDR_MC_LINKLOCAL(&s61.sin6_addr)) { + s61.sin6_scope_id = + ((u_int16_t)s61.sin6_addr.s6_addr[2] << 8) | + s61.sin6_addr.s6_addr[3]; + s61.sin6_addr.s6_addr[2] = s61.sin6_addr.s6_addr[3] = 0; + } +#endif bcopy(&sen2.sen_ip6_dst, &s62.sin6_addr, sizeof(struct in6_addr)); +#ifdef __KAME__ + if (IN6_IS_ADDR_LINKLOCAL(&s62.sin6_addr) || + IN6_IS_ADDR_MC_LINKLOCAL(&s62.sin6_addr)) { + s62.sin6_scope_id = + ((u_int16_t)s62.sin6_addr.s6_addr[2] << 8) | + s62.sin6_addr.s6_addr[3]; + s62.sin6_addr.s6_addr[2] = s62.sin6_addr.s6_addr[3] = 0; + } +#endif printf("%-42s %-5u %-5u ", netname6(&s61, &s62.sin6_addr), ntohs(sen1.sen_ip6_dport), sen1.sen_ip6_proto); |