summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-05-13 13:42:42 +0200
committerMartin Mares <mj@ucw.cz>2000-05-13 13:42:42 +0200
commit9449c91ab2eb962b17989125c712f805f82a092b (patch)
tree786e8faaf9e89eaf1767688857108d2cd6be96a6
parent56d6c530eba46dde7280d6743fea7e750f2d5635 (diff)
downloadbird-9449c91ab2eb962b17989125c712f805f82a092b.tar
bird-9449c91ab2eb962b17989125c712f805f82a092b.zip
Added `show route for <prefix-or-ipa>' which looks up route leading to
given network.
-rw-r--r--TODO1
-rw-r--r--nest/config.Y9
-rw-r--r--nest/rt-table.c5
3 files changed, 12 insertions, 3 deletions
diff --git a/TODO b/TODO
index 2bf8eb3..9581a48 100644
--- a/TODO
+++ b/TODO
@@ -10,7 +10,6 @@ Core
- filters: user defined attributes?
- cli: show tables?
-- cli: show where is routed given IP address?
- client: Ctrl-R eats one more enter
- client: paging?
diff --git a/nest/config.Y b/nest/config.Y
index f92c054..1267100 100644
--- a/nest/config.Y
+++ b/nest/config.Y
@@ -22,7 +22,7 @@ CF_DECLS
CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS)
CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
-CF_KEYWORDS(PRIMARY, STATS, COUNT)
+CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR)
CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
RIP, OSPF, OSPF_EXT, OSPF_IA, OSPF_BOUNDARY, BGP, PIPE)
@@ -256,6 +256,13 @@ r_args:
$$->prefix = $2.addr;
$$->pxlen = $2.len;
}
+ | r_args FOR prefix_or_ipa {
+ $$ = $1;
+ if ($$->pxlen != 256) cf_error("Only one prefix expected");
+ $$->prefix = $3.addr;
+ $$->pxlen = $3.len;
+ $$->show_for = 1;
+ }
| r_args TABLE SYM {
$$ = $1;
if ($3->class != SYM_TABLE) cf_error("%s is not a table", $3->name);
diff --git a/nest/rt-table.c b/nest/rt-table.c
index cfaa893..7133ed4 100644
--- a/nest/rt-table.c
+++ b/nest/rt-table.c
@@ -846,7 +846,10 @@ rt_show(struct rt_show_data *d)
}
else
{
- n = fib_find(&d->table->fib, &d->prefix, d->pxlen);
+ if (d->show_for)
+ n = fib_route(&d->table->fib, d->prefix, d->pxlen);
+ else
+ n = fib_find(&d->table->fib, &d->prefix, d->pxlen);
if (n)
{
rt_show_net(this_cli, n, d);