Search in sources :

Example 11 with EvpnDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.destination.EvpnDestination in project bgpcep by opendaylight.

the class EvpnNlriParser method parseNlri.

@Override
public void parseNlri(final ByteBuf nlri, final MpUnreachNlriBuilder builder) throws BGPParsingException {
    if (!nlri.isReadable()) {
        return;
    }
    final List<EvpnDestination> dst = parseNlri(nlri);
    builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder().setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.evpn._case.DestinationEvpnBuilder().setEvpnDestination(dst).build()).build()).build());
}
Also used : Preconditions(com.google.common.base.Preconditions) EvpnDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.destination.EvpnDestination) WithdrawnRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder)

Example 12 with EvpnDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.destination.EvpnDestination in project bgpcep by opendaylight.

the class EvpnNlriParser method parseNlri.

@Nullable
private static List<EvpnDestination> parseNlri(final ByteBuf nlri, final PeerSpecificParserConstraint constraints, final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
    if (!nlri.isReadable()) {
        return null;
    }
    final List<EvpnDestination> dests = new ArrayList<>();
    while (nlri.isReadable()) {
        final EvpnDestinationBuilder builder = new EvpnDestinationBuilder();
        if (MultiPathSupportUtil.isTableTypeSupported(constraints, new BgpTableTypeImpl(afi, safi))) {
            builder.setPathId(PathIdUtil.readPathId(nlri));
        }
        final NlriType type = NlriType.forValue(nlri.readUnsignedByte());
        final int length = nlri.readUnsignedByte();
        final ByteBuf nlriBuf = nlri.readSlice(length);
        builder.setRouteDistinguisher(parseRouteDistinguisher(nlriBuf));
        builder.setEvpnChoice(SimpleEvpnNlriRegistry.getInstance().parseEvpn(type, nlriBuf));
        dests.add(builder.build());
    }
    return dests;
}
Also used : ArrayList(java.util.ArrayList) EvpnDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.destination.EvpnDestination) EvpnDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.destination.EvpnDestinationBuilder) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) NlriType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.NlriType) ByteBuf(io.netty.buffer.ByteBuf) PeerSpecificParserConstraint(org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 13 with EvpnDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.destination.EvpnDestination in project bgpcep by opendaylight.

the class EvpnNlriParser method serializeNlri.

public static void serializeNlri(final List<EvpnDestination> destinationList, final ByteBuf output) {
    ByteBuf nlriOutput = null;
    for (final EvpnDestination dest : destinationList) {
        final ByteBuf nlriCommon = Unpooled.buffer();
        serializeRouteDistinquisher(dest.getRouteDistinguisher(), nlriCommon);
        nlriOutput = SimpleEvpnNlriRegistry.getInstance().serializeEvpn(dest.getEvpnChoice(), nlriCommon);
    }
    output.writeBytes(nlriOutput);
}
Also used : EvpnDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.destination.EvpnDestination) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

EvpnDestination (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.destination.EvpnDestination)8 ByteBuf (io.netty.buffer.ByteBuf)4 EvpnDestinationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.destination.EvpnDestinationBuilder)4 EvpnDestination (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.destination.EvpnDestination)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 EvpnRegistry (org.opendaylight.protocol.bgp.evpn.spi.EvpnRegistry)2 EvpnDestinationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.destination.EvpnDestinationBuilder)2 DestinationEvpnCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationEvpnCaseBuilder)2 DestinationEvpnBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.evpn._case.DestinationEvpnBuilder)2 WithdrawnRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.mp.unreach.nlri.WithdrawnRoutesBuilder)2 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)2 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)2 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)2 Preconditions (com.google.common.base.Preconditions)1 Nullable (javax.annotation.Nullable)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)1 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)1 NlriType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.NlriType)1