Search in sources :

Example 6 with SvecBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.SvecBuilder in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method getValidSvec.

// Note: objects is expected to be non-empty
private static Svec getValidSvec(final SvecBuilder builder, final Queue<Object> objects) {
    final Object svec = objects.element();
    if (svec instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.Svec) {
        builder.setSvec((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.Svec) svec);
        objects.remove();
    } else {
        return null;
    }
    // FIXME: this list is not retained anywhere
    final List<Metrics> metrics = new ArrayList<>();
    final List<VendorInformationObject> viObjects = new ArrayList<>();
    SvecState state = SvecState.INIT;
    for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
        state = insertP2PObject(state, obj, builder, metrics, viObjects);
        if (state == SvecState.END) {
            break;
        }
        objects.remove();
    }
    if (!viObjects.isEmpty()) {
        builder.setVendorInformationObject(viObjects);
    }
    return builder.build();
}
Also used : Preconditions(com.google.common.base.Preconditions) Svec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Svec) ArrayList(java.util.ArrayList) Metrics(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)

Example 7 with SvecBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.SvecBuilder in project bgpcep by opendaylight.

the class PCEPSvecObjectParser method parseObject.

@Override
public Svec parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    if (bytes.readableBytes() < MIN_SIZE) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: >=" + MIN_SIZE + ".");
    }
    bytes.skipBytes(FLAGS_F_OFFSET);
    final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
    final List<RequestId> requestIDs = new ArrayList<>();
    while (bytes.isReadable()) {
        requestIDs.add(new RequestId(ByteBufUtils.readUint32(bytes)));
    }
    if (requestIDs.isEmpty()) {
        throw new PCEPDeserializerException("Empty Svec Object - no request ids.");
    }
    return new SvecBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setLinkDiverse(flags.get(L_FLAG_OFFSET)).setNodeDiverse(flags.get(N_FLAG_OFFSET)).setSrlgDiverse(flags.get(S_FLAG_OFFSET)).setLinkDirectionDiverse(flags.get(D_FLAG_OFFSET)).setPartialPathDiverse(flags.get(P_FLAG_OFFSET)).setRequestsIds(requestIDs).build();
}
Also used : RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId) ArrayList(java.util.ArrayList) SvecBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.SvecBuilder) BitArray(org.opendaylight.protocol.util.BitArray) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Aggregations

ArrayList (java.util.ArrayList)7 RequestId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId)3 SvecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.SvecBuilder)3 Preconditions (com.google.common.base.Preconditions)2 Svec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Svec)2 Svec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Svec)2 ByteBuf (io.netty.buffer.ByteBuf)1 Collections (java.util.Collections)1 Before (org.junit.Before)1 Test (org.junit.Test)1 TestEnterpriseSpecificInformation (org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation)1 BaseParserExtensionActivator (org.opendaylight.protocol.pcep.parser.BaseParserExtensionActivator)1 PCEPSvecObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPSvecObjectParser)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)1 SimplePCEPExtensionProviderContext (org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext)1 BitArray (org.opendaylight.protocol.util.BitArray)1 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)1 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)1 EnterpriseNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber)1