diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2006-06-16 17:46:44 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2006-06-16 17:46:44 +0000 |
commit | bc506cd082eca8c7705ac02c7a764eae84ced91f (patch) | |
tree | 301ae7443fbc2a3dec333bf5a4cfc157eeb6ef31 /sbin/route | |
parent | 5f6e2bfbe3131c3a7d8723ab7ba874a01edc9101 (diff) |
make route show work on secondary tables, using the just committed
extension to the syctl NET_RT_DUMP interface, claudio ok
Diffstat (limited to 'sbin/route')
-rw-r--r-- | sbin/route/route.c | 4 | ||||
-rw-r--r-- | sbin/route/show.c | 12 | ||||
-rw-r--r-- | sbin/route/show.h | 4 |
3 files changed, 11 insertions, 9 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c index 1c44f0d9d55..cb3b42c686b 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.98 2006/06/16 16:55:19 henning Exp $ */ +/* $OpenBSD: route.c,v 1.99 2006/06/16 17:46:43 henning Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -601,7 +601,7 @@ show(int argc, char *argv[]) usage(*argv); } - p_rttables(af); + p_rttables(af, tableid); } void diff --git a/sbin/route/show.c b/sbin/route/show.c index c496688b3a7..21fb61228f5 100644 --- a/sbin/route/show.c +++ b/sbin/route/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.53 2006/05/30 19:42:58 todd Exp $ */ +/* $OpenBSD: show.c,v 1.54 2006/06/16 17:46:43 henning Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -118,13 +118,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; @@ -133,12 +133,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; } diff --git a/sbin/route/show.h b/sbin/route/show.h index dff6b350b6d..54e24c2f13f 100644 --- a/sbin/route/show.h +++ b/sbin/route/show.h @@ -1,4 +1,4 @@ -/* $OpenBSD: show.h,v 1.5 2006/05/27 18:26:45 claudio Exp $ */ +/* $OpenBSD: show.h,v 1.6 2006/06/16 17:46:43 henning Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -19,7 +19,7 @@ #ifndef __SHOW_H__ #define __SHOW_H__ -void p_rttables(int); +void p_rttables(int, u_int); char *routename(struct sockaddr *); char *netname(struct sockaddr *, struct sockaddr *); |