use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach in project bgpcep by opendaylight.
the class LinkstateNlriParser method serializeAttribute.
@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
final AttributesReach pathAttributes1 = pathAttributes.augmentation(AttributesReach.class);
final AttributesUnreach pathAttributes2 = pathAttributes.augmentation(AttributesUnreach.class);
if (pathAttributes1 != null) {
serializeAdvertisedRoutes(pathAttributes1.getMpReachNlri().getAdvertizedRoutes(), byteAggregator);
} else if (pathAttributes2 != null) {
serializeWithDrawnRoutes(pathAttributes2.getMpUnreachNlri().getWithdrawnRoutes(), byteAggregator);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach in project bgpcep by opendaylight.
the class Ipv4NlriParser method serializeAttribute.
@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
final AttributesReach pathAttributes1 = pathAttributes.augmentation(AttributesReach.class);
final AttributesUnreach pathAttributes2 = pathAttributes.augmentation(AttributesUnreach.class);
if (pathAttributes1 != null) {
final AdvertizedRoutes advertizedRoutes = pathAttributes1.getMpReachNlri().getAdvertizedRoutes();
if (advertizedRoutes != null && advertizedRoutes.getDestinationType() instanceof DestinationIpv4Case) {
final DestinationIpv4Case destinationIpv4Case = (DestinationIpv4Case) advertizedRoutes.getDestinationType();
for (final Ipv4Prefixes ipv4Prefix : destinationIpv4Case.getDestinationIpv4().getIpv4Prefixes()) {
PathIdUtil.writePathId(ipv4Prefix.getPathId(), byteAggregator);
Ipv4Util.writeMinimalPrefix(ipv4Prefix.getPrefix(), byteAggregator);
}
}
} else if (pathAttributes2 != null) {
final WithdrawnRoutes withdrawnRoutes = pathAttributes2.getMpUnreachNlri().getWithdrawnRoutes();
if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case destinationIpv4Case = (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case) withdrawnRoutes.getDestinationType();
for (final Ipv4Prefixes ipv4Prefix : destinationIpv4Case.getDestinationIpv4().getIpv4Prefixes()) {
PathIdUtil.writePathId(ipv4Prefix.getPathId(), byteAggregator);
Ipv4Util.writeMinimalPrefix(ipv4Prefix.getPrefix(), byteAggregator);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach in project bgpcep by opendaylight.
the class BGPUpdateMessageParser method withdrawAttributes.
private Attributes withdrawAttributes(final Attributes parsed, final BGPTreatAsWithdrawException withdrawCause) throws BGPDocumentedException {
final AttributesBuilder builder = new AttributesBuilder();
final MpReachNlri mpReachNlri = getMpReach(parsed);
if (mpReachNlri == null) {
// No MP_REACH attribute, just reuse MP_UNREACH if it is present.
final AttributesUnreach attrs2 = parsed.augmentation(AttributesUnreach.class);
if (attrs2 != null) {
builder.addAugmentation(attrs2);
}
return builder.build();
}
final MpUnreachNlri unreachNlri = getMpUnreach(parsed);
if (unreachNlri != null) {
final TablesKey reachKey = new TablesKey(mpReachNlri.getAfi(), mpReachNlri.getSafi());
final TablesKey unreachKey = new TablesKey(unreachNlri.getAfi(), unreachNlri.getSafi());
if (!reachKey.equals(unreachKey)) {
LOG.warn("Unexpected mismatch between MP_REACH ({}) and MP_UNREACH ({})", reachKey, unreachKey, withdrawCause);
throw new BGPDocumentedException(withdrawCause);
}
}
final MpUnreachNlri converted = this.nlriReg.convertMpReachToMpUnReach(mpReachNlri, unreachNlri).orElseThrow(() -> {
LOG.warn("Could not convert attributes {} to withdraw attributes", parsed, withdrawCause);
return new BGPDocumentedException(withdrawCause);
});
builder.addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(converted).build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach in project bgpcep by opendaylight.
the class MvpnIpv6NlriHandler method serializeAttribute.
@Override
public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) {
final AttributesReach pathAttributes1 = pathAttributes.augmentation(AttributesReach.class);
final AttributesUnreach pathAttributes2 = pathAttributes.augmentation(AttributesUnreach.class);
if (pathAttributes1 != null) {
final AdvertizedRoutes routes = pathAttributes1.getMpReachNlri().getAdvertizedRoutes();
if (routes != null && routes.getDestinationType() instanceof DestinationMvpnIpv6AdvertizedCase) {
final DestinationMvpnIpv6AdvertizedCase reach = (DestinationMvpnIpv6AdvertizedCase) routes.getDestinationType();
Ipv6NlriHandler.serializeNlri(reach.getDestinationMvpn().getMvpnDestination(), byteAggregator);
}
} else if (pathAttributes2 != null) {
final WithdrawnRoutes withdrawnRoutes = pathAttributes2.getMpUnreachNlri().getWithdrawnRoutes();
if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof DestinationMvpnIpv6WithdrawnCase) {
final DestinationMvpnIpv6WithdrawnCase reach = (DestinationMvpnIpv6WithdrawnCase) withdrawnRoutes.getDestinationType();
Ipv6NlriHandler.serializeNlri(reach.getDestinationMvpn().getMvpnDestination(), byteAggregator);
}
}
}
Aggregations