summaryrefslogtreecommitdiff
path: root/usr.bin/netstat
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/route.c67
1 files changed, 55 insertions, 12 deletions
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index ce1643fc846..39d2126735f 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.30 1999/12/08 12:30:17 itojun Exp $ */
+/* $OpenBSD: route.c,v 1.31 1999/12/20 06:17:20 angelos Exp $ */
/* $NetBSD: route.c,v 1.15 1996/05/07 02:55:06 thorpej Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94";
#else
-static char *rcsid = "$OpenBSD: route.c,v 1.30 1999/12/08 12:30:17 itojun Exp $";
+static char *rcsid = "$OpenBSD: route.c,v 1.31 1999/12/20 06:17:20 angelos Exp $";
#endif
#endif /* not lint */
@@ -972,21 +972,64 @@ encap_print(rt)
register struct rtentry *rt;
{
struct sockaddr_encap sen1, sen2, sen3;
+#ifdef INET6
+ struct sockaddr_in6 s61, s62;
+ char ip6addr[64];
+#endif /* INET6 */
bcopy(kgetsa(rt_key(rt)), &sen1, sizeof(sen1));
bcopy(kgetsa(rt_mask(rt)), &sen2, sizeof(sen2));
bcopy(kgetsa(rt->rt_gateway), &sen3, sizeof(sen3));
- printf("%-18s %-5u ", netname(sen1.sen_ip_src.s_addr,
- sen2.sen_ip_src.s_addr),
- sen1.sen_sport);
-
- printf("%-18s %-5u %-5u ", netname(sen1.sen_ip_dst.s_addr,
- sen2.sen_ip_dst.s_addr),
- sen1.sen_dport, sen1.sen_proto);
-
- printf("%s/%08x/%-u\n", inet_ntoa(sen3.sen_ipsp_dst),
- ntohl(sen3.sen_ipsp_spi), sen3.sen_ipsp_sproto);
+ if (sen1.sen_type == SENT_IP4)
+ {
+ printf("%-18s %-5u ", netname(sen1.sen_ip_src.s_addr,
+ sen2.sen_ip_src.s_addr),
+ sen1.sen_sport);
+
+ printf("%-18s %-5u %-5u ", netname(sen1.sen_ip_dst.s_addr,
+ sen2.sen_ip_dst.s_addr),
+ sen1.sen_dport, sen1.sen_proto);
+ }
+
+#ifdef INET6
+ if (sen1.sen_type == SENT_IP6)
+ {
+ bzero(&s61, sizeof(s61));
+ bzero(&s62, sizeof(s62));
+ 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));
+ bcopy(&sen2.sen_ip6_src, &s62.sin6_addr, sizeof(struct in6_addr));
+
+ printf("%-42s %-5u ", netname6(&s61, &s62.sin6_addr),
+ sen1.sen_sport);
+
+ bzero(&s61, sizeof(s61));
+ bzero(&s62, sizeof(s62));
+ 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));
+ bcopy(&sen2.sen_ip6_dst, &s62.sin6_addr, sizeof(struct in6_addr));
+
+ printf("%-42s %-5u %-5u ", netname6(&s61, &s62.sin6_addr),
+ sen1.sen_dport, sen1.sen_proto);
+ }
+#endif /* INET6 */
+
+ if (sen3.sen_type == SENT_IPSP)
+ printf("%s/%08x/%-u\n", inet_ntoa(sen3.sen_ipsp_dst),
+ ntohl(sen3.sen_ipsp_spi), sen3.sen_ipsp_sproto);
+
+#ifdef INET6
+ if (sen3.sen_type == SENT_IPSP6)
+ {
+ inet_ntop(AF_INET6, &sen3.sen_ipsp6_dst,
+ ip6addr, sizeof(ip6addr));
+ printf("%s/%08x/%-u\n", ip6addr, ntohl(sen3.sen_ipsp6_spi),
+ sen3.sen_ipsp6_sproto);
+ }
+#endif /* INET6 */
}
void