Search in sources :

Example 1 with LlGracefulCapabilityHandler

use of org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler in project bgpcep by opendaylight.

the class BGPActivator method registerCapabilityParsers.

private static void registerCapabilityParsers(final List<Registration> regs, final BGPExtensionProviderContext context) {
    final AddressFamilyRegistry afiReg = context.getAddressFamilyRegistry();
    final SubsequentAddressFamilyRegistry safiReg = context.getSubsequentAddressFamilyRegistry();
    final MultiProtocolCapabilityHandler multi = new MultiProtocolCapabilityHandler(afiReg, safiReg);
    regs.add(context.registerCapabilityParser(MultiProtocolCapabilityHandler.CODE, multi));
    regs.add(context.registerCapabilitySerializer(MultiprotocolCapability.class, multi));
    final AddPathCapabilityHandler addPath = new AddPathCapabilityHandler(afiReg, safiReg);
    regs.add(context.registerCapabilityParser(AddPathCapabilityHandler.CODE, addPath));
    regs.add(context.registerCapabilitySerializer(AddPathCapability.class, addPath));
    final RouteRefreshCapabilityHandler routeRefresh = new RouteRefreshCapabilityHandler();
    regs.add(context.registerCapabilityParser(RouteRefreshCapabilityHandler.CODE, routeRefresh));
    regs.add(context.registerCapabilitySerializer(RouteRefreshCapability.class, routeRefresh));
    final As4CapabilityHandler as4 = new As4CapabilityHandler();
    regs.add(context.registerCapabilityParser(As4CapabilityHandler.CODE, as4));
    regs.add(context.registerCapabilitySerializer(As4BytesCapability.class, as4));
    final GracefulCapabilityHandler grace = new GracefulCapabilityHandler(afiReg, safiReg);
    regs.add(context.registerCapabilitySerializer(GracefulRestartCapability.class, grace));
    regs.add(context.registerCapabilityParser(GracefulCapabilityHandler.CODE, grace));
    final LlGracefulCapabilityHandler llgrace = new LlGracefulCapabilityHandler(afiReg, safiReg);
    regs.add(context.registerCapabilitySerializer(LlGracefulRestartCapability.class, llgrace));
    regs.add(context.registerCapabilityParser(LlGracefulCapabilityHandler.CODE, llgrace));
    final CapabilityParameterParser cpp = new CapabilityParameterParser(context.getCapabilityRegistry());
    regs.add(context.registerParameterParser(CapabilityParameterParser.TYPE, cpp));
    regs.add(context.registerParameterSerializer(BgpParameters.class, cpp));
    final BgpExtendedMessageCapabilityHandler bgpextmessage = new BgpExtendedMessageCapabilityHandler();
    regs.add(context.registerCapabilityParser(BgpExtendedMessageCapabilityHandler.CODE, bgpextmessage));
    regs.add(context.registerCapabilitySerializer(BgpExtendedMessageCapability.class, bgpextmessage));
}
Also used : AddressFamilyRegistry(org.opendaylight.protocol.bgp.parser.spi.AddressFamilyRegistry) SubsequentAddressFamilyRegistry(org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry) RouteRefreshCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.RouteRefreshCapability) RouteRefreshCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.RouteRefreshCapabilityHandler) AddPathCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler) GracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.GracefulCapabilityHandler) LlGracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler) LlGracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler) CapabilityParameterParser(org.opendaylight.protocol.bgp.parser.impl.message.open.CapabilityParameterParser) As4CapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.As4CapabilityHandler) As4BytesCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapability) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters) MultiProtocolCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.MultiProtocolCapabilityHandler) BgpExtendedMessageCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.BgpExtendedMessageCapabilityHandler) SubsequentAddressFamilyRegistry(org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry) MultiprotocolCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapability) AddPathCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.AddPathCapability) GracefulRestartCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapability) LlGracefulRestartCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapability) LlGracefulRestartCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapability) BgpExtendedMessageCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.c.parameters.BgpExtendedMessageCapability)

Example 2 with LlGracefulCapabilityHandler

use of org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler 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 3 with LlGracefulCapabilityHandler

use of org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler in project bgpcep by opendaylight.

the class LlGracefulCapabilityHandlerTest method setUp.

@Before
public void setUp() {
    doReturn(Ipv4AddressFamily.class).when(this.afir).classForFamily(1);
    doReturn(Ipv6AddressFamily.class).when(this.afir).classForFamily(2);
    doReturn(null).when(this.afir).classForFamily(256);
    doReturn(UnicastSubsequentAddressFamily.class).when(this.safir).classForFamily(1);
    doReturn(null).when(this.safir).classForFamily(-123);
    final BGPExtensionConsumerContext ctx = ServiceLoader.load(BGPExtensionConsumerContext.class).findFirst().orElseThrow();
    this.handler = new LlGracefulCapabilityHandler(ctx.getAddressFamilyRegistry(), ctx.getSubsequentAddressFamilyRegistry());
}
Also used : LlGracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler) BGPExtensionConsumerContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext) Before(org.junit.Before)

Example 4 with LlGracefulCapabilityHandler

use of org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler 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

LlGracefulCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler)4 LlGracefulRestartCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapability)3 Test (org.junit.Test)2 Uint24 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.Uint24)2 CParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters)2 CParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder)2 CParameters1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder)2 LlGracefulRestartCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapabilityBuilder)2 TablesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.TablesBuilder)2 Ipv4AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily)2 Ipv6AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily)2 Before (org.junit.Before)1 AddPathCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler)1 As4CapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.As4CapabilityHandler)1 BgpExtendedMessageCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.BgpExtendedMessageCapabilityHandler)1 CapabilityParameterParser (org.opendaylight.protocol.bgp.parser.impl.message.open.CapabilityParameterParser)1 GracefulCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.GracefulCapabilityHandler)1 MultiProtocolCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.MultiProtocolCapabilityHandler)1 RouteRefreshCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.RouteRefreshCapabilityHandler)1 AddressFamilyRegistry (org.opendaylight.protocol.bgp.parser.spi.AddressFamilyRegistry)1