use of org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler 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));
}
use of org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler in project bgpcep by opendaylight.
the class AddPathCapabilityHandlerTest method testCapabilityHandler.
@Test
public void testCapabilityHandler() throws BGPDocumentedException, BGPParsingException {
final List<AddressFamilies> family = new ArrayList<>();
family.add(new AddressFamiliesBuilder().setAfi(AddPathCapabilityHandlerTest.AFI).setSafi(AddPathCapabilityHandlerTest.SAFI).setSendReceive(SendReceive.forValue(1)).build());
final CParameters capabilityToSerialize = new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(family).build()).build()).build();
final ByteBuf bytes = Unpooled.buffer(6);
final AddPathCapabilityHandler handler = new AddPathCapabilityHandler(this.afiRegistry, this.safiRegistry);
handler.serializeCapability(capabilityToSerialize, bytes);
assertArrayEquals(this.serializedBytes, bytes.array());
final CParameters newCaps = handler.parseCapability(this.parseCorrectBytes);
assertEquals(capabilityToSerialize.hashCode(), newCaps.hashCode());
}
use of org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler in project bgpcep by opendaylight.
the class AddPathCapabilityHandlerTest method testSafiException.
@Test(expected = BGPParsingException.class)
public void testSafiException() throws BGPDocumentedException, BGPParsingException {
final ByteBuf bytes = this.parseWrongBytes.copy();
final AddPathCapabilityHandler handler = new AddPathCapabilityHandler(this.afiRegistry, this.safirException);
handler.parseCapability(bytes);
}
use of org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler in project bgpcep by opendaylight.
the class AddPathCapabilityHandlerTest method testUnhandledSendReceive.
@Test(expected = IllegalArgumentException.class)
public void testUnhandledSendReceive() {
final List<AddressFamilies> family = new ArrayList<>();
family.add(new AddressFamiliesBuilder().setAfi(AddPathCapabilityHandlerTest.AFI).setSafi(AddPathCapabilityHandlerTest.SAFI).setSendReceive(SendReceive.forValue(4)).build());
final CParameters capabilityToSerialize = new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(family).build()).build()).build();
final ByteBuf bytes = Unpooled.buffer();
final AddPathCapabilityHandler handler = new AddPathCapabilityHandler(this.afiRegistry, this.safiRegistry);
handler.serializeCapability(capabilityToSerialize, bytes);
}
use of org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler in project bgpcep by opendaylight.
the class AddPathCapabilityHandlerTest method testAfiException.
@Test(expected = BGPParsingException.class)
public void testAfiException() throws BGPDocumentedException, BGPParsingException {
final ByteBuf bytes = this.parseWrongBytes.copy();
final AddPathCapabilityHandler handler = new AddPathCapabilityHandler(this.afirExpection, this.safiRegistry);
handler.parseCapability(bytes);
}
Aggregations