diff -u proto/bgp/bgp.c.orig proto/bgp/bgp.c --- proto/bgp/bgp.c.orig 2012-01-10 14:42:47.000000000 +0200 +++ proto/bgp/bgp.c 2012-02-28 12:12:35.000000000 +0200 @@ -76,7 +76,7 @@ static void bgp_connect(struct bgp_proto *p); static void bgp_active(struct bgp_proto *p); static sock *bgp_setup_listen_sk(ip_addr addr, unsigned port, u32 flags); - +static void bgp_sh_proto_summary(struct proto *p); /** * bgp_open - open a BGP instance @@ -1174,6 +1174,86 @@ } } +void +bgp_sh_summary(struct symbol *sym) +{ + struct proto_config *pc, *q; + struct proto *p; + + pc = NULL; + if (sym) + { + if (sym->class != SYM_PROTO) + cf_error("%s: Not a protocol", sym->name); + pc = (struct proto_config *)sym->def; + if ( pc->protocol != &proto_bgp ) + cf_error("%s: Not a BGP protocol", sym->name); + +#ifdef IPV6 + cli_msg(-2002, "Peer\n%12s %-19s %-20s %s", "AS", "Last state change", "Prefixes rcvd/best", "State/Last error" ); +#else + cli_msg(-2002, "%-15s %10s %-19s %-20s %s", "Peer", "AS", "Last state change", "Prefixes rcvd/best", "State/Last error" ); +#endif + bgp_sh_proto_summary(pc->proto); + } + else + { + p = NULL; + WALK_LIST(q, config->protos) + { + if (q->protocol == &proto_bgp && q->proto) + { + if (p == NULL) + { +#ifdef IPV6 + cli_msg(-2002, "Peer\n%12s %-19s %-20s %s", "AS", "Last state change", "Prefixes rcvd/best", "State/Last error" ); +#else + cli_msg(-2002, "%-15s %10s %-19s %-20s %s", "Peer", "AS", "Last state change", "Prefixes rcvd/best", "State/Last error" ); +#endif + } + p = q->proto; + bgp_sh_proto_summary(p); + } + } + + if (p == NULL) + cli_msg(-1006, "No protocols match"); + } + cli_msg(0, ""); +} + +static void +bgp_sh_proto_summary(struct proto *p) +{ + struct bgp_proto *bp; + byte tbuf[TM_DATETIME_BUFFER_SIZE]; + char rs[20]; + char ps[256]; + + /* Get protocol data */ + tm_format_datetime(tbuf, &config->tf_proto, p->last_state_change); + + struct proto_stats *s = &p->stats; + bsnprintf(rs, sizeof(rs), "%u/%u", s->imp_routes, s->pref_routes); + + p->proto->get_status(p, ps); + + /* Get BGP protocol from protocol */ + bp = (struct bgp_proto *) p; + + /* Display summary */ +#ifdef IPV6 + cli_msg(-1006, "%I\n%12u %-19s %-20s %s", +#else + cli_msg(-1006, "%-15I %10u %-19s %-20s %s", +#endif + bp->cf->remote_ip, + bp->remote_as, + tbuf, + rs, + ps); +} + struct protocol proto_bgp = { name: "BGP", template: "bgp%d", diff -u proto/bgp/bgp.h.orig proto/bgp/bgp.h --- proto/bgp/bgp.h.orig 2012-01-10 14:42:47.000000000 +0200 +++ proto/bgp/bgp.h 2012-02-28 12:12:35.000000000 +0200 @@ -313,4 +313,6 @@ #define BGP_AF BGP_AF_IPV4 #endif +void bgp_sh_summary(struct symbol *sym); + #endif diff -u proto/bgp/config.Y.orig proto/bgp/config.Y --- proto/bgp/config.Y.orig 2012-01-10 14:42:47.000000000 +0200 +++ proto/bgp/config.Y 2012-02-28 12:18:37.000000000 +0200 @@ -133,6 +133,11 @@ CF_ENUM(T_ENUM_BGP_ORIGIN, ORIGIN_, IGP, EGP, INCOMPLETE) +CF_CLI_HELP(SHOW BGP, , [[Show BGP protocol information]]) + +CF_CLI(SHOW BGP SUMMARY, optsym, [], [[Show BGP peers summary]]) +{ bgp_sh_summary($4); }; + CF_CODE CF_END