From 600d05b077242df14a332bf8cbf2889bd11ca087 Mon Sep 17 00:00:00 2001 From: Henning Brauer Date: Sat, 3 Jan 2004 16:13:50 +0000 Subject: factor out the printing stuff and format nicer as well --- usr.sbin/bgpctl/bgpctl.c | 22 ++++++++++++++++++---- 1 file 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 @@ -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 -- cgit v1.2.3