Пример #1
0
 def test_peer_up_notification(self):
     opt_param = [
         bgp.BGPOptParamCapabilityUnknown(cap_code=200, cap_value=b'hoge'),
         bgp.BGPOptParamCapabilityRouteRefresh(),
         bgp.BGPOptParamCapabilityMultiprotocol(afi=afi.IP,
                                                safi=safi.MPLS_VPN)
     ]
     open_message = bgp.BGPOpen(my_as=40000,
                                bgp_identifier='192.0.2.2',
                                opt_param=opt_param)
     msg = bmp.BMPPeerUpNotification(local_address='192.0.2.2',
                                     local_port=179,
                                     remote_port=11089,
                                     sent_open_message=open_message,
                                     received_open_message=open_message,
                                     peer_type=bmp.BMP_PEER_TYPE_GLOBAL,
                                     is_post_policy=True,
                                     peer_distinguisher=0,
                                     peer_address='192.0.2.1',
                                     peer_as=30000,
                                     peer_bgp_id='192.0.2.1',
                                     timestamp=self._time())
     binmsg = msg.serialize()
     msg2, rest = bmp.BMPMessage.parser(binmsg)
     eq_(msg.to_jsondict(), msg2.to_jsondict())
     eq_(rest, b'')
Пример #2
0
 def test_open1(self):
     msg = bgp.BGPOpen(my_as=30000, bgp_identifier='192.0.2.1')
     binmsg = msg.serialize()
     msg2, _, rest = bgp.BGPMessage.parser(binmsg)
     eq_(str(msg), str(msg2))
     eq_(len(msg), 29)
     eq_(rest, b'')
Пример #3
0
 def test_json1(self):
     opt_param = [
         bgp.BGPOptParamCapabilityUnknown(cap_code=200, cap_value=b'hoge'),
         bgp.BGPOptParamCapabilityRouteRefresh(),
         bgp.BGPOptParamCapabilityMultiprotocol(afi=afi.IP,
                                                safi=safi.MPLS_VPN),
         bgp.BGPOptParamCapabilityFourOctetAsNumber(as_number=1234567),
         bgp.BGPOptParamUnknown(type_=99, value=b'fuga')
     ]
     msg1 = bgp.BGPOpen(my_as=30000,
                        bgp_identifier='192.0.2.2',
                        opt_param=opt_param)
     jsondict = msg1.to_jsondict()
     msg2 = bgp.BGPOpen.from_jsondict(jsondict['BGPOpen'])
     eq_(str(msg1), str(msg2))
Пример #4
0
 def test_open2(self):
     opt_param = [
         bgp.BGPOptParamCapabilityUnknown(cap_code=200, cap_value=b'hoge'),
         bgp.BGPOptParamCapabilityGracefulRestart(flags=0,
                                                  time=120,
                                                  tuples=[]),
         bgp.BGPOptParamCapabilityRouteRefresh(),
         bgp.BGPOptParamCapabilityCiscoRouteRefresh(),
         bgp.BGPOptParamCapabilityMultiprotocol(afi=afi.IP,
                                                safi=safi.MPLS_VPN),
         bgp.BGPOptParamCapabilityCarryingLabelInfo(),
         bgp.BGPOptParamCapabilityFourOctetAsNumber(as_number=1234567),
         bgp.BGPOptParamUnknown(type_=99, value=b'fuga')
     ]
     msg = bgp.BGPOpen(my_as=30000,
                       bgp_identifier='192.0.2.2',
                       opt_param=opt_param)
     binmsg = msg.serialize()
     msg2, _, rest = bgp.BGPMessage.parser(binmsg)
     eq_(str(msg), str(msg2))
     ok_(len(msg) > 29)
     eq_(rest, b'')