diff options
author | shin <shin@FreeBSD.org> | 1999-12-21 09:31:14 +0000 |
---|---|---|
committer | shin <shin@FreeBSD.org> | 1999-12-21 09:31:14 +0000 |
commit | c33c53ebdb0450a62a15d3439f0f013f89722fb0 (patch) | |
tree | 89b6f4a5d2663892753d24e7370772d71030b445 | |
parent | 6c96f03d92cf7596ad0514659fc0e2b0c8358a60 (diff) | |
download | FreeBSD-src-c33c53ebdb0450a62a15d3439f0f013f89722fb0.zip FreeBSD-src-c33c53ebdb0450a62a15d3439f0f013f89722fb0.tar.gz |
define WID_DST6 and WID_GW6 and use them only for IPv6, to keep IPv4 related
information in 80 columns.
TODO: IPv6 related information is not likely to be kept in 80 columns, anyway.
Some more print modes could be added,
but what is the priority between those modes?
-print out all information even if they don't fit into 80 columns
-strip off some information to fit them into 80 columns
Reviewed by: markm
-rw-r--r-- | usr.bin/netstat/route.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index e41eec6..adca08a 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -166,7 +166,7 @@ routepr(rtree) } 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 @@ pr_family(af) } /* 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 @@ p_rtentry(rt) 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); |