From owner-freebsd-arch Tue Dec 21 0:50:39 1999 Delivered-To: freebsd-arch@freebsd.org Received: from ns1.yes.no (ns1.yes.no [195.204.136.10]) by hub.freebsd.org (Postfix) with ESMTP id 4A5E0153E3 for ; Tue, 21 Dec 1999 00:50:37 -0800 (PST) (envelope-from eivind@bitbox.follo.net) Received: from bitbox.follo.net (bitbox.follo.net [195.204.143.218]) by ns1.yes.no (8.9.3/8.9.3) with ESMTP id JAA08381 for ; Tue, 21 Dec 1999 09:50:35 +0100 (CET) Received: (from eivind@localhost) by bitbox.follo.net (8.8.8/8.8.6) id JAA24820 for freebsd-arch@freebsd.org; Tue, 21 Dec 1999 09:50:34 +0100 (MET) Received: from orange.kame.net (orange.kame.net [203.178.141.194]) by hub.freebsd.org (Postfix) with ESMTP id A9B9D153FE; Tue, 21 Dec 1999 00:50:11 -0800 (PST) (envelope-from shin@nd.net.fujitsu.co.jp) Received: from localhost (kame209.kame.net [203.178.141.209]) by orange.kame.net (8.9.1+3.1W/3.7W/smtpfeed 0.89) with ESMTP id RAA25547; Tue, 21 Dec 1999 17:49:41 +0900 (JST) 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] In-Reply-To: <199912210825.dBL8PR304494@gratis.grondar.za> References: <199912210825.dBL8PR304494@gratis.grondar.za> X-Mailer: Mew version 1.94 on Emacs 20.4 / Mule 4.0 (HANANOEN) X-Prom-Mew: Prom-Mew 1.93.4 (procmail reader for Mew) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <19991221175036F.shin@nd.net.fujitsu.co.jp> Date: Tue, 21 Dec 1999 17:50:36 +0900 From: Yoshinobu Inoue X-Dispatcher: imput version 990905(IM130) Lines: 106 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > 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