Search in sources :

Example 31 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.

the class StatefulPCUpdateRequestMessageParser method validatePath.

private static boolean validatePath(final Queue<Object> objects, final List<Message> errors, final UpdatesBuilder builder) {
    final PathBuilder pBuilder = new PathBuilder();
    Object object = objects.remove();
    if (object instanceof Ero) {
        pBuilder.setEro((Ero) object);
    } else {
        errors.add(createErrorMsg(PCEPErrors.ERO_MISSING, Optional.empty()));
        return false;
    }
    parsePath(objects, pBuilder);
    builder.setPath(pBuilder.build());
    return true;
}
Also used : PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.PathBuilder) Ero(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)

Example 32 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.

the class TopologyProviderTest method createSrEroObject.

private static Ero createSrEroObject(final String nai) {
    final SrEroTypeBuilder srEroBuilder = new SrEroTypeBuilder().setCFlag(false).setMFlag(false).setNaiType(NaiType.Ipv4NodeId).setSid(Uint32.valueOf(123456)).setNai(new IpNodeIdBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(nai))).build());
    final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(srEroBuilder.build()).setLoose(false);
    final List<Subobject> subobjects = Lists.newArrayList(subobjBuilder.build());
    return new EroBuilder().setProcessingRule(false).setIgnore(false).setSubobject(subobjects).build();
}
Also used : SrEroTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.pcrpt.pcrpt.message.reports.path.ero.subobject.subobject.type.SrEroTypeBuilder) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) IpNodeIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.subobject.nai.IpNodeIdBuilder) EroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.EroBuilder) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder)

Example 33 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.

the class MessagesUtil method getEro.

public static Ero getEro(final List<PathDescription> pathDescriptions) {
    /* Prepare ERO */
    final EroBuilder eroBuilder = new EroBuilder().setIgnore(false).setProcessingRule(true);
    final List<Subobject> eroSubs = new ArrayList<>();
    /* Fulfill ERO sublist */
    for (PathDescription path : pathDescriptions) {
        Subobject sb = null;
        if (path.getSid() == null) {
            IpPrefix ipPref = null;
            /* Prepare SubObject for IPv4 or IPv6 address */
            if (path.getIpv4() != null) {
                final Ipv4Prefix ipv4Pref = new Ipv4Prefix(path.getIpv4().getValue() + "/32");
                ipPref = new IpPrefixBuilder().setIpPrefix(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix(ipv4Pref)).build();
            }
            if (path.getIpv6() != null) {
                final Ipv6Prefix ipv6Pref = new Ipv6Prefix(path.getIpv6().getValue() + "/128");
                ipPref = new IpPrefixBuilder().setIpPrefix(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix(ipv6Pref)).build();
            }
            if (ipPref != null) {
                final IpPrefixCase ipPrefCase = new IpPrefixCaseBuilder().setIpPrefix(ipPref).build();
                sb = new SubobjectBuilder().setSubobjectType(ipPrefCase).setLoose(false).build();
            }
        } else {
            /* Prepare SubObject for Segment Routing */
            SrEroType srEro = null;
            if (path.getLocalIpv4() != null && path.getRemoteIpv4() != null) {
                srEro = new SrEroTypeBuilder().setNaiType(NaiType.Ipv4Adjacency).setSid(path.getSid()).setCFlag(false).setMFlag(true).setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(path.getLocalIpv4().getValue()))).setRemoteIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(path.getRemoteIpv4().getValue()))).build()).build();
            }
            if (path.getLocalIpv6() != null && path.getRemoteIpv6() != null) {
                srEro = new SrEroTypeBuilder().setNaiType(NaiType.Ipv6Adjacency).setSid(path.getSid()).setCFlag(false).setMFlag(true).setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone(path.getLocalIpv6().getValue()))).setRemoteIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone(path.getRemoteIpv6().getValue()))).build()).build();
            }
            if (srEro != null) {
                sb = new SubobjectBuilder().setSubobjectType(srEro).setLoose(false).build();
            }
        }
        /* Add corresponding SubObject to the ERO List */
        if (sb != null) {
            eroSubs.add(sb);
        }
    }
    /* Set ERO sublist */
    eroBuilder.setSubobject(eroSubs);
    return eroBuilder.build();
}
Also used : Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) ArrayList(java.util.ArrayList) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder) Ipv6AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) IpPrefix(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix) IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase) EroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.EroBuilder) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) IpPrefixBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject) SrEroType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.pcrep.pcrep.message.replies.result.success._case.success.paths.ero.subobject.subobject.type.SrEroType) SrEroTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.pcrep.pcrep.message.replies.result.success._case.success.paths.ero.subobject.subobject.type.SrEroTypeBuilder) PathDescription(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.path.descriptions.PathDescription) IpPrefixCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder) IpAdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.subobject.nai.IpAdjacencyBuilder)

Example 34 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.

the class MessagesUtil method buildPath.

private static PathsBuilder buildPath(final ConstrainedPath cpath) {
    final PathsBuilder pathBuilder = new PathsBuilder();
    /* Get ERO from Path Description */
    pathBuilder.setEro(getEro(cpath.getPathDescription()));
    /* Fulfill Computed Metrics if available */
    final ArrayList<Metrics> metrics = new ArrayList<>();
    if (cpath.getMetric() != null) {
        final MetricBuilder metricBuilder = new MetricBuilder().setComputed(true).setMetricType(Uint8.valueOf(IGP_METRIC)).setValue(new Float32(ByteBuffer.allocate(4).putFloat(cpath.getMetric().floatValue()).array()));
        metrics.add(new MetricsBuilder().setMetric(metricBuilder.build()).build());
    }
    if (cpath.getTeMetric() != null) {
        final MetricBuilder metricBuilder = new MetricBuilder().setComputed(true).setMetricType(Uint8.valueOf(TE_METRIC)).setValue(new Float32(ByteBuffer.allocate(4).putFloat(cpath.getTeMetric().floatValue()).array()));
        metrics.add(new MetricsBuilder().setMetric(metricBuilder.build()).build());
    }
    if (cpath.getDelay() != null) {
        final MetricBuilder metricBuilder = new MetricBuilder().setComputed(true).setMetricType(Uint8.valueOf(PATH_DELAY)).setValue(new Float32(ByteBuffer.allocate(4).putFloat(cpath.getDelay().getValue().floatValue()).array()));
        metrics.add(new MetricsBuilder().setMetric(metricBuilder.build()).build());
    }
    if (!metrics.isEmpty()) {
        pathBuilder.setMetrics(metrics);
    }
    /* Fulfill Bandwidth and ClassType if set */
    if (cpath.getBandwidth() != null) {
        final BandwidthBuilder bwBuilder = new BandwidthBuilder();
        bwBuilder.setBandwidth(new Bandwidth(new Float32(ByteBuffer.allocate(4).putFloat(cpath.getBandwidth().getValue().floatValue()).array())));
        pathBuilder.setBandwidth(bwBuilder.build());
    }
    if (cpath.getClassType() != null && !cpath.getClassType().equals(Uint8.ZERO)) {
        pathBuilder.setClassType(new ClassTypeBuilder().setClassType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ClassType(cpath.getClassType())).build());
    }
    return pathBuilder;
}
Also used : Collections(java.util.Collections) ArrayList(java.util.ArrayList) PathsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.success._case.success.PathsBuilder) BandwidthBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.BandwidthBuilder) MetricsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.MetricsBuilder) Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics) Float32(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth) ClassTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.classtype.object.ClassTypeBuilder) MetricBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.MetricBuilder)

Example 35 with Ero

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.

the class EROSubobjectListParser method parseList.

public List<SubobjectContainer> parseList(final ByteBuf buffer) throws RSVPParsingException {
    // Explicit approval of empty ERO
    Preconditions.checkArgument(buffer != null, "Array of bytes is mandatory. Can't be null.");
    final List<SubobjectContainer> subs = new ArrayList<>();
    while (buffer.isReadable()) {
        final boolean loose = (buffer.getUnsignedByte(buffer.readerIndex()) & (1 << Values.FIRST_BIT_OFFSET)) != 0;
        final int type = (buffer.readUnsignedByte() & Values.BYTE_MAX_VALUE_BYTES) & ~(1 << Values.FIRST_BIT_OFFSET);
        final int length = buffer.readUnsignedByte() - HEADER_LENGTH;
        if (length > buffer.readableBytes()) {
            throw new RSVPParsingException("Wrong length specified. Passed: " + length + "; Expected: <= " + buffer.readableBytes());
        }
        LOG.debug("Attempt to parse subobject from bytes: {}", ByteBufUtil.hexDump(buffer));
        final SubobjectContainer sub = this.subobjReg.parseSubobject(type, buffer.readSlice(length), loose);
        if (sub == null) {
            LOG.warn("Parsing failed for subobject type: {}. Ignoring subobject.", type);
        } else {
            LOG.debug("Subobject was parsed. {}", sub);
            subs.add(sub);
        }
    }
    return subs;
}
Also used : SubobjectContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer) ArrayList(java.util.ArrayList) RSVPParsingException(org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)

Aggregations

ArrayList (java.util.ArrayList)16 Ero (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero)8 ByteBuf (io.netty.buffer.ByteBuf)7 Test (org.junit.Test)7 EroBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.EroBuilder)7 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)5 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject)5 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder)5 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)4 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder)4 ArrayDeque (java.util.ArrayDeque)2 InitiatedActivator (org.opendaylight.protocol.pcep.ietf.initiated.InitiatedActivator)2 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)2 RSVPParsingException (org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)2 BitArray (org.opendaylight.protocol.util.BitArray)2 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)2 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)2 Ipv6AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone)2 SrRange (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.prefix.state.SrRange)2 SrRangeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.prefix.state.SrRangeBuilder)2