Search in sources :

Example 1 with NoPath

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPath in project bgpcep by opendaylight.

the class PCEPReplyMessageParser method getValidReply.

protected Replies getValidReply(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
    Object object = objects.remove(0);
    if (!(object instanceof Rp)) {
        errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.absent()));
        return null;
    }
    final Rp rp = (Rp) object;
    final RepliesBuilder repliesBuilder = new RepliesBuilder();
    if (!objects.isEmpty() && objects.get(0) instanceof Monitoring) {
        repliesBuilder.setMonitoring((Monitoring) objects.get(0));
        objects.remove(0);
    }
    if (!objects.isEmpty() && objects.get(0) instanceof PccIdReq) {
        repliesBuilder.setPccIdReq((PccIdReq) objects.get(0));
        objects.remove(0);
    }
    final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
    Result res = null;
    if (!objects.isEmpty()) {
        if (objects.get(0) instanceof NoPath) {
            res = handleNoPath((NoPath) objects.get(0), objects);
        } else if (objects.get(0) instanceof Ero) {
            res = handleEro((Ero) objects.get(0), objects);
        }
    }
    final List<MetricPce> metricPceList = new ArrayList<>();
    if (!objects.isEmpty() && objects.get(0) instanceof PceId) {
        while (!objects.isEmpty()) {
            metricPceList.add(Util.validateMonitoringMetrics(objects));
        }
    }
    if (!vendorInfo.isEmpty()) {
        repliesBuilder.setVendorInformationObject(vendorInfo);
    }
    if (!metricPceList.isEmpty()) {
        repliesBuilder.setMetricPce(metricPceList);
    }
    return repliesBuilder.setRp(rp).setResult(res).build();
}
Also used : RepliesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.RepliesBuilder) Ero(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero) ArrayList(java.util.ArrayList) Result(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId) PccIdReq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) NoPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPath) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp) Monitoring(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring) MetricPce(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPce)

Example 2 with NoPath

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPath in project bgpcep by opendaylight.

the class PCEPNoPathObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof NoPath, "Wrong instance of PCEPObject. Passed %s. Needed NoPathObject.", object.getClass());
    final NoPath nPObj = (NoPath) object;
    final ByteBuf body = Unpooled.buffer();
    Preconditions.checkArgument(nPObj.getNatureOfIssue() != null, "NatureOfIssue is mandatory.");
    writeUnsignedByte(nPObj.getNatureOfIssue(), body);
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(C_FLAG_OFFSET, nPObj.isUnsatisfiedConstraints());
    flags.toByteBuf(body);
    body.writeZero(RESERVED_F_LENGTH);
    serializeTlvs(nPObj.getTlvs(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : NoPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPath) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 3 with NoPath

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPath in project bgpcep by opendaylight.

the class PCEPNoPathObjectParser method parseObject.

@Override
public NoPath parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final NoPathBuilder builder = new NoPathBuilder();
    builder.setIgnore(header.isIgnore());
    builder.setProcessingRule(header.isProcessingRule());
    builder.setNatureOfIssue(bytes.readUnsignedByte());
    final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
    builder.setUnsatisfiedConstraints(flags.get(C_FLAG_OFFSET));
    bytes.skipBytes(RESERVED_F_LENGTH);
    final TlvsBuilder tlvsBuilder = new TlvsBuilder();
    parseTlvs(tlvsBuilder, bytes.slice());
    builder.setTlvs(tlvsBuilder.build());
    return builder.build();
}
Also used : NoPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPathBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder) BitArray(org.opendaylight.protocol.util.BitArray)

Example 4 with NoPath

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPath in project bgpcep by opendaylight.

the class NoPathVectorTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof NoPathVector, "NoPathVectorTlv is mandatory.");
    final NoPathVector noPath = (NoPathVector) tlv;
    final ByteBuf body = Unpooled.buffer();
    final BitArray flags = new BitArray(FLAGS_SIZE);
    final Flags f = noPath.getFlags();
    flags.set(REACHABLITY_PROBLEM, f.isP2mpUnreachable());
    flags.set(NO_GCO_SOLUTION, f.isNoGcoSolution());
    flags.set(NO_GCO_MIGRATION_PATH, f.isNoGcoMigration());
    flags.set(PATH_KEY, f.isPathKey());
    flags.set(CHAIN_UNAVAILABLE, f.isChainUnavailable());
    flags.set(UNKNOWN_SRC, f.isUnknownSource());
    flags.set(UNKNOWN_DEST, f.isUnknownDestination());
    flags.set(PCE_UNAVAILABLE, f.isPceUnavailable());
    flags.toByteBuf(body);
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : NoPathVector(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVector) BitArray(org.opendaylight.protocol.util.BitArray) Flags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv.Flags) ByteBuf(io.netty.buffer.ByteBuf)

Example 5 with NoPath

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPath in project bgpcep by opendaylight.

the class PCEPReplyMessageParser method handleNoPath.

private Result handleNoPath(final NoPath noPath, final List<Object> objects) {
    objects.remove(0);
    final FailureCaseBuilder builder = new FailureCaseBuilder();
    builder.setNoPath(noPath);
    while (!objects.isEmpty() && !(objects.get(0) instanceof PceId)) {
        this.parseAttributes(builder, objects);
    }
    return builder.build();
}
Also used : FailureCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.FailureCaseBuilder) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId)

Aggregations

BitArray (org.opendaylight.protocol.util.BitArray)3 ByteBuf (io.netty.buffer.ByteBuf)2 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pce.id.object.PceId)2 NoPath (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPath)2 ArrayList (java.util.ArrayList)1 Flags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv.Flags)1 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)1 Ero (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero)1 MetricPce (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.metrics.MetricPce)1 Monitoring (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.Monitoring)1 PccIdReq (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq)1 RepliesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.RepliesBuilder)1 Result (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result)1 FailureCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.FailureCaseBuilder)1 NoPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPathBuilder)1 TlvsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder)1 NoPathVector (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVector)1 Rp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp)1 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject)1