use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class BGPPeer method nextHopToAttribute.
private static Attributes nextHopToAttribute(final Attributes attrs, final MpReachNlri mpReach) {
if (attrs.getCNextHop() == null && mpReach.getCNextHop() != null) {
final AttributesBuilder attributesBuilder = new AttributesBuilder(attrs);
attributesBuilder.setCNextHop(mpReach.getCNextHop());
return attributesBuilder.build();
}
return attrs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class CodecsImpl method serializeAttributes.
@Override
public ContainerNode serializeAttributes(final Attributes pathAttr) {
Preconditions.checkState(this.attributesCodec != null, "Attributes codec not available");
final AttributesBuilder a = new AttributesBuilder(pathAttr);
a.removeAugmentation(AttributesReach.class);
a.removeAugmentation(AttributesUnreach.class);
return (ContainerNode) this.attributesCodec.serialize(a.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class AbstractAddPathTest method createSimpleUpdate.
private static Update createSimpleUpdate(final Ipv4Prefix prefix, final PathId pathId, final ClusterIdentifier clusterId, final long localPreference) {
final AttributesBuilder attBuilder = new AttributesBuilder();
attBuilder.setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(localPreference)).build());
attBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build());
attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(Uint32.ZERO).build());
if (clusterId != null) {
attBuilder.setClusterId(new ClusterIdBuilder().setCluster(Collections.singletonList(clusterId)).build());
attBuilder.setOriginatorId(new OriginatorIdBuilder().setOriginator(new Ipv4AddressNoZone(clusterId)).build());
}
addAttributeAugmentation(attBuilder, prefix, pathId);
return new UpdateBuilder().setAttributes(attBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class AbstractAddPathTest method createSimpleWithdrawalUpdate.
private static Update createSimpleWithdrawalUpdate(final Ipv4Prefix prefix, final long localPreference) {
final AttributesBuilder attBuilder = new AttributesBuilder();
attBuilder.setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(localPreference)).build());
attBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build());
attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
attBuilder.setUnrecognizedAttributes(Collections.emptyMap());
return new UpdateBuilder().setWithdrawnRoutes(Collections.singletonList(new WithdrawnRoutesBuilder().setPrefix(prefix).build())).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class AbstractRIBSupport method buildUpdate.
@Override
public final Update buildUpdate(final Collection<MapEntryNode> advertised, final Collection<MapEntryNode> withdrawn, final Attributes attr) {
final UpdateBuilder ub = new UpdateBuilder();
final AttributesBuilder ab = new AttributesBuilder(attr);
final CNextHop hop = ab.getCNextHop();
LOG.debug("cnextHop before={}", hop);
// do not preserve next hop in attributes if we are using MpReach
ab.setCNextHop(null);
if (!advertised.isEmpty()) {
final MpReachNlri mb = buildReach(advertised, hop);
ab.addAugmentation(new AttributesReachBuilder().setMpReachNlri(mb).build());
LOG.debug("mpreach nexthop={}", mb);
}
if (!withdrawn.isEmpty()) {
final MpUnreachNlri mb = buildUnreach(withdrawn);
ab.addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mb).build());
LOG.debug("mpunrach mb={}", mb);
}
ub.setAttributes(ab.build());
LOG.debug("update {}", ub.build());
return ub.build();
}
Aggregations