Date: Tue, 21 Dec 1999 17:50:36 +0900 From: Yoshinobu Inoue <shin@nd.net.fujitsu.co.jp> To: mark@grondar.za Cc: obrien@freebsd.org, jhay@mikom.csir.co.za, freebsd-arch@freebsd.org, cvs-committers@freebsd.org Subject: Re: [Solicite review for KAME 3rd patch] Message-ID: <19991221175036F.shin@nd.net.fujitsu.co.jp> In-Reply-To: <199912210825.dBL8PR304494@gratis.grondar.za> References: <199912210825.dBL8PR304494@gratis.grondar.za>
next in thread | previous in thread | raw e-mail | index | archive | help
> > Alternately, the output formatting could be changed, but ``ifconfig -rn''
> > needs to be neatly readble on an 80 column display. We cater to the
> > server market, where a large number of machines run headless on console
> > servers.
>
> Is there a way of finding out if the kernel in use is using IPv6?
> If so, then the output should be conditional upon that, defaulting to
> "old" behaviour.
I think it can be checked by, socket(PF_INET6, SOCK_DGRAM, 0) etc,
but in this case I think following diff to netstat/route.c
will resolve the issue. Please give me comments and if it
seems to be OK, I'll commit it.
Yoshinobu Inoue
Index: route.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/netstat/route.c,v
retrieving revision 1.37
diff -u -r1.37 route.c
--- route.c 1999/12/07 17:38:57 1.37
+++ route.c 1999/12/21 08:48:57
@@ -166,7 +166,7 @@
} else if (af == AF_UNSPEC || af == i) {
pr_family(i);
do_rtent = 1;
- pr_rthdr();
+ pr_rthdr(i);
p_tree(head.rnh_treetop);
}
}
@@ -222,31 +222,43 @@
}
/* column widths; each followed by one space */
-#ifndef INET6
#define WID_DST 18 /* width of destination column */
#define WID_GW 18 /* width of gateway column */
-#else
-#define WID_DST (lflag ? 39 : (nflag ? 33: 18)) /* width of dest column */
-#define WID_GW (lflag ? 31 : (nflag ? 29 : 18)) /* width of gateway column */
+#ifdef INET6
+#define WID_DST6 (lflag ? 39 : (nflag ? 33: 18)) /* width of dest column */
+#define WID_GW6 (lflag ? 31 : (nflag ? 29 : 18)) /* width of gateway column */
#endif /*INET6*/
/*
* Print header for routing table columns.
*/
void
-pr_rthdr()
+pr_rthdr(af)
{
+ int wid_dst, wid_gw;
+
+ wid_dst =
+#ifdef INET6
+ af == AF_INET6 ? WID_DST6 :
+#endif
+ WID_DST;
+ wid_gw =
+#ifdef INET6
+ af == AF_INET6 ? WID_GW6 :
+#endif
+ WID_GW;
+
if (Aflag)
printf("%-8.8s ","Address");
if (lflag)
printf("%-*.*s %-*.*s %-6.6s %6.6s%8.8s %8.8s %6s\n",
- WID_DST, WID_DST, "Destination",
- WID_GW, WID_GW, "Gateway",
+ wid_dst, wid_dst, "Destination",
+ wid_gw, wid_gw, "Gateway",
"Flags", "Refs", "Use", "Netif", "Expire");
else
printf("%-*.*s %-*.*s %-6.6s %8.8s %6s\n",
- WID_DST, WID_DST, "Destination",
- WID_GW, WID_GW, "Gateway",
+ wid_dst, wid_dst, "Destination",
+ wid_gw, wid_gw, "Gateway",
"Flags", "Netif", "Expire");
}
@@ -585,8 +597,16 @@
bzero(&mask, sizeof(mask));
if (rt_mask(rt) && (sa = kgetsa(rt_mask(rt))))
bcopy(sa, &mask, sa->sa_len);
- p_sockaddr(&addr.u_sa, &mask.u_sa, rt->rt_flags, WID_DST);
- p_sockaddr(kgetsa(rt->rt_gateway), NULL, RTF_HOST, WID_GW);
+ p_sockaddr(&addr.u_sa, &mask.u_sa, rt->rt_flags,
+#ifdef INET6
+ addr.u_sa.sa_family == AF_INET6 ? WID_DST6 :
+#endif
+ WID_DST);
+ p_sockaddr(kgetsa(rt->rt_gateway), NULL, RTF_HOST,
+#ifdef INET6
+ kgetsa(rt->rt_gateway)->sa_family == AF_INET6 ? WID_GW6 :
+#endif
+ WID_GW);
p_flags(rt->rt_flags, "%-6.6s ");
if (lflag)
printf("%6ld %8ld ", rt->rt_refcnt, rt->rt_use);
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991221175036F.shin>
