Search in sources :

Example 1 with RouteTargetConstrainDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination in project bgpcep by opendaylight.

the class RouteTargetConstrainNlriHandler method parseNlriDestinations.

private static List<RouteTargetConstrainDestination> parseNlriDestinations(final ByteBuf nlri, final boolean addPathSupported) {
    final List<RouteTargetConstrainDestination> dests = new ArrayList<>();
    while (nlri.isReadable()) {
        final RouteTargetConstrainDestinationBuilder builder = new RouteTargetConstrainDestinationBuilder();
        if (addPathSupported) {
            builder.setPathId(PathIdUtil.readPathId(nlri));
        }
        final int length = nlri.readUnsignedByte() / 8;
        final ByteBuf nlriBuf = nlri.readSlice(length);
        Integer type = null;
        if (length != 0) {
            builder.setOriginAs(new AsNumber(ByteBufUtils.readUint32(nlriBuf)));
            type = (int) nlriBuf.readUnsignedByte();
            // Skip Subtype
            nlriBuf.skipBytes(1);
        }
        builder.setRouteTargetConstrainChoice(ImmutableRouteTargetConstrainNlriRegistry.getInstance().parseRouteTargetConstrain(type, nlriBuf));
        dests.add(builder.build());
    }
    return dests;
}
Also used : RouteTargetConstrainDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestinationBuilder) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) RouteTargetConstrainDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) PeerSpecificParserConstraint(org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)

Example 2 with RouteTargetConstrainDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination in project bgpcep by opendaylight.

the class RouteTargetConstrainNlriHandler method serializeNlriDestinations.

public static ByteBuf serializeNlriDestinations(final List<RouteTargetConstrainDestination> destinationList) {
    final ByteBuf nlri = Unpooled.buffer();
    for (final RouteTargetConstrainDestination dest : destinationList) {
        final RouteTargetConstrainChoice rtcChoice = dest.getRouteTargetConstrainChoice();
        if (rtcChoice instanceof RouteTargetConstrainDefaultCase) {
            nlri.writeByte(0);
        } else {
            nlri.writeByte(RT_BITS_LENGTH);
            final AsNumber originAs = dest.getOriginAs();
            if (originAs != null) {
                ByteBufUtils.write(nlri, originAs.getValue());
            }
            nlri.writeBytes(ImmutableRouteTargetConstrainNlriRegistry.getInstance().serializeRouteTargetConstrain(rtcChoice));
        }
    }
    return nlri;
}
Also used : RouteTargetConstrainDefaultCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.route.target.constrain.choice.RouteTargetConstrainDefaultCase) ByteBuf(io.netty.buffer.ByteBuf) RouteTargetConstrainDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) RouteTargetConstrainChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.RouteTargetConstrainChoice)

Example 3 with RouteTargetConstrainDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination in project bgpcep by opendaylight.

the class RouteTargetConstrainRIBSupport method extractDestination.

private RouteTargetConstrainDestination extractDestination(final DataContainerNode rtDest) {
    final RouteTargetConstrainDestinationBuilder builder = new RouteTargetConstrainDestinationBuilder().setPathId(PathIdUtil.buildPathId(rtDest, routePathIdNid())).setRouteTargetConstrainChoice(extractRouteTargetChoice(rtDest));
    final Optional<Object> originAs = NormalizedNodes.findNode(rtDest, this.originAsNid).map(NormalizedNode::body);
    originAs.ifPresent(o -> builder.setOriginAs(new AsNumber((Uint32) o)));
    return builder.build();
}
Also used : RouteTargetConstrainDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestinationBuilder) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) BindingObject(org.opendaylight.yangtools.yang.binding.BindingObject) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)

Example 4 with RouteTargetConstrainDestination

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination in project bgpcep by opendaylight.

the class RouteTargetConstrainRIBSupport method createRouteKey.

private NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode routeTarget) {
    final ByteBuf buffer = Unpooled.buffer();
    final RouteTargetConstrainDestination dest = extractDestination(routeTarget);
    buffer.writeBytes(ImmutableRouteTargetConstrainNlriRegistry.getInstance().serializeRouteTargetConstrain(dest.getRouteTargetConstrainChoice()));
    return PathIdUtil.createNidKey(routeQName(), routeKeyTemplate(), ByteArray.encodeBase64(buffer), routeTarget.findChildByArg(routePathIdNid()));
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) RouteTargetConstrainDestination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)3 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)3 RouteTargetConstrainDestination (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination)3 RouteTargetConstrainDestinationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestinationBuilder)2 ArrayList (java.util.ArrayList)1 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)1 RouteTargetConstrainChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.RouteTargetConstrainChoice)1 RouteTargetConstrainDefaultCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.route.target.constrain.choice.RouteTargetConstrainDefaultCase)1 BindingObject (org.opendaylight.yangtools.yang.binding.BindingObject)1 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)1 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)1