Search in sources :

Example 16 with AttributesUnreach

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);
    }
}
Also used : AttributesReach(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReach) AttributesUnreach(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach)

Example 17 with AttributesUnreach

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);
            }
        }
    }
}
Also used : AdvertizedRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutes) WithdrawnRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutes) AttributesReach(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReach) Ipv4Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4Prefixes) AttributesUnreach(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach) DestinationIpv4Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4Case)

Example 18 with AttributesUnreach

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();
}
Also used : AttributesUnreachBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreachBuilder) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey) MpUnreachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri) BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException) AttributesUnreach(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri)

Example 19 with AttributesUnreach

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);
        }
    }
}
Also used : AttributesReach(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReach) AdvertizedRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutes) DestinationMvpnIpv6WithdrawnCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.ipv6.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationMvpnIpv6WithdrawnCase) DestinationMvpnIpv6AdvertizedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.ipv6.rev180417.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationMvpnIpv6AdvertizedCase) AttributesUnreach(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach) WithdrawnRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutes)

Aggregations

AttributesUnreach (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesUnreach)19 AttributesReach (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReach)16 AdvertizedRoutes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.mp.reach.nlri.AdvertizedRoutes)11 WithdrawnRoutes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutes)11 MpUnreachNlri (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri)5 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes)3 Test (org.junit.Test)2 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)2 DestinationType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType)2 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)2 ByteBuf (io.netty.buffer.ByteBuf)1 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)1 NlriSerializer (org.opendaylight.protocol.bgp.parser.spi.NlriSerializer)1 PeerSpecificParserConstraintImpl (org.opendaylight.protocol.bgp.parser.spi.pojo.PeerSpecificParserConstraintImpl)1 DestinationEvpnCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationEvpnCase)1 Ipv4Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.prefixes.destination.ipv4.Ipv4Prefixes)1 Ipv6Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv6.prefixes.destination.ipv6.Ipv6Prefixes)1 DestinationIpv4Case (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4Case)1 DestinationIpv6Case (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv6Case)1 DestinationL3vpnMcastIpv4AdvertizedCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationL3vpnMcastIpv4AdvertizedCase)1