diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2006-06-16 16:55:20 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2006-06-16 16:55:20 +0000 |
commit | 54d421fe15bee7839692a4672d2e6a5b47a8fbf1 (patch) | |
tree | b842777d6f512b8f07c2bca235615393d0a6063c /sbin/route/route.c | |
parent | a2301df6e3c29a4111a860fa0491d261af5e0252 (diff) |
introduce -T <tableid> to work on alternate tables.
purposefully undocumented for the moment, claudio hshoexer norby ok
Diffstat (limited to 'sbin/route/route.c')
-rw-r--r-- | sbin/route/route.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c index 5e204f88049..1c44f0d9d55 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.97 2006/05/27 18:26:45 claudio Exp $ */ +/* $OpenBSD: route.c,v 1.98 2006/06/16 16:55:19 henning Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -76,6 +76,7 @@ int iflag, verbose, aflen = sizeof(struct sockaddr_in); int locking, lockrest, debugonly; u_long rtm_inits; uid_t uid; +u_int tableid = 0; struct rt_metrics rt_metrics; @@ -101,6 +102,7 @@ void set_metric(char *, int); void inet_makenetandmask(u_int32_t, struct sockaddr_in *, int); void interfaces(void); void getlabel(char *); +void gettable(const char *); __dead void usage(char *cp) @@ -130,7 +132,7 @@ main(int argc, char **argv) if (argc < 2) usage(NULL); - while ((ch = getopt(argc, argv, "dnqtv")) != -1) + while ((ch = getopt(argc, argv, "dnqtT:v")) != -1) switch (ch) { case 'n': nflag = 1; @@ -144,6 +146,9 @@ main(int argc, char **argv) case 't': tflag = 1; break; + case 'T': + gettable(optarg); + break; case 'd': debugonly = 1; break; @@ -972,6 +977,7 @@ rtmsg(int cmd, int flags, int fmask) rtm.rtm_addrs = rtm_addrs; rtm.rtm_rmx = rt_metrics; rtm.rtm_inits = rtm_inits; + rtm.rtm_tableid = tableid; if (rtm_addrs & RTA_NETMASK) mask_addr(&so_dst, &so_mask, RTA_DST); @@ -1081,7 +1087,8 @@ print_rtmsg(struct rt_msghdr *rtm, int msglen) rtm->rtm_version); return; } - printf("%s: len %d, ", msgtypes[rtm->rtm_type], rtm->rtm_msglen); + printf("%s: len %d, table %u, ", msgtypes[rtm->rtm_type], + rtm->rtm_msglen, rtm->rtm_tableid); switch (rtm->rtm_type) { case RTM_IFINFO: ifm = (struct if_msghdr *)rtm; @@ -1410,3 +1417,13 @@ getlabel(char *name) errx(1, "label too long"); rtm_addrs |= RTA_LABEL; } + +void +gettable(const char *s) +{ + const char *errstr; + + tableid = strtonum(s, 0, RT_TABLEID_MAX, &errstr); + if (errstr) + errx(1, "invalid table id: %s", errstr); +} |