summaryrefslogtreecommitdiffhomepage
path: root/cli/gobgpcli
diff options
context:
space:
mode:
Diffstat (limited to 'cli/gobgpcli')
-rwxr-xr-xcli/gobgpcli44
1 files changed, 31 insertions, 13 deletions
diff --git a/cli/gobgpcli b/cli/gobgpcli
index bbb70503..c2bac48f 100755
--- a/cli/gobgpcli
+++ b/cli/gobgpcli
@@ -226,26 +226,44 @@ class Show(object):
return self._neighbor(neighbor=self.args[1])
if self.args[2] == "local":
self.args[2] = "local-rib"
+ if self.args[2] == "received-routes":
+ self.args[2] = "adj-rib-in"
+ if self.args[2] == "advertised-routes":
+ self.args[2] = "adj-rib-out"
+
r = requests.get(self.base_url + "/neighbor/" + self.args[1] + "/" + self.args[2])
if self.options.debug:
print r.json()
return 0
+
print(" Network Next Hop AS_PATH Attrs")
- for d in r.json()["Destinations"]:
- for p in d["Paths"]:
- nexthop = ""
- AS = ""
- for a in p["Attrs"]:
- if a["Type"] == "BGP_ATTR_TYPE_AS_PATH":
- AS = a["AsPath"]
- if p["Best"] == "true":
- header = "*>"
- else:
- header = "*"
- print("{:s} {:s} {:s} {:s} {:s}".format(header, p["Network"],
- p["Nexthop"], AS, self._format_attrs(p["Attrs"])))
+ if self.args[2] =="local-rib":
+ for d in r.json()["Destinations"]:
+ self.show_routes(d["Paths"])
+
+ elif self.args[2] == "adj-rib-in" or self.args[2] == "adj-rib-out":
+ rfs = ["RF_IPv4_UC", "RF_IPv6_UC"]
+ for rf in rfs:
+ paths = r.json()[rf]
+ self.show_routes(paths)
+
return 0
+ def show_routes(self, paths):
+ for p in paths:
+ nexthop = ""
+ AS = ""
+ for a in p["Attrs"]:
+ if a["Type"] == "BGP_ATTR_TYPE_AS_PATH":
+ AS = a["AsPath"]
+ if p["Best"] == "true":
+ header = "*>"
+ else:
+ header = "*"
+ print("{:s} {:s} {:s} {:s} {:s}".format(header, p["Network"],
+ p["Nexthop"], AS, self._format_attrs(p["Attrs"])))
+
+
def main():
usage = "gobpgcli [options] <command> <args>"