Search in sources :

Example 1 with RouteTargetConstrainDestinationBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestinationBuilder 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 RouteTargetConstrainDestinationBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestinationBuilder 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)

Aggregations

AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)2 RouteTargetConstrainDestinationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestinationBuilder)2 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)1 RouteTargetConstrainDestination (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination)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