Ejemplo n.º 1
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))
Ejemplo n.º 2
0
 def test_open2(self):
     opt_param = [bgp.BGPOptParamCapabilityUnknown(cap_code=200,
                                                   cap_value='hoge'),
                  bgp.BGPOptParamCapabilityRouteRefresh(),
                  bgp.BGPOptParamCapabilityMultiprotocol(
                      afi=afi.IP, safi=safi.MPLS_VPN),
                  bgp.BGPOptParamCapabilityFourOctetAsNumber(
                      as_number=1234567),
                  bgp.BGPOptParamUnknown(type_=99, value='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, '')
Ejemplo n.º 3
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'')