diff options
Diffstat (limited to 'proto')
-rw-r--r-- | proto/static/config.Y | 3 | ||||
-rw-r--r-- | proto/static/static.c | 34 | ||||
-rw-r--r-- | proto/static/static.h | 3 |
3 files changed, 40 insertions, 0 deletions
diff --git a/proto/static/config.Y b/proto/static/config.Y index df9e55b3..1e2d7a86 100644 --- a/proto/static/config.Y +++ b/proto/static/config.Y @@ -57,6 +57,9 @@ stat_route: | stat_route0 PROHIBIT { this_srt->dest = RTD_PROHIBIT; } ; +CF_CLI(SHOW STATIC, optsym, [<name>], [[Show details of static protocol]]) +{ static_show(proto_get_named($3, &proto_static)); } ; + CF_CODE CF_END diff --git a/proto/static/static.c b/proto/static/static.c index d245be2f..4217ad03 100644 --- a/proto/static/static.c +++ b/proto/static/static.c @@ -14,7 +14,9 @@ #include "nest/iface.h" #include "nest/protocol.h" #include "nest/route.h" +#include "nest/cli.h" #include "conf/conf.h" +#include "lib/string.h" #include "static.h" @@ -41,6 +43,7 @@ static_install(struct proto *p, struct static_route *r, struct iface *ifa) e->net = n; e->pflags = 0; rte_update(p->table, n, p, e); + r->installed = 1; } static void @@ -52,6 +55,7 @@ static_remove(struct proto *p, struct static_route *r) n = net_find(p->table, r->net, r->masklen); if (n) rte_update(p->table, n, p, NULL); + r->installed = 0; } static int @@ -177,3 +181,33 @@ struct protocol proto_static = { dump: static_dump, start: static_start, }; + +static void +static_show_rt(struct static_route *r) +{ + byte via[STD_ADDRESS_P_LENGTH + 16]; + + switch (r->dest) + { + case RTD_ROUTER: bsprintf(via, "via %I", r->via); break; + case RTD_DEVICE: bsprintf(via, "to %s", r->if_name); break; + case RTD_BLACKHOLE: bsprintf(via, "blackhole"); break; + case RTD_UNREACHABLE: bsprintf(via, "unreachable"); break; + case RTD_PROHIBIT: bsprintf(via, "prohibited"); break; + default: bsprintf(via, "???"); + } + cli_msg(-1009, "%I/%d %s%s", r->net, r->masklen, via, r->installed ? "" : " (dormant)"); +} + +void +static_show(struct proto *P) +{ + struct static_config *c = (void *) P->cf; + struct static_route *r; + + WALK_LIST(r, c->other_routes) + static_show_rt(r); + WALK_LIST(r, c->iface_routes) + static_show_rt(r); + cli_msg(0, ""); +} diff --git a/proto/static/static.h b/proto/static/static.h index 5299a9f8..66451183 100644 --- a/proto/static/static.h +++ b/proto/static/static.h @@ -26,6 +26,9 @@ struct static_route { ip_addr via; /* Destination router */ struct neighbor *neigh; byte *if_name; /* Name for RTD_DEVICE routes */ + int installed; /* Installed in master table */ }; +void static_show(struct proto *); + #endif |