use of org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser in project bgpcep by opendaylight.
the class LinkstateNlriParserTest method setUp.
private void setUp(final byte[] data) throws BGPParsingException {
final LinkstateNlriParser parser = new LinkstateNlriParser();
final MpReachNlriBuilder builder = new MpReachNlriBuilder();
this.registry = SimpleNlriTypeRegistry.getInstance();
final BGPActivator act = new BGPActivator(true, ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance().getRsvpRegistry());
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
parser.parseNlri(Unpooled.copiedBuffer(data), builder);
final DestinationLinkstate ls = ((DestinationLinkstateCase) builder.getAdvertizedRoutes().getDestinationType()).getDestinationLinkstate();
assertEquals(1, ls.getCLinkstateDestination().size());
this.dest = ls.getCLinkstateDestination().get(0);
}
use of org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser in project bgpcep by opendaylight.
the class LinkstateNlriParserTest method testSerializeAttribute.
@Test
public void testSerializeAttribute() throws BGPParsingException {
final LinkstateNlriParser parser = new LinkstateNlriParser();
setUp(this.prefixNlri);
final List<CLinkstateDestination> dests = Lists.newArrayList(this.dest);
final DestinationLinkstateCase dlc = new DestinationLinkstateCaseBuilder().setDestinationLinkstate(new DestinationLinkstateBuilder().setCLinkstateDestination(dests).build()).build();
final AdvertizedRoutes aroutes = new AdvertizedRoutesBuilder().setDestinationType(dlc).build();
final Attributes1 reach = new Attributes1Builder().setMpReachNlri(new MpReachNlriBuilder().setAdvertizedRoutes(aroutes).build()).build();
Attributes pa = new AttributesBuilder().addAugmentation(Attributes1.class, reach).build();
ByteBuf result = Unpooled.buffer();
parser.serializeAttribute(pa, result);
assertArrayEquals(this.prefixNlri, ByteArray.getAllBytes(result));
setUp(this.nodeNlri);
final List<CLinkstateDestination> destsU = Lists.newArrayList(this.dest);
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase dlcU = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCaseBuilder().setDestinationLinkstate(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.linkstate._case.DestinationLinkstateBuilder().setCLinkstateDestination(destsU).build()).build();
final WithdrawnRoutes wroutes = new WithdrawnRoutesBuilder().setDestinationType(dlcU).build();
final Attributes2 unreach = new Attributes2Builder().setMpUnreachNlri(new MpUnreachNlriBuilder().setWithdrawnRoutes(wroutes).build()).build();
pa = new AttributesBuilder().addAugmentation(Attributes2.class, unreach).build();
result = Unpooled.buffer();
parser.serializeAttribute(pa, result);
assertArrayEquals(this.nodeNlri, ByteArray.getAllBytes(result));
}
use of org.opendaylight.protocol.bgp.linkstate.impl.nlri.LinkstateNlriParser in project bgpcep by opendaylight.
the class BGPActivator method startImpl.
@Override
protected List<AutoCloseable> startImpl(final BGPExtensionProviderContext context) {
final List<AutoCloseable> regs = new ArrayList<>();
final SimpleNlriTypeRegistry nlriTypeReg = SimpleNlriTypeRegistry.getInstance();
regs.add(context.registerAddressFamily(LinkstateAddressFamily.class, LINKSTATE_AFI));
regs.add(context.registerSubsequentAddressFamily(LinkstateSubsequentAddressFamily.class, LINKSTATE_SAFI));
final NextHopParserSerializer linkstateNextHopParser = new NextHopParserSerializer() {
};
final LinkstateNlriParser parser = new LinkstateNlriParser();
regs.add(context.registerNlriParser(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class, parser, linkstateNextHopParser, Ipv4NextHopCase.class, Ipv6NextHopCase.class));
regs.add(context.registerNlriSerializer(LinkstateRoutes.class, parser));
regs.add(context.registerAttributeSerializer(Attributes1.class, new LinkstateAttributeParser(this.ianaLinkstateAttributeType, this.rsvpTeObjectRegistry)));
final LinkstateAttributeParser linkstateAttributeParser = new LinkstateAttributeParser(this.ianaLinkstateAttributeType, this.rsvpTeObjectRegistry);
regs.add(context.registerAttributeParser(linkstateAttributeParser.getType(), linkstateAttributeParser));
registerNlriCodecs(regs, nlriTypeReg);
registerNlriTlvCodecs(regs, nlriTypeReg);
registerBindingSubTlvs(regs);
return regs;
}
Aggregations