diff -u --recursive bird-1.3.6.o//nest/config.Y bird-1.3.6/nest/config.Y --- bird-1.3.6.o//nest/config.Y 2012-01-10 13:42:47.000000000 +0100 +++ bird-1.3.6/nest/config.Y 2012-02-09 19:47:31.286556659 +0100 @@ -435,6 +435,9 @@ CF_CLI(SHOW SYMBOLS, optsym, [], [[Show all known symbolic names]]) { cmd_show_symbols($3); } ; +CF_CLI_HELP(SHOW BGP, ..., [[Show BGP information]]) +CF_CLI(SHOW BGP SUMMARY,,, [[Show BGP summary]]) +{ proto_cmd_show_summary("BGP"); } ; CF_CLI_HELP(DUMP, ..., [[Dump debugging information]]) CF_CLI(DUMP RESOURCES,,, [[Dump all allocated resource]]) diff -u --recursive bird-1.3.6.o//nest/proto.c bird-1.3.6/nest/proto.c --- bird-1.3.6.o//nest/proto.c 2012-01-10 13:42:47.000000000 +0100 +++ bird-1.3.6/nest/proto.c 2012-02-09 19:48:09.836165541 +0100 @@ -964,6 +964,23 @@ } void +proto_cmd_show_summary(char *name) +{ + int cnt = 0; + node *n; + + cli_msg(-2002, "Peer\n%12s %-19s %-20s %s", "AS", "Last state change", "Prefixes rcvd/best","State/Last error" ); + WALK_LIST(n, proto_list) + { + struct proto *p = SKIP_BACK(struct proto, glob_node, n); + if (patmatch(name, p->proto->name)) + p->proto->show_proto_summary(p); + } + cli_msg(0, ""); +} + +void + proto_cmd_disable(struct proto *p, unsigned int arg UNUSED, int cnt UNUSED) { if (p->disabled) diff -u --recursive bird-1.3.6.o//nest/protocol.h bird-1.3.6/nest/protocol.h --- bird-1.3.6.o//nest/protocol.h 2012-01-10 13:42:47.000000000 +0100 +++ bird-1.3.6/nest/protocol.h 2012-02-09 19:53:19.357025194 +0100 @@ -52,7 +52,8 @@ void (*get_status)(struct proto *, byte *buf); /* Get instance status (for `show protocols' command) */ void (*get_route_info)(struct rte *, byte *buf, struct ea_list *attrs); /* Get route information (for `show route' command) */ int (*get_attr)(struct eattr *, byte *buf, int buflen); /* ASCIIfy dynamic attribute (returns GA_*) */ - void (*show_proto_info)(struct proto *); /* Show protocol info (for `show protocols all' command) */ + void (*show_proto_info)(struct proto *); /* Show protocol info (for `show protocols all' command) */ + void (*show_proto_summary)(struct proto *); /* Show protocol one-line summary (for show bgp|ospf-related commands) */ void (*copy_config)(struct proto_config *, struct proto_config *); /* Copy config from given protocol instance */ }; @@ -218,6 +219,7 @@ { memcpy(dest + 1, src + 1, size - sizeof(struct proto_config)); } void proto_cmd_show(struct proto *, unsigned int, int); +void proto_cmd_show_summary(char *); void proto_cmd_disable(struct proto *, unsigned int, int); void proto_cmd_enable(struct proto *, unsigned int, int); void proto_cmd_restart(struct proto *, unsigned int, int); diff -u --recursive bird-1.3.6.o//proto/bgp/bgp.c bird-1.3.6/proto/bgp/bgp.c --- bird-1.3.6.o//proto/bgp/bgp.c 2012-01-10 13:42:47.000000000 +0100 +++ bird-1.3.6/proto/bgp/bgp.c 2012-02-09 19:50:04.529001887 +0100 @@ -971,6 +971,29 @@ c->gw_mode = (c->multihop || internal) ? GW_RECURSIVE : GW_DIRECT; } +static void +bgp_show_proto_summary(struct proto *P) +{ + struct bgp_proto *p = (struct bgp_proto *) P; + char rs[20]; + char ps[256]; + byte tbuf[TM_DATETIME_BUFFER_SIZE]; + struct proto_stats *s = &P->stats; + + tm_format_datetime(tbuf, &config->tf_proto, P->last_state_change); + + bsnprintf(rs, sizeof(rs), "%u/%u", s->imp_routes, s->pref_routes); + P->proto->get_status(P, ps); + + cli_msg(-1006, "%I\n%12u %-19s %-20s %s", + p->cf->remote_ip, + p->remote_as, + tbuf, + rs, + ps); +} + + static int bgp_reconfigure(struct proto *P, struct proto_config *C) { @@ -1187,5 +1210,7 @@ get_status: bgp_get_status, get_attr: bgp_get_attr, get_route_info: bgp_get_route_info, - show_proto_info: bgp_show_proto_info + show_proto_info: bgp_show_proto_info, + show_proto_summary: bgp_show_proto_summary + };