Search in sources :

Example 1 with GracefulCapabilityHandler

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

the class BGPActivator method registerCapabilityParsers.

private static void registerCapabilityParsers(final List<AutoCloseable> 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 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.rev171207.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) 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.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapability) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.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.rev171207.mp.capabilities.MultiprotocolCapability) AddPathCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.AddPathCapability) GracefulRestartCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.GracefulRestartCapability) BgpExtendedMessageCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.BgpExtendedMessageCapability)

Example 2 with GracefulCapabilityHandler

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

the class GracefulCapabilityHandlerTest method testUnhandledSafi.

@Test(expected = IllegalArgumentException.class)
public void testUnhandledSafi() {
    final GracefulCapabilityHandler handler = new GracefulCapabilityHandler(this.ctx.getAddressFamilyRegistry(), this.ctx.getSubsequentAddressFamilyRegistry());
    final GracefulRestartCapabilityBuilder capaBuilder = new GracefulRestartCapabilityBuilder();
    capaBuilder.setRestartFlags(new RestartFlags(true));
    capaBuilder.setRestartTime(50);
    final TablesBuilder tablesBuilder = new TablesBuilder();
    tablesBuilder.setAfiFlags(new AfiFlags(true));
    tablesBuilder.setAfi(Ipv4AddressFamily.class);
    tablesBuilder.setSafi(SubsequentAddressFamily.class);
    capaBuilder.setTables(Lists.newArrayList(tablesBuilder.build()));
    final ByteBuf buffer = Unpooled.buffer();
    handler.serializeCapability(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setGracefulRestartCapability(capaBuilder.build()).build()).build(), buffer);
}
Also used : RestartFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.GracefulRestartCapability.RestartFlags) CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) AfiFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.Tables.AfiFlags) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1Builder) GracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.GracefulCapabilityHandler) ByteBuf(io.netty.buffer.ByteBuf) GracefulRestartCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.GracefulRestartCapabilityBuilder) TablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.TablesBuilder) Test(org.junit.Test)

Example 3 with GracefulCapabilityHandler

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

the class GracefulCapabilityHandlerTest method testUnhandledAfi.

@Test(expected = IllegalArgumentException.class)
public void testUnhandledAfi() {
    final GracefulCapabilityHandler handler = new GracefulCapabilityHandler(this.ctx.getAddressFamilyRegistry(), this.ctx.getSubsequentAddressFamilyRegistry());
    final GracefulRestartCapabilityBuilder capaBuilder = new GracefulRestartCapabilityBuilder();
    capaBuilder.setRestartFlags(new RestartFlags(true));
    capaBuilder.setRestartTime(50);
    final TablesBuilder tablesBuilder = new TablesBuilder();
    tablesBuilder.setAfiFlags(new AfiFlags(true));
    tablesBuilder.setAfi(AddressFamily.class);
    tablesBuilder.setSafi(UnicastSubsequentAddressFamily.class);
    capaBuilder.setTables(Lists.newArrayList(tablesBuilder.build()));
    final ByteBuf buffer = Unpooled.buffer();
    handler.serializeCapability(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setGracefulRestartCapability(capaBuilder.build()).build()).build(), buffer);
}
Also used : RestartFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.GracefulRestartCapability.RestartFlags) CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) AfiFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.Tables.AfiFlags) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1Builder) GracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.GracefulCapabilityHandler) ByteBuf(io.netty.buffer.ByteBuf) GracefulRestartCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.GracefulRestartCapabilityBuilder) TablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.TablesBuilder) Test(org.junit.Test)

Example 4 with GracefulCapabilityHandler

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

the class GracefulCapabilityHandlerTest method testRestartTimeMaxValue.

@Test(expected = IllegalArgumentException.class)
public void testRestartTimeMaxValue() {
    final GracefulCapabilityHandler handler = new GracefulCapabilityHandler(this.ctx.getAddressFamilyRegistry(), this.ctx.getSubsequentAddressFamilyRegistry());
    final GracefulRestartCapabilityBuilder capaBuilder = new GracefulRestartCapabilityBuilder();
    capaBuilder.setRestartFlags(new RestartFlags(true));
    capaBuilder.setRestartTime(50 * 1000);
    final TablesBuilder tablesBuilder = new TablesBuilder();
    tablesBuilder.setAfiFlags(new AfiFlags(true));
    tablesBuilder.setAfi(Ipv4AddressFamily.class);
    tablesBuilder.setSafi(UnicastSubsequentAddressFamily.class);
    capaBuilder.setTables(Lists.newArrayList(tablesBuilder.build()));
    final ByteBuf buffer = Unpooled.buffer();
    handler.serializeCapability(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setGracefulRestartCapability(capaBuilder.build()).build()).build(), buffer);
}
Also used : RestartFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.GracefulRestartCapability.RestartFlags) CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) AfiFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.Tables.AfiFlags) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1Builder) GracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.GracefulCapabilityHandler) ByteBuf(io.netty.buffer.ByteBuf) GracefulRestartCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.GracefulRestartCapabilityBuilder) TablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.TablesBuilder) Test(org.junit.Test)

Example 5 with GracefulCapabilityHandler

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

the class GracefulCapabilityHandlerTest method testRestartTimeMinValue.

@Test(expected = IllegalArgumentException.class)
public void testRestartTimeMinValue() {
    final GracefulCapabilityHandler handler = new GracefulCapabilityHandler(this.ctx.getAddressFamilyRegistry(), this.ctx.getSubsequentAddressFamilyRegistry());
    final GracefulRestartCapabilityBuilder capaBuilder = new GracefulRestartCapabilityBuilder();
    capaBuilder.setRestartFlags(new RestartFlags(true));
    capaBuilder.setRestartTime(-1);
    final TablesBuilder tablesBuilder = new TablesBuilder();
    tablesBuilder.setAfiFlags(new AfiFlags(true));
    tablesBuilder.setAfi(Ipv4AddressFamily.class);
    tablesBuilder.setSafi(UnicastSubsequentAddressFamily.class);
    capaBuilder.setTables(Lists.newArrayList(tablesBuilder.build()));
    final ByteBuf buffer = Unpooled.buffer();
    handler.serializeCapability(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setGracefulRestartCapability(capaBuilder.build()).build()).build(), buffer);
}
Also used : RestartFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.GracefulRestartCapability.RestartFlags) CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) AfiFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.Tables.AfiFlags) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1Builder) GracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.GracefulCapabilityHandler) ByteBuf(io.netty.buffer.ByteBuf) GracefulRestartCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.GracefulRestartCapabilityBuilder) TablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.TablesBuilder) Test(org.junit.Test)

Aggregations

GracefulCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.GracefulCapabilityHandler)6 ByteBuf (io.netty.buffer.ByteBuf)5 Test (org.junit.Test)5 CParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParametersBuilder)5 CParameters1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1Builder)5 RestartFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.GracefulRestartCapability.RestartFlags)5 GracefulRestartCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.GracefulRestartCapabilityBuilder)5 AfiFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.Tables.AfiFlags)5 TablesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.TablesBuilder)5 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 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 SubsequentAddressFamilyRegistry (org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry)1 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters)1 As4BytesCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapability)1 BgpExtendedMessageCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.BgpExtendedMessageCapability)1