use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder in project bgpcep by opendaylight.
the class PrefixesBuilder method createAttributes.
private static Attributes createAttributes(final List<String> extCom, final boolean multiPathSupport, final Ipv4Prefix addressPrefix) {
final AttributesBuilder attBuilder = new AttributesBuilder();
attBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Egp).build());
attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed((long) 0).build());
attBuilder.setLocalPref(new LocalPrefBuilder().setPref(100L).build());
attBuilder.setExtendedCommunities(createExtComm(extCom));
attBuilder.setUnrecognizedAttributes(Collections.emptyList());
final Ipv4PrefixesBuilder prefixes = new Ipv4PrefixesBuilder().setPrefix(addressPrefix);
if (multiPathSupport) {
prefixes.setPathId(new PathId(5L));
}
attBuilder.addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(new MpReachNlriBuilder().setCNextHop(NEXT_HOP).setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(Collections.singletonList(prefixes.build())).build()).build()).build()).build()).build());
return attBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder in project bgpcep by opendaylight.
the class Ipv4NlriParserTest method parseReachNlriMultiPathTest.
@Test
public void parseReachNlriMultiPathTest() {
final MpReachNlri mpReachNlri = new MpReachNlriBuilder().setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(PREFIXES).build()).build()).build()).build();
final MpReachNlriBuilder mpReachNlriBuilder = new MpReachNlriBuilder();
mpReachNlriBuilder.setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class);
this.parser.parseNlri(Unpooled.wrappedBuffer(MP_NLRI_BYTES), mpReachNlriBuilder, this.constraint);
mpReachNlriBuilder.setAfi(null).setSafi(null);
Assert.assertEquals(mpReachNlri, mpReachNlriBuilder.build());
final Ipv4NlriParser serializer = new Ipv4NlriParser();
final ByteBuf output = Unpooled.buffer(MP_NLRI_BYTES.length);
final Attributes attributes = new AttributesBuilder().addAugmentation(new AttributesReachBuilder().setMpReachNlri(mpReachNlri).build()).build();
serializer.serializeAttribute(attributes, output);
Assert.assertArrayEquals(MP_NLRI_BYTES, output.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder in project bgpcep by opendaylight.
the class Ipv4NlriParserTest method setUp.
@Before
public void setUp() {
final Ipv4Prefix prefix1 = new Ipv4Prefix(this.ipPrefix1);
final Ipv4Prefix prefix2 = new Ipv4Prefix(this.ipPrefix2);
final Ipv4Prefix wrongPrefix = new Ipv4Prefix(this.additionalIpWD);
this.prefixes.add(new Ipv4PrefixesBuilder().setPrefix(prefix1).build());
this.prefixes.add(new Ipv4PrefixesBuilder().setPrefix(prefix2).build());
this.ip4caseWD = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(this.prefixes).build()).build();
this.ip4caseAD = new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(this.prefixes).build()).build();
final ArrayList<Ipv4Prefixes> fakePrefixes = new ArrayList<>(this.prefixes);
fakePrefixes.add(new Ipv4PrefixesBuilder().setPrefix(wrongPrefix).build());
this.ip4caseWDWrong = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(fakePrefixes).build()).build();
this.ip4caseADWrong = new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(fakePrefixes).build()).build();
final ByteBuf buffer1 = Unpooled.buffer(5);
Ipv4Util.writeMinimalPrefix(prefix1, buffer1);
this.inputBytes.writeBytes(buffer1.array());
final ByteBuf buffer2 = Unpooled.buffer(5);
Ipv4Util.writeMinimalPrefix(prefix2, buffer2);
this.inputBytes.writeBytes(buffer2.array());
Mockito.doReturn(Optional.of(this.muliPathSupport)).when(this.constraint).getPeerConstraint(Mockito.any());
Mockito.doReturn(true).when(this.muliPathSupport).isTableTypeSupported(Mockito.any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder in project bgpcep by opendaylight.
the class LinkstateAttributeParserTest method testGetNlriType.
@Test
public void testGetNlriType() throws BGPParsingException, BGPDocumentedException {
final ByteBuf b = Unpooled.buffer();
AttributesBuilder builder = new AttributesBuilder();
this.parser.parseAttribute(b, builder, null);
assertEquals(0, b.readableBytes());
builder = new AttributesBuilder();
final AttributesReachBuilder builder1 = new AttributesReachBuilder();
builder.addAugmentation(builder1.build());
this.parser.parseAttribute(b, builder, null);
assertEquals(0, b.readableBytes());
builder = new AttributesBuilder();
builder.addAugmentation(builder1.setMpReachNlri(new MpReachNlriBuilder().setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().build()).build()).build()).build());
this.parser.parseAttribute(b, builder, null);
assertEquals(0, b.readableBytes());
builder = new AttributesBuilder();
final AttributesUnreachBuilder builder2 = new AttributesUnreachBuilder();
builder.addAugmentation(builder2.build());
this.parser.parseAttribute(b, builder, null);
assertEquals(0, b.readableBytes());
builder = new AttributesBuilder();
builder.addAugmentation(builder2.setMpUnreachNlri(new MpUnreachNlriBuilder().setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6CaseBuilder().build()).build()).build()).build());
this.parser.parseAttribute(b, builder, null);
assertEquals(0, b.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4CaseBuilder in project bgpcep by opendaylight.
the class BmpRibInWriter method prefixesToMpReach.
/**
* Creates MPReach for the prefixes to be handled in the same way as linkstate routes.
*
* @param message Update message containing prefixes in NLRI
* @return MpReachNlri with prefixes from the nlri field
*/
private static MpReachNlri prefixesToMpReach(final UpdateMessage message) {
final List<Ipv4Prefixes> prefixes = message.getNlri().stream().map(n -> new Ipv4PrefixesBuilder().setPrefix(n.getPrefix()).setPathId(n.getPathId()).build()).collect(Collectors.toList());
final MpReachNlriBuilder b = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(prefixes).build()).build()).build());
if (message.getAttributes() != null) {
b.setCNextHop(message.getAttributes().getCNextHop());
}
return b.build();
}
Aggregations