From edf0ca14a493b4e01bbb4279c1d282a20b2d4da5 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 6 Jan 2015 22:40:31 +0900 Subject: cli: improve the capability representation Show both advertised and received caps like: fujita@ubuntu:~/git/gobgp$ ./cli/gobgpcli show neighbor 10.0.0.2 BGP neighbor is 10.0.0.2, remote AS 64515 BGP version 4, remote router ID 192.168.0.2 BGP state = BGP_FSM_ESTABLISHED, up for 0:09:28.011988 Neighbor capabilities: MULTIPROTOCOL: advertised and received ROUTE_REFRESH: advertised and received FOUR_OCTET_AS_NUMBER: advertised and received ROUTE_REFRESH_CISCO: received Message statistics: Sent Rcvd Opens: 2 1 Notifications: 0 0 Updates: 0 0 Keepalives: 18 1 Route Refesh: 0 0 Total: 20 2 Signed-off-by: FUJITA Tomonori --- cli/gobgpcli | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'cli') diff --git a/cli/gobgpcli b/cli/gobgpcli index 325c268d..f1209bb3 100755 --- a/cli/gobgpcli +++ b/cli/gobgpcli @@ -70,12 +70,20 @@ class Show(object): print(" BGP version 4, remote router ID {:s}".format(n["conf"]["id"])) print(" BGP state = {:s}, up for {:s}".format(n["info"]["bgp_state"], str(timedelta(seconds=n["info"]["uptime"])))) print(" Neighbor capabilities:") - for i in n["conf"]["CapList"]: + allcap = set(n["conf"]["RemoteCap"]) | set(n["conf"]["LocalCap"]) + for i in sorted(allcap): if i in capdict: - i = capdict[i] + k = capdict[i] else: - i = "UNKNOWN (" + str(i) + ")" - print(" {:s}".format(i)) + k = "UNKNOWN (" + str(i) + ")" + r = "" + if i in n["conf"]["LocalCap"]: + r += "advertised" + if i in n["conf"]["RemoteCap"]: + if len(r) != 0: + r += " and " + r += "received" + print(" {:s}: {:s}".format(k, r)) print(" Message statistics:") print(" Sent Rcvd") print(" Opens: {:>10d} {:>10d}".format(n["info"]["open_message_out"], n["info"]["open_message_in"])) -- cgit v1.2.3