From 8312ab23b389d1c2da9c722954c237278b4ee898 Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Fri, 30 Mar 2018 11:33:58 +0900 Subject: mrtlib: Define JSON representation types Signed-off-by: IWASE Yusuke Signed-off-by: FUJITA Tomonori --- ryu/lib/mrtlib.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ryu/lib/mrtlib.py b/ryu/lib/mrtlib.py index a89ccfcc..c2d50c6e 100644 --- a/ryu/lib/mrtlib.py +++ b/ryu/lib/mrtlib.py @@ -264,6 +264,12 @@ class Ospf2MrtMessage(MrtMessage): # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ _HEADER_FMT = '!4s4s' HEADER_SIZE = struct.calcsize(_HEADER_FMT) + _TYPE = { + 'ascii': [ + 'remote_ip', + 'local_ip', + ], + } def __init__(self, remote_ip, local_ip, ospf_message): self.remote_ip = remote_ip @@ -328,6 +334,12 @@ class TableDumpMrtMessage(MrtMessage): # +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ _HEADER_FMT = '' # should be defined in subclass HEADER_SIZE = 0 + _TYPE = { + 'ascii': [ + 'prefix', + 'peer_ip', + ], + } def __init__(self, view_num, seq_num, prefix, prefix_len, status, originated_time, peer_ip, peer_as, bgp_attributes, @@ -457,6 +469,11 @@ class TableDump2PeerIndexTableMrtMessage(TableDump2MrtMessage): HEADER_SIZE = struct.calcsize(_HEADER_FMT) _PEER_COUNT_FMT = '!H' PEER_COUNT_SIZE = struct.calcsize(_PEER_COUNT_FMT) + _TYPE = { + 'ascii': [ + 'bgp_id', + ], + } def __init__(self, bgp_id, peer_entries, view_name='', view_name_len=None, peer_count=None): @@ -540,6 +557,13 @@ class MrtPeer(stringify.StringifyMixin): IP_ADDR_FAMILY_BIT = 1 << 0 AS_NUMBER_SIZE_BIT = 1 << 1 + _TYPE = { + 'ascii': [ + 'bgp_id', + 'ip_addr', + ], + } + def __init__(self, bgp_id, ip_addr, as_num, type_=0): self.type = type_ self.bgp_id = bgp_id @@ -937,6 +961,12 @@ class Bgp4MpMrtMessage(MrtMessage): """ MRT Message for the BGP4MP Type. """ + _TYPE = { + 'ascii': [ + 'peer_ip', + 'local_ip', + ], + } @MrtRecord.register_type(MrtRecord.TYPE_BGP4MP) -- cgit v1.2.3