summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2014-05-05 16:52:42 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-05-10 01:14:56 +0900
commitca923a35bf86e0b5e51d026f5ab549eaa8bfbe36 (patch)
treef300d9e4a3a8d10a0afc280d623661246d0ffc5e
parent1d97ac17270237a03eeaca89cdb9b7665a99f556 (diff)
packet/bgp: add helper methods to nlri class for bgp ssh client
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/packet/bgp.py44
1 files changed, 42 insertions, 2 deletions
diff --git a/ryu/lib/packet/bgp.py b/ryu/lib/packet/bgp.py
index 8bcffa82..06323a85 100644
--- a/ryu/lib/packet/bgp.py
+++ b/ryu/lib/packet/bgp.py
@@ -716,7 +716,11 @@ class IPAddrPrefix(_UnlabelledAddrPrefix, _IPAddrPrefix):
@property
def prefix(self):
- return self.addr
+ return self.addr+'/{0}'.format(self.length)
+
+ @property
+ def formatted_nlri_str(self):
+ return self.prefix
class IP6AddrPrefix(_UnlabelledAddrPrefix, _IP6AddrPrefix):
@@ -724,18 +728,54 @@ class IP6AddrPrefix(_UnlabelledAddrPrefix, _IP6AddrPrefix):
@property
def prefix(self):
- return self.addr
+ return self.addr+'/{0}'.format(self.length)
+
+ @property
+ def formatted_nlri_str(self):
+ return self.prefix
class LabelledVPNIPAddrPrefix(_LabelledAddrPrefix, _VPNAddrPrefix,
_IPAddrPrefix):
ROUTE_FAMILY = RF_IPv4_VPN
+ @property
+ def prefix(self):
+ return self.addr[-1]+'/{0}'.format(self.length)
+
+ @property
+ def route_disc(self):
+ return self.addr[-2]
+
+ @property
+ def label_list(self):
+ return self.addr[:-2]
+
+ @property
+ def formatted_nlri_str(self):
+ return "%s:%s" % (self.route_disc, self.prefix)
+
class LabelledVPNIP6AddrPrefix(_LabelledAddrPrefix, _VPNAddrPrefix,
_IP6AddrPrefix):
ROUTE_FAMILY = RF_IPv6_VPN
+ @property
+ def prefix(self):
+ return self.addr[-1]+'/{0}'.format(self.length)
+
+ @property
+ def route_disc(self):
+ return self.addr[-2]
+
+ @property
+ def label_list(self):
+ return self.addr[:-2]
+
+ @property
+ def formatted_nlri_str(self):
+ return "%s:%s" % (self.route_disc, self.prefix)
+
class RouteTargetMembershipNLRI(StringifyMixin):
"""Route Target Membership NLRI.