diff -aur bird-1.3.2.orig/nest/config.Y bird-1.3.2/nest/config.Y --- bird-1.3.2.orig/nest/config.Y 2011-07-10 11:58:51.000000000 +0200 +++ bird-1.3.2/nest/config.Y 2011-07-21 15:23:34.000000000 +0200 @@ -427,6 +427,10 @@ 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]]) { rdump(&root_pool); cli_msg(0, ""); } ; diff -aur bird-1.3.2.orig/nest/proto.c bird-1.3.2/nest/proto.c --- bird-1.3.2.orig/nest/proto.c 2011-07-10 11:58:51.000000000 +0200 +++ bird-1.3.2/nest/proto.c 2011-07-21 15:39:59.000000000 +0200 @@ -910,6 +910,32 @@ } void +proto_cmd_show_summary(char *name) +{ + int cnt = 0; + node *nn; + struct bgp_proto *bp; + + cli_msg(-1000, "%-15s %10s %-19s %-20s %s", "Peer", "AS", "Last state change", "Prefixes rcvd/best", "State/Last error"); + WALK_LIST(nn, proto_list) + { + struct proto *p = SKIP_BACK(struct proto, glob_node, nn); + + if (patmatch(name, p->proto->name)) + { + p->proto->show_proto_summary(p); + } + } + +/* if (!cnt) + cli_msg(8003, "No protocols match"); + else + cli_msg(0, "");*/ + + cli_msg(0, ""); +} + +void proto_cmd_disable(struct proto *p, unsigned int arg UNUSED, int cnt UNUSED) { if (p->disabled) diff -aur bird-1.3.2.orig/nest/protocol.h bird-1.3.2/nest/protocol.h --- bird-1.3.2.orig/nest/protocol.h 2011-07-10 11:58:51.000000000 +0200 +++ bird-1.3.2/nest/protocol.h 2011-07-21 15:39:13.000000000 +0200 @@ -53,6 +53,7 @@ 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_summary)(struct proto *); /* Show protocol one-line summary (for show bgp|ospf -related commands) */ }; void protos_build(void); @@ -213,6 +214,7 @@ void proto_cmd_reload(struct proto *, unsigned int, int); void proto_cmd_debug(struct proto *, unsigned int, int); void proto_cmd_mrtdump(struct proto *, unsigned int, int); +void proto_cmd_show_summary(char *); void proto_apply_cmd(struct proto_spec ps, void (* cmd)(struct proto *, unsigned int, int), int restricted, unsigned int arg); struct proto *proto_get_named(struct symbol *, struct protocol *); diff -aur bird-1.3.2.orig/proto/bgp/bgp.c bird-1.3.2/proto/bgp/bgp.c --- bird-1.3.2.orig/proto/bgp/bgp.c 2011-07-10 11:58:51.000000000 +0200 +++ bird-1.3.2/proto/bgp/bgp.c 2011-07-21 15:38:21.000000000 +0200 @@ -1092,6 +1092,29 @@ } } +static void +bgp_show_proto_summary(struct proto *P) +{ + struct bgp_proto *p = (struct bgp_proto *) P; + struct bgp_conn *c = p->conn; + 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(-1000, "%-15I %10u %-19s %-20s %s", + p->cf->remote_ip, + p->remote_as, + tbuf, + rs, + ps); +} + static int bgp_reconfigure(struct proto *P, struct proto_config *C) { @@ -1126,5 +1149,6 @@ 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 + };