Search in sources :

Example 11 with RequestId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId in project bgpcep by opendaylight.

the class PCEPRequestParameterObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof Rp, "Wrong instance of PCEPObject. Passed %s. Needed RPObject.", object.getClass());
    final ByteBuf body = Unpooled.buffer();
    final Rp rpObj = (Rp) object;
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(R_FLAG_OFFSET, rpObj.isReoptimization());
    flags.set(B_FLAG_OFFSET, rpObj.isBiDirectional());
    flags.set(O_FLAG_OFFSET, rpObj.isLoose());
    flags.set(M_FLAG_OFFSET, rpObj.isMakeBeforeBreak());
    flags.set(D_FLAG_OFFSET, rpObj.isOrder());
    flags.set(P_FLAG_OFFSET, rpObj.isPathKey());
    flags.set(S_FLAG_OFFSET, rpObj.isSupplyOf());
    flags.set(F_FLAG_OFFSET, rpObj.isFragmentation());
    flags.set(N_FLAG_OFFSET, rpObj.isP2mp());
    flags.set(E_FLAG_OFFSET, rpObj.isEroCompression());
    final byte[] res = flags.array();
    if (rpObj.getPriority() != null) {
        final byte p = UnsignedBytes.checkedCast(rpObj.getPriority());
        res[res.length - 1] = (byte) (res[res.length - 1] | p);
    }
    body.writeBytes(res);
    Preconditions.checkArgument(rpObj.getRequestId() != null, "RequestId is mandatory");
    writeUnsignedInt(rpObj.getRequestId().getValue(), body);
    serializeTlvs(rpObj.getTlvs(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp)

Example 12 with RequestId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId in project bgpcep by opendaylight.

the class PCEPSvecObjectParser method parseObject.

@Override
public Svec 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.");
    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 = Lists.newArrayList();
    while (bytes.isReadable()) {
        requestIDs.add(new RequestId(bytes.readUnsignedInt()));
    }
    if (requestIDs.isEmpty()) {
        throw new PCEPDeserializerException("Empty Svec Object - no request ids.");
    }
    final SvecBuilder builder = new SvecBuilder();
    builder.setIgnore(header.isIgnore());
    builder.setProcessingRule(header.isProcessingRule());
    builder.setLinkDiverse(flags.get(L_FLAG_OFFSET));
    builder.setNodeDiverse(flags.get(N_FLAG_OFFSET));
    builder.setSrlgDiverse(flags.get(S_FLAG_OFFSET));
    builder.setRequestsIds(requestIDs);
    return builder.build();
}
Also used : RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId) SvecBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.svec.object.SvecBuilder) BitArray(org.opendaylight.protocol.util.BitArray) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Aggregations

RequestId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId)10 ByteBuf (io.netty.buffer.ByteBuf)9 Test (org.junit.Test)6 RpBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder)5 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)4 BitArray (org.opendaylight.protocol.util.BitArray)4 SvecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.svec.object.SvecBuilder)3 Collections (java.util.Collections)2 PCEPRequestParameterObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser)2 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion)2 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.iro.Subobject)2 ReqMissing (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissing)2 ReqMissingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissingBuilder)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 Stateful07ErrorMessageParser (org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07ErrorMessageParser)1 StatefulActivator (org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator)1 TestEnterpriseSpecificInformation (org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation)1 BaseParserExtensionActivator (org.opendaylight.protocol.pcep.parser.BaseParserExtensionActivator)1 PCEPErrorObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPErrorObjectParser)1