Search in sources :

Example 6 with Uint24

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.Uint24 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 7 with Uint24

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.Uint24 in project bgpcep by opendaylight.

the class LlGracefulCapabilityHandlerTest method testRecvdUnsupportedSafi.

@Test
public void testRecvdUnsupportedSafi() {
    final byte[] capaBytes = { // header
    (byte) 0x47, (byte) 0x15, // Ipv4 Unicast, afiFlags = false, timer = 10
    (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, // Unsupported safi, afiFlags = true, timer = 160
    (byte) 0x00, (byte) 0x01, (byte) 0x85, (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0xa0, // Ipv6  Unicast afiFlags = false, timer = 160
    (byte) 0x00, (byte) 0x02, (byte) 0x01, (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0xa0 };
    final LlGracefulRestartCapability capability = new LlGracefulRestartCapabilityBuilder().setTables(BindingMap.ordered(new TablesBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setAfiFlags(new Tables.AfiFlags(Boolean.FALSE)).setLongLivedStaleTime(TEN).build(), new TablesBuilder().setAfi(Ipv6AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setAfiFlags(new Tables.AfiFlags(Boolean.TRUE)).setLongLivedStaleTime(new Uint24(Uint32.valueOf(160))).build())).build();
    final CParameters cParameters = new CParametersBuilder().addAugmentation(new CParameters1Builder().setLlGracefulRestartCapability(capability).build()).build();
    LlGracefulCapabilityHandler handler1 = new LlGracefulCapabilityHandler(afir, safir);
    assertEquals(cParameters, handler1.parseCapability(Unpooled.wrappedBuffer(capaBytes).slice(2, capaBytes.length - 2)));
}
Also used : Ipv6AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily) 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) LlGracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily) LlGracefulRestartCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapability) CParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters) Uint24(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.Uint24) 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) Test(org.junit.Test)

Example 8 with Uint24

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.Uint24 in project bgpcep by opendaylight.

the class LlGracefulCapabilityHandlerTest method testRecvdUnsupportedAfi.

@Test
public void testRecvdUnsupportedAfi() {
    final byte[] capaBytes = { // header
    (byte) 0x47, (byte) 0x15, // Ipv4 Unicast, afiFlags = false, timer = 10
    (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, // Unsupported afi, afiFlags = true, timer = 160
    (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0xa0, // Ipv6  Unicast afiFlags = false, timer = 160
    (byte) 0x00, (byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xa0 };
    final LlGracefulRestartCapability capability = new LlGracefulRestartCapabilityBuilder().setTables(BindingMap.ordered(new TablesBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setAfiFlags(new Tables.AfiFlags(Boolean.FALSE)).setLongLivedStaleTime(TEN).build(), new TablesBuilder().setAfi(Ipv6AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setAfiFlags(new Tables.AfiFlags(Boolean.FALSE)).setLongLivedStaleTime(new Uint24(Uint32.valueOf(160))).build())).build();
    final CParameters cParameters = new CParametersBuilder().addAugmentation(new CParameters1Builder().setLlGracefulRestartCapability(capability).build()).build();
    LlGracefulCapabilityHandler handler1 = new LlGracefulCapabilityHandler(afir, safir);
    assertEquals(cParameters, handler1.parseCapability(Unpooled.wrappedBuffer(capaBytes).slice(2, capaBytes.length - 2)));
}
Also used : Ipv6AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily) 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) LlGracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily) LlGracefulRestartCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapability) CParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters) Uint24(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.Uint24) 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) Test(org.junit.Test)

Aggregations

Uint24 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.Uint24)8 Test (org.junit.Test)5 CParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder)4 CParameters1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder)4 LlGracefulRestartCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapabilityBuilder)4 TablesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.TablesBuilder)4 ByteBuf (io.netty.buffer.ByteBuf)3 CParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters)3 LlGracefulRestartCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapability)3 Ipv4AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily)3 Ipv6AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily)3 LlGracefulCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler)2 Tables (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.Tables)2 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.TablesKey)2 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Mockito.doReturn (org.mockito.Mockito.doReturn)1