diff options
author | 2004-01-03 16:13:49 +0000 | |
---|---|---|
committer | 2004-01-03 16:13:49 +0000 | |
commit | f85ac724ac4ad6dadbf4ea7c113604425ecb37c5 (patch) | |
tree | 649f4e1c5bd595c769827463b7bfe6057b9cea29 | |
parent | disable TSC for Geode SC1100; Stuart Henderson, pr 3625; ok mickey, deraadt (diff) | |
download | wireguard-openbsd-f85ac724ac4ad6dadbf4ea7c113604425ecb37c5.tar.xz wireguard-openbsd-f85ac724ac4ad6dadbf4ea7c113604425ecb37c5.zip |
factor out the printing stuff and format nicer as well
-rw-r--r-- | usr.sbin/bgpctl/bgpctl.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index ff8adff1902..aab92f5151f 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.3 2004/01/03 14:06:42 henning Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.4 2004/01/03 16:13:49 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -27,6 +27,8 @@ #include "bgpd.h" int main(int, char *[]); +void print_summary_head(void); +void print_summary(struct peer *); struct imsgbuf ibuf; @@ -63,6 +65,7 @@ main(int argc, char *argv[]) imsg_init(&ibuf, fd); imsg_compose(&ibuf, IMSG_CTL_SHOW_NEIGHBOR, 0, NULL, 0); + print_summary_head(); done = 0; while (!done) { @@ -84,9 +87,7 @@ main(int argc, char *argv[]) switch (imsg.hdr.type) { case IMSG_CTL_SHOW_NEIGHBOR: p = imsg.data; - printf("%s: %s\n", - inet_ntoa(p->conf.remote_addr.sin_addr), - statenames[p->state]); + print_summary(p); break; case IMSG_CTL_END: done = 1; @@ -98,3 +99,16 @@ main(int argc, char *argv[]) } close(fd); } + +void +print_summary_head(void) +{ + printf("%-15s %-5s %s\n", "Neighbor", "AS", "Status"); +} + +void +print_summary(struct peer *p) +{ + printf("%-15s %5u %s\n", inet_ntoa(p->conf.remote_addr.sin_addr), + p->conf.remote_as, statenames[p->state]); +}
\ No newline at end of file |