summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-01-03 16:13:50 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-01-03 16:13:50 +0000
commit600d05b077242df14a332bf8cbf2889bd11ca087 (patch)
treecdd02a2dba30e86a1ed52a1f59ea5ff789f64b87
parente2fc0d717603fc33422c7950ce4a10de95cee86e (diff)
factor out the printing stuff and format nicer as well
-rw-r--r--usr.sbin/bgpctl/bgpctl.c22
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