use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.destination.ipv4.Ipv4PrefixesBuilder 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.rev171207.ipv4.prefixes.destination.ipv4.Ipv4PrefixesBuilder in project bgpcep by opendaylight.
the class Ipv4NlriParserTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
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.rev171207.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.rev171207.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);
ByteBufWriteUtil.writeMinimalPrefix(prefix1, buffer1);
this.inputBytes.writeBytes(buffer1.array());
final ByteBuf buffer2 = Unpooled.buffer(5);
ByteBufWriteUtil.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.rev171207.ipv4.prefixes.destination.ipv4.Ipv4PrefixesBuilder in project bgpcep by opendaylight.
the class Ipv4NlriParser method prefixes.
private static DestinationIpv4 prefixes(final ByteBuf nlri, final PeerSpecificParserConstraint constraints, final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
final List<Ipv4Prefixes> prefixes = new ArrayList<>();
while (nlri.isReadable()) {
final Ipv4PrefixesBuilder prefixesBuilder = new Ipv4PrefixesBuilder();
if (MultiPathSupportUtil.isTableTypeSupported(constraints, new BgpTableTypeImpl(afi, safi))) {
prefixesBuilder.setPathId(PathIdUtil.readPathId(nlri));
}
prefixesBuilder.setPrefix(Ipv4Util.prefixForByteBuf(nlri));
prefixes.add(prefixesBuilder.build());
}
return new DestinationIpv4Builder().setIpv4Prefixes(prefixes).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.destination.ipv4.Ipv4PrefixesBuilder 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.destination.ipv4.Ipv4PrefixesBuilder in project bgpcep by opendaylight.
the class BmpRibInWriter method prefixesToMpUnreach.
/**
* Create MPUnreach for the prefixes to be handled in the same way as linkstate routes.
*
* @param message Update message containing withdrawn routes
* @return MpUnreachNlri with prefixes from the withdrawn routes field
*/
private static MpUnreachNlri prefixesToMpUnreach(final UpdateMessage message) {
final List<Ipv4Prefixes> prefixes = new ArrayList<>();
message.getWithdrawnRoutes().forEach(w -> prefixes.add(new Ipv4PrefixesBuilder().setPrefix(w.getPrefix()).setPathId(w.getPathId()).build()));
return new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder().setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(prefixes).build()).build()).build()).build();
}
Aggregations