summaryrefslogtreecommitdiff
path: root/usr.bin/netstat/show.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2007-07-25 11:50:48 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2007-07-25 11:50:48 +0000
commit8bb62f9b32f78e8065bc6894edfd23a6c929d9d3 (patch)
tree655c7183a63772b09004d21f3fefd80d17f4de15 /usr.bin/netstat/show.c
parentf61f154c8ef589df49ac609b531ca67d71d1c4ae (diff)
Make it possible to show alternate routing tables in netstat. This mostly
comes from route(8) which already had the -T option. OK henning@
Diffstat (limited to 'usr.bin/netstat/show.c')
-rw-r--r--usr.bin/netstat/show.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/usr.bin/netstat/show.c b/usr.bin/netstat/show.c
index 173f60c3115..e8f94b8582c 100644
--- a/usr.bin/netstat/show.c
+++ b/usr.bin/netstat/show.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: show.c,v 1.9 2007/07/24 20:36:34 claudio Exp $ */
+/* $OpenBSD: show.c,v 1.10 2007/07/25 11:50:47 claudio Exp $ */
/* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */
/*
@@ -95,7 +95,6 @@ static const struct bits bits[] = {
{ 0 }
};
-void pr_rthdr(int, int);
void p_rtentry(struct rt_msghdr *);
void p_pfkentry(struct sadb_msg *);
void pr_family(int);
@@ -112,13 +111,13 @@ void index_pfk(struct sadb_msg *, void **);
* Print routing tables.
*/
void
-p_rttables(int af)
+p_rttables(int af, u_int tableid)
{
struct rt_msghdr *rtm;
struct sadb_msg *msg;
char *buf = NULL, *next, *lim = NULL;
size_t needed;
- int mib[6];
+ int mib[7];
struct sockaddr *sa;
mib[0] = CTL_NET;
@@ -127,12 +126,14 @@ p_rttables(int af)
mib[3] = af;
mib[4] = NET_RT_DUMP;
mib[5] = 0;
- if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
+ mib[6] = tableid;
+
+ if (sysctl(mib, 7, NULL, &needed, NULL, 0) < 0)
err(1, "route-sysctl-estimate");
if (needed > 0) {
if ((buf = malloc(needed)) == 0)
err(1, NULL);
- if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
+ if (sysctl(mib, 7, buf, &needed, NULL, 0) < 0)
err(1, "sysctl of routing table");
lim = buf + needed;
}