use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder in project bgpcep by opendaylight.
the class AppendActionTest method testAppend.
@Test
public void testAppend() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("multiple-append-test")).findFirst().get();
final RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
final Attributes expected = new AttributesBuilder().setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build()).setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("4.5.6.7")).build()).build()).setLocalPref(new LocalPrefBuilder().setPref(100L).build()).setMultiExitDisc(new MultiExitDiscBuilder().setMed(15L).build()).build();
assertEquals(expected, result.getAttributes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder in project bgpcep by opendaylight.
the class MultiPathAbstractRIBSupportTest method buildUpdate.
@Test
public void buildUpdate() {
final Ipv4NextHopCase nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("10.0.0.2")).build()).build();
final Attributes attr = new AttributesBuilder().setCNextHop(nextHop).build();
final Collection<MapEntryNode> routes = new HashSet<>();
assertEquals(new UpdateBuilder().setAttributes(new AttributesBuilder().build()).build(), MULTI_PATH_ABSTRACT_TEST.buildUpdate(routes, routes, attr));
routes.add(this.mapEntryNode);
final MpReachNlri mpReach = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setCNextHop(nextHop).setAdvertizedRoutes(new AdvertizedRoutesBuilder().build()).build();
final Attributes attMpR = new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpReach).build()).build();
assertEquals(new UpdateBuilder().setAttributes(attMpR).build(), MULTI_PATH_ABSTRACT_TEST.buildUpdate(routes, Collections.emptySet(), attr));
final MpUnreachNlri mpUnreach = new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().build()).build();
final Attributes attMpU = new AttributesBuilder().addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(mpUnreach).build()).build();
assertEquals(new UpdateBuilder().setAttributes(attMpU).build(), MULTI_PATH_ABSTRACT_TEST.buildUpdate(Collections.emptySet(), routes, attr));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder in project bgpcep by opendaylight.
the class AppPeerBenchmark method addRoute.
private long addRoute(final Ipv4Prefix ipv4Prefix, final Ipv4Address nextHop, final long count, final long batch) {
final AttributesBuilder attributesBuilder = new AttributesBuilder();
attributesBuilder.setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address(nextHop)).build()).build());
attributesBuilder.setMultiExitDisc(MED);
attributesBuilder.setLocalPref(LOC_PREF);
attributesBuilder.setOrigin(ORIGIN);
attributesBuilder.setAsPath(AS_PATH);
final Attributes attributes = attributesBuilder.build();
return processRoutes(ipv4Prefix, count, batch, attributes);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder in project bgpcep by opendaylight.
the class BgpTestActivator method startImpl.
@Override
protected List<AutoCloseable> startImpl(final BGPExtensionProviderContext context) {
initMock();
final List<AutoCloseable> regs = Lists.newArrayList();
regs.add(context.registerAttributeParser(TYPE, this.attrParser));
regs.add(context.registerAttributeSerializer(DataObject.class, this.attrSerializer));
regs.add(context.registerParameterParser(TYPE, this.paramParser));
regs.add(context.registerParameterSerializer(BgpParameters.class, this.paramSerializer));
regs.add(context.registerCapabilityParser(TYPE, this.capaParser));
regs.add(context.registerCapabilitySerializer(CParameters.class, this.capaSerializer));
regs.add(context.registerBgpPrefixSidTlvParser(TYPE, this.sidTlvParser));
regs.add(context.registerBgpPrefixSidTlvSerializer(BgpPrefixSidTlv.class, this.sidTlvSerializer));
regs.add(context.registerMessageParser(TYPE, this.msgParser));
regs.add(context.registerMessageSerializer(Notification.class, this.msgSerializer));
regs.add(context.registerAddressFamily(Ipv4AddressFamily.class, 1));
regs.add(context.registerAddressFamily(Ipv6AddressFamily.class, 2));
regs.add(context.registerSubsequentAddressFamily(UnicastSubsequentAddressFamily.class, 1));
this.nextHopParserSerializer = new NextHopParserSerializer() {
@Override
public CNextHop parseNextHop(final ByteBuf buffer) throws BGPParsingException {
return new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("127.0.0.1")).build()).build();
}
@Override
public void serializeNextHop(final CNextHop cNextHop, final ByteBuf byteAggregator) {
final byte[] mpReachBytes = { 0x7f, 0x00, 0x00, 0x01 };
byteAggregator.writeBytes(mpReachBytes);
}
};
regs.add(context.registerNlriParser(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class, this.nlriParser, this.nextHopParserSerializer, Ipv4NextHopCase.class));
regs.add(context.registerNlriParser(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class, this.nlriParser, this.nextHopParserSerializer, Ipv6NextHopCase.class));
regs.add(context.registerNlriSerializer(DataObject.class, this.nlriSerializer));
regs.add(context.registerExtendedCommunityParser(0, 0, this.exParser));
regs.add(context.registerExtendedCommunitySerializer(RouteTargetIpv4Case.class, this.exSerializer));
return regs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder in project bgpcep by opendaylight.
the class VpnIpv4NextHopTest method testSerializeIpv4NextHopCase.
@Test
public void testSerializeIpv4NextHopCase() throws BGPParsingException {
final ByteBuf buffer = Unpooled.buffer();
final byte[] nextHop = { 0, 0, 0, 0, 0, 0, 0, 0, 42, 42, 42, 42 };
final CNextHop hop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("42.42.42.42")).build()).build();
HANDLER.serializeNextHop(hop, buffer);
assertArrayEquals(nextHop, ByteArray.readAllBytes(buffer));
final CNextHop parsedHop = HANDLER.parseNextHop(Unpooled.wrappedBuffer(nextHop));
assertTrue(hop instanceof Ipv4NextHopCase);
assertEquals(hop, parsedHop);
}
Aggregations