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));
}
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)));
}
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());
}
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)));
}
Aggregations