On 06.03.2012 20:33, Alexander Shikoff wrote:
On Tue, Mar 06, 2012 at 10:14:21PM +0400, Alexander V. Chernikov wrote:
'show bgp sum proto' gives us mapping for proto -> peer address, but what about reverse mapping?
Like this: bird> show bgp summary Proto Peer AS Last state change Prefixes rcvd/best State/Last error b_7204 10.2.33.4 65001 22:00 0/0 Idle Received: No supported AFI/SAFI b_7206 10.2.33.6 65001 22:00 8/3 Established b_mega 10.0.0.1 42678 22:00 0/0 Connect The only reason why I've not included instance name in output is the urge to minimize it. It's easy to implement, if someone really needs instance name in an output.
Ok, so I vote for including protocol name to final version :)
P.S. I've changed style a bit, new version attached. +void +bgp_sh_summary(struct symbol *sym) +{ + struct proto_config *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); + } + else + { + if (EMPTY_LIST(config->protos)) + { + cli_msg(1006, "No protocols match"); + return; + } + } In this case EMPTY_LIST will be applied to global protos list. Thus if you have only non-BGP protos then EMPTY_LIST(config->protos) will return 0 and you'll get header string printed:
It seems sometimes it is better just go to sleep instead of writing patches :) However, we can still define cli_msg as print_header macro before bgp_sh_summary() not to write it twice.
+ +#ifdef IPV6 + cli_msg(-2002, "%-10s %s\n%12s %-19s %-20s %s", "Proto", "Peer", "AS", "Last state change", "Prefixes rcvd/best", "State/Last error" ); +#else + cli_msg(-2002, "%-10s %-15s %10s %-19s %-20s %s", "Proto", "Peer", "AS", "Last state change", "Prefixes rcvd/best", "State/Last error" ); +#endif
... and nothing after it. I tried to avoid that.
+ if (pc) + { + /* Show single protocol info */ + bgp_sh_proto_summary(pc->proto); + cli_msg(0, ""); + return; + } + + WALK_LIST(pc, config->protos) + { + if ((pc->protocol !=&proto_bgp) || (!pc->proto)) + continue; + + bgp_sh_proto_summary(pc->proto); + } + + cli_msg(0, ""); +}