diff options
author | reyk <reyk@openbsd.org> | 2009-08-17 11:36:01 +0000 |
---|---|---|
committer | reyk <reyk@openbsd.org> | 2009-08-17 11:36:01 +0000 |
commit | 417c432fe120d1d83d3ab6abbf095070175b55d0 (patch) | |
tree | 2727e51064854006b10fd8967956440484068e9a /usr.sbin/relayctl | |
parent | remove prototype of non-existent midi_get_hwif() (diff) | |
download | wireguard-openbsd-417c432fe120d1d83d3ab6abbf095070175b55d0.tar.xz wireguard-openbsd-417c432fe120d1d83d3ab6abbf095070175b55d0.zip |
also report routers and their host states in relayctl
ok pyr@, jmc@ for man bits
Diffstat (limited to 'usr.sbin/relayctl')
-rw-r--r-- | usr.sbin/relayctl/parser.c | 3 | ||||
-rw-r--r-- | usr.sbin/relayctl/parser.h | 3 | ||||
-rw-r--r-- | usr.sbin/relayctl/relayctl.8 | 9 | ||||
-rw-r--r-- | usr.sbin/relayctl/relayctl.c | 36 |
4 files changed, 41 insertions, 10 deletions
diff --git a/usr.sbin/relayctl/parser.c b/usr.sbin/relayctl/parser.c index 303713537f9..25c51285b68 100644 --- a/usr.sbin/relayctl/parser.c +++ b/usr.sbin/relayctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.20 2007/12/20 20:15:43 reyk Exp $ */ +/* $OpenBSD: parser.c,v 1.21 2009/08/17 11:36:01 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -82,6 +82,7 @@ static const struct token t_show[] = { {KEYWORD, "hosts", SHOW_HOSTS, NULL}, {KEYWORD, "redirects", SHOW_RDRS, NULL}, {KEYWORD, "relays", SHOW_RELAYS, NULL}, + {KEYWORD, "routers", SHOW_ROUTERS, NULL}, {KEYWORD, "sessions", SHOW_SESSIONS, NULL}, {ENDTOKEN, "", NONE, NULL} }; diff --git a/usr.sbin/relayctl/parser.h b/usr.sbin/relayctl/parser.h index 91e3e949671..0a30ae4584c 100644 --- a/usr.sbin/relayctl/parser.h +++ b/usr.sbin/relayctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.9 2007/12/20 20:15:43 reyk Exp $ */ +/* $OpenBSD: parser.h,v 1.10 2009/08/17 11:36:01 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -23,6 +23,7 @@ enum actions { SHOW_RDRS, SHOW_RELAYS, SHOW_SESSIONS, + SHOW_ROUTERS, RDR_DISABLE, RDR_ENABLE, TABLE_DISABLE, diff --git a/usr.sbin/relayctl/relayctl.8 b/usr.sbin/relayctl/relayctl.8 index 8bf8478fd8d..b5a16209201 100644 --- a/usr.sbin/relayctl/relayctl.8 +++ b/usr.sbin/relayctl/relayctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: relayctl.8,v 1.23 2008/12/31 15:22:27 sobrado Exp $ +.\" $OpenBSD: relayctl.8,v 1.24 2009/08/17 11:36:01 reyk Exp $ .\" .\" Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 31 2008 $ +.Dd $Mdocdate: August 17 2009 $ .Dt RELAYCTL 8 .Os .Sh NAME @@ -76,10 +76,13 @@ not the total number of redirected connections. Show detailed status of relays including the current and average access statistics. The statistics will be updated every minute. +.It Cm show routers +Show detailed status of routers including the configured network +routes. .It Cm show sessions Dump the complete list of running relay sessions. .It Cm show summary -Display a list of all relays, redirections, tables, and hosts. +Display a list of all relays, redirections, routers, tables, and hosts. .It Cm table disable Op Ar name | id Disable a table. Consider all hosts disabled. diff --git a/usr.sbin/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c index 0ce43e44114..81eae4e7bf9 100644 --- a/usr.sbin/relayctl/relayctl.c +++ b/usr.sbin/relayctl/relayctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayctl.c,v 1.38 2009/08/07 11:21:53 reyk Exp $ */ +/* $OpenBSD: relayctl.c,v 1.39 2009/08/17 11:36:01 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -139,6 +139,7 @@ main(int argc, char *argv[]) case SHOW_HOSTS: case SHOW_RDRS: case SHOW_RELAYS: + case SHOW_ROUTERS: imsg_compose(ibuf, IMSG_CTL_SHOW_SUM, 0, 0, -1, NULL, 0); printf("%-4s\t%-8s\t%-24s\t%-7s\tStatus\n", "Id", "Type", "Name", "Avlblty"); @@ -204,6 +205,7 @@ main(int argc, char *argv[]) case SHOW_HOSTS: case SHOW_RDRS: case SHOW_RELAYS: + case SHOW_ROUTERS: done = show_summary_msg(&imsg, res->action); break; case SHOW_SESSIONS: @@ -306,12 +308,14 @@ show_summary_msg(struct imsg *imsg, int type) struct table *table; struct host *host; struct relay *rlay; + struct router *rt; + struct netroute *nr; struct ctl_stats stats[RELAY_MAXPROC]; char name[MAXHOSTNAMELEN]; switch (imsg->hdr.type) { case IMSG_CTL_RDR: - if (type == SHOW_HOSTS || type == SHOW_RELAYS) + if (!(type == SHOW_SUM || type == SHOW_RDRS)) break; rdr = imsg->data; printf("%-4u\t%-8s\t%-24s\t%-7s\t%s\n", @@ -319,7 +323,7 @@ show_summary_msg(struct imsg *imsg, int type) print_rdr_status(rdr->conf.flags)); break; case IMSG_CTL_TABLE: - if (type == SHOW_RELAYS || type == SHOW_RDRS) + if (!(type == SHOW_SUM || type == SHOW_HOSTS)) break; table = imsg->data; printf("%-4u\t%-8s\t%-24s\t%-7s\t%s\n", @@ -327,7 +331,7 @@ show_summary_msg(struct imsg *imsg, int type) print_table_status(table->up, table->conf.flags)); break; case IMSG_CTL_HOST: - if (type == SHOW_RELAYS || type == SHOW_RDRS) + if (!(type == SHOW_SUM || type == SHOW_HOSTS)) break; host = imsg->data; if (host->conf.parentid) @@ -350,7 +354,7 @@ show_summary_msg(struct imsg *imsg, int type) } break; case IMSG_CTL_RELAY: - if (type == SHOW_HOSTS || type == SHOW_RDRS) + if (!(type == SHOW_SUM || type == SHOW_RELAYS)) break; rlay = imsg->data; printf("%-4u\t%-8s\t%-24s\t%-7s\t%s\n", @@ -370,6 +374,28 @@ show_summary_msg(struct imsg *imsg, int type) bcopy(imsg->data, &stats, sizeof(stats)); print_statistics(stats); break; + case IMSG_CTL_ROUTER: + if (!(type == SHOW_SUM || type == SHOW_ROUTERS)) + break; + rt = imsg->data; + printf("%-4u\t%-8s\t%-24s\t%-7s\t%s\n", + rt->rt_conf.id, "router", rt->rt_conf.name, "", + print_relay_status(rt->rt_conf.flags)); + if (type != SHOW_ROUTERS) + break; + if (rt->rt_conf.rtable) + printf("\t%8s\trtable: %d\n", "", rt->rt_conf.rtable); + if (strlen(rt->rt_conf.label)) + printf("\t%8s\trtlabel: %s\n", "", rt->rt_conf.label); + break; + case IMSG_CTL_NETROUTE: + if (type != SHOW_ROUTERS) + break; + nr = imsg->data; + (void)print_host(&nr->nr_conf.ss, name, sizeof(name)); + printf("\t%8s\troute: %s/%d\n", + "", name, nr->nr_conf.prefixlen); + break; case IMSG_CTL_END: return (1); default: |