Search in sources :

Example 31 with BgpParameters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters in project bgpcep by opendaylight.

the class ParserTest method testOpenMessage.

/*
     * ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
     * 00 3d <- length (61) - including header
     * 01 <- message type
     * 04 <- BGP version
     * 00 64 <- My AS Number (AS TRANS in this case)
     * 00 b4 <- Hold Time
     * 00 00 00 00 <- BGP Identifier
     * 20 <- Optional Parameters Length
     * 02 <- opt. param. type (capabilities)
     * 06 <- length
     * 01 <- capability code (MP Extensions for BGP4)
     * 04 <- length
     * 00 01 00 01 <- AFI 1, SAFI 1
     * 02 <- opt. param. type (capabilities)
     * 06 <- length
     * 01 <- capability code (MP Extensions for BGP4)
     * 04 <- length
     * 00 02 00 01 <- AFI 2, SAFI 1
     * 02 <- opt. param. type (capabilities)
     * 06 <- length
     * 01 <- capability code (MP Extensions for BGP4)
     * 04 <- length
     * 40 04 00 47 <- AFI 16388, SAFI 71
     * 02 <- opt. param. type (capabilities)
     * 06 <- length
     * 41 <- capability code (AS4 octet support)
     * 04 <- length
     * 00 00 00 64 <- AS number
     */
@Test
public void testOpenMessage() throws Exception {
    final MessageRegistry msgReg = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getMessageRegistry();
    final Notification o = msgReg.parseMessage(Unpooled.copiedBuffer(inputBytes.get(3)), null);
    final Open open = (Open) o;
    final Set<BgpTableType> types = Sets.newHashSet();
    for (final BgpParameters param : open.getBgpParameters()) {
        for (final OptionalCapabilities optCapa : param.getOptionalCapabilities()) {
            final CParameters cParam = optCapa.getCParameters();
            if (cParam != null && cParam.getAugmentation(CParameters1.class) != null && cParam.getAugmentation(CParameters1.class).getMultiprotocolCapability() != null) {
                final MultiprotocolCapability mp = cParam.getAugmentation(CParameters1.class).getMultiprotocolCapability();
                final BgpTableType type = new BgpTableTypeImpl(mp.getAfi(), mp.getSafi());
                types.add(type);
            }
        }
    }
    final Set<BgpTableType> expected = Sets.newHashSet();
    expected.add(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
    expected.add(new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class));
    expected.add(new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
    assertEquals(expected, types);
    final ByteBuf buffer = Unpooled.buffer();
    msgReg.serializeMessage(o, buffer);
    assertArrayEquals(inputBytes.get(3), ByteArray.readAllBytes(buffer));
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) Ipv6AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily) LinkstateSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.LinkstateSubsequentAddressFamily) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily) CParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParameters) LinkstateAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.LinkstateAddressFamily) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) CParameters1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1) ByteBuf(io.netty.buffer.ByteBuf) Notification(org.opendaylight.yangtools.yang.binding.Notification) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Open) OptionalCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilities) MultiprotocolCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapability) MessageRegistry(org.opendaylight.protocol.bgp.parser.spi.MessageRegistry) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily) Test(org.junit.Test)

Aggregations

BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters)26 OptionalCapabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilities)19 BgpParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParametersBuilder)15 OptionalCapabilitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilitiesBuilder)13 CParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParametersBuilder)13 CParameters1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1Builder)13 MultiprotocolCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapabilityBuilder)12 Test (org.junit.Test)11 OpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenBuilder)11 CParameters1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1)11 Open (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Open)10 ByteBuf (io.netty.buffer.ByteBuf)7 InetSocketAddress (java.net.InetSocketAddress)7 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)7 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)7 As4BytesCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapabilityBuilder)7 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.ProtocolVersion)6 Notification (org.opendaylight.yangtools.yang.binding.Notification)6 BGPSessionPreferences (org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences)5 BgpId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId)5