Search in sources :

Example 21 with CParameters1Builder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder in project bgpcep by opendaylight.

the class APITest method testBgpExtendedMessageUtil.

@Test
public void testBgpExtendedMessageUtil() {
    final List<BgpParameters> params = new ArrayList<>();
    final List<OptionalCapabilities> capas = new ArrayList<>();
    capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().build()).build()).build()).build());
    capas.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
    params.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
    final Open open1 = new OpenBuilder().setBgpParameters(params).build();
    assertTrue(BgpExtendedMessageUtil.advertizedBgpExtendedMessageCapability(open1));
}
Also used : OptionalCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilitiesBuilder) CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder) MultiprotocolCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapabilityBuilder) OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.OpenBuilder) ArrayList(java.util.ArrayList) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters) BgpParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParametersBuilder) OptionalCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilities) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Open) Test(org.junit.Test)

Example 22 with CParameters1Builder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder in project bgpcep by opendaylight.

the class LlGracefulCapabilityHandler method parseCapability.

@Override
public CParameters parseCapability(final ByteBuf buffer) {
    final BindingMap.Builder<TablesKey, Tables> tables = BindingMap.builder();
    while (buffer.isReadable()) {
        final short afival = buffer.readShort();
        final Class<? extends AddressFamily> afi = this.afiReg.classForFamily(afival);
        if (afi == null) {
            LOG.debug("Ignoring GR capability for unknown address family {}", afival);
            buffer.skipBytes(PER_TABLE_SIZE - 2);
            continue;
        }
        final byte safival = buffer.readByte();
        final Class<? extends SubsequentAddressFamily> safi = this.safiReg.classForFamily(safival);
        if (safi == null) {
            LOG.debug("Ignoring GR capability for unknown subsequent address family {}", safival);
            buffer.skipBytes(PER_TABLE_SIZE - 3);
            continue;
        }
        final byte afiFlags = buffer.readByte();
        final int staleTime = buffer.readUnsignedMedium();
        final Tables table = new TablesBuilder().setAfi(afi).setSafi(safi).setAfiFlags(new Tables.AfiFlags(afiFlags == AFI_FLAG_FORWARDING_STATE)).setLongLivedStaleTime(new Uint24(Uint32.valueOf(staleTime))).build();
        tables.add(table);
    }
    return new CParametersBuilder().addAugmentation(new CParameters1Builder().setLlGracefulRestartCapability(new LlGracefulRestartCapabilityBuilder().setTables(tables.build()).build()).build()).build();
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.TablesKey) BindingMap(org.opendaylight.yangtools.yang.binding.util.BindingMap) LlGracefulRestartCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapabilityBuilder) TablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.TablesBuilder) CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.Tables) Uint24(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.Uint24)

Example 23 with CParameters1Builder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder in project bgpcep by opendaylight.

the class GracefulCapabilityHandler method parseCapability.

@Override
public CParameters parseCapability(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
    final GracefulRestartCapabilityBuilder cb = new GracefulRestartCapabilityBuilder();
    final int flagBits = buffer.getByte(0) >> RESTART_FLAGS_SIZE;
    cb.setRestartFlags(new RestartFlags((flagBits & Byte.SIZE) != 0));
    final int timer = ((buffer.readUnsignedByte() & TIMER_TOPBITS_MASK) << Byte.SIZE) + buffer.readUnsignedByte();
    cb.setRestartTime(Uint16.valueOf(timer));
    final BindingMap.Builder<TablesKey, Tables> tables = BindingMap.builder();
    while (buffer.readableBytes() != 0) {
        final int afiVal = buffer.readShort();
        final Class<? extends AddressFamily> afi = this.afiReg.classForFamily(afiVal);
        if (afi == null) {
            LOG.debug("Ignoring GR capability for unknown address family {}", afiVal);
            buffer.skipBytes(PER_AFI_SAFI_SIZE - 2);
            continue;
        }
        final int safiVal = buffer.readUnsignedByte();
        final Class<? extends SubsequentAddressFamily> safi = this.safiReg.classForFamily(safiVal);
        if (safi == null) {
            LOG.debug("Ignoring GR capability for unknown subsequent address family {}", safiVal);
            buffer.skipBytes(1);
            continue;
        }
        final int flags = buffer.readUnsignedByte();
        tables.add(new TablesBuilder().setAfi(afi).setSafi(safi).setAfiFlags(new AfiFlags((flags & AFI_FLAG_FORWARDING_STATE) != 0)).build());
    }
    cb.setTables(tables.build());
    return new CParametersBuilder().addAugmentation(new CParameters1Builder().setGracefulRestartCapability(cb.build()).build()).build();
}
Also used : RestartFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapability.RestartFlags) AfiFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables.AfiFlags) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey) BindingMap(org.opendaylight.yangtools.yang.binding.util.BindingMap) TablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesBuilder) CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables) GracefulRestartCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapabilityBuilder)

Example 24 with CParameters1Builder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder in project bgpcep by opendaylight.

the class RouteRefreshCapabilityHandlerTest method testRRCapHandler.

@Test
public void testRRCapHandler() throws BGPDocumentedException, BGPParsingException {
    final CParameters expectedParams = new CParametersBuilder().addAugmentation(new CParameters1Builder().setRouteRefreshCapability(new RouteRefreshCapabilityBuilder().build()).build()).build();
    assertEquals(expectedParams, HANDLER.parseCapability(Unpooled.copiedBuffer(OK_BYTES)));
    assertEquals(expectedParams, HANDLER.parseCapability(Unpooled.copiedBuffer(WRONG_BYTES)));
    final ByteBuf byteAggregator = Unpooled.buffer(2);
    HANDLER.serializeCapability(expectedParams, byteAggregator);
    assertEquals(Unpooled.copiedBuffer(CAP_BYTES), byteAggregator);
    final CParameters missingCap = new CParametersBuilder().addAugmentation(new CParameters1Builder().setRouteRefreshCapability(null).build()).build();
    final ByteBuf byteAggregator2 = Unpooled.buffer(0);
    HANDLER.serializeCapability(missingCap, byteAggregator2);
    assertEquals(Unpooled.copiedBuffer(new byte[] {}), byteAggregator2);
}
Also used : CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder) CParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters) RouteRefreshCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.RouteRefreshCapabilityBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 25 with CParameters1Builder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder in project bgpcep by opendaylight.

the class AddPathCapabilityHandlerTest method noSerializationTest.

@Test
public void noSerializationTest() {
    final CParameters capabilityNoAugmentation = new CParametersBuilder().removeAugmentation(CParameters1.class).build();
    final CParameters capabilityNoMP = new CParametersBuilder().addAugmentation(new CParameters1Builder().build()).build();
    final ByteBuf bytes = Unpooled.buffer();
    final AddPathCapabilityHandler handler = new AddPathCapabilityHandler(this.afiRegistry, this.safirException);
    handler.serializeCapability(capabilityNoAugmentation, bytes);
    assertEquals(0, bytes.readableBytes());
    handler.serializeCapability(capabilityNoMP, bytes);
    assertEquals(0, bytes.readableBytes());
}
Also used : CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder) AddPathCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler) CParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters) CParameters1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

CParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder)38 CParameters1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder)38 Test (org.junit.Test)28 ByteBuf (io.netty.buffer.ByteBuf)21 ArrayList (java.util.ArrayList)18 CParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters)18 MultiprotocolCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapabilityBuilder)16 OptionalCapabilitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilitiesBuilder)13 BgpParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParametersBuilder)11 OptionalCapabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilities)11 GracefulRestartCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapabilityBuilder)11 OpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.OpenBuilder)10 As4BytesCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapabilityBuilder)10 Ipv4AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily)9 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters)8 Open (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Open)7 AddPathCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.AddPathCapabilityBuilder)7 RestartFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapability.RestartFlags)7 TablesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesBuilder)7 AddPathCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler)6