Search in sources :

Example 11 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.Flags in project bgpcep by opendaylight.

the class PCEPProcTimeObjectParser method parseObject.

@Override
public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
    Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final ProcTimeBuilder builder = new ProcTimeBuilder();
    buffer.skipBytes(RESERVED);
    final BitArray flagBits = BitArray.valueOf(buffer, FLAGS);
    builder.setEstimated(flagBits.get(E_FLAG_POSITION));
    builder.setCurrentProcTime(buffer.readUnsignedInt());
    builder.setMinProcTime(buffer.readUnsignedInt());
    builder.setMaxProcTime(buffer.readUnsignedInt());
    builder.setAverageProcTime(buffer.readUnsignedInt());
    builder.setVarianceProcTime(buffer.readUnsignedInt());
    return builder.build();
}
Also used : ProcTimeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.proc.time.object.ProcTimeBuilder) BitArray(org.opendaylight.protocol.util.BitArray)

Example 12 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.Flags in project bgpcep by opendaylight.

the class PCEPProcTimeObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof ProcTime, "Wrong instance of PCEPObject. Passed %s. Needed ProcTimeObject.", object.getClass());
    final ProcTime procTime = (ProcTime) object;
    final ByteBuf body = Unpooled.buffer(BODY_SIZE);
    body.writeZero(RESERVED);
    final BitArray flagBits = new BitArray(FLAGS);
    flagBits.set(E_FLAG_POSITION, procTime.isEstimated());
    flagBits.toByteBuf(body);
    ByteBufWriteUtil.writeUnsignedInt(procTime.getCurrentProcTime(), body);
    ByteBufWriteUtil.writeUnsignedInt(procTime.getMinProcTime(), body);
    ByteBufWriteUtil.writeUnsignedInt(procTime.getMaxProcTime(), body);
    ByteBufWriteUtil.writeUnsignedInt(procTime.getAverageProcTime(), body);
    ByteBufWriteUtil.writeUnsignedInt(procTime.getVarianceProcTime(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : ProcTime(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.proc.time.object.ProcTime) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 13 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.Flags in project bgpcep by opendaylight.

the class PCEPRequestParameterObjectParser method parseObject.

@Override
public Object 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 BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
    final RpBuilder builder = new RpBuilder();
    builder.setIgnore(header.isIgnore());
    builder.setProcessingRule(header.isProcessingRule());
    short priority = 0;
    priority |= flags.get(PRI_SF_OFFSET + 2) ? 1 : 0;
    priority |= (flags.get(PRI_SF_OFFSET + 1) ? 1 : 0) << 1;
    priority |= (flags.get(PRI_SF_OFFSET) ? 1 : 0) << 2;
    if (priority != 0) {
        builder.setPriority(priority);
    }
    builder.setFragmentation(flags.get(F_FLAG_OFFSET));
    builder.setP2mp(flags.get(N_FLAG_OFFSET));
    builder.setEroCompression(flags.get(E_FLAG_OFFSET));
    builder.setMakeBeforeBreak(flags.get(M_FLAG_OFFSET));
    builder.setOrder(flags.get(D_FLAG_OFFSET));
    builder.setPathKey(flags.get(P_FLAG_OFFSET));
    builder.setSupplyOf(flags.get(S_FLAG_OFFSET));
    builder.setLoose(flags.get(O_FLAG_OFFSET));
    builder.setBiDirectional(flags.get(B_FLAG_OFFSET));
    builder.setReoptimization(flags.get(R_FLAG_OFFSET));
    builder.setRequestId(new RequestId(bytes.readUnsignedInt()));
    final TlvsBuilder tlvsBuilder = new TlvsBuilder();
    parseTlvs(tlvsBuilder, bytes.slice());
    builder.setTlvs(tlvsBuilder.build());
    return builder.build();
}
Also used : TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder) RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId) RpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder) BitArray(org.opendaylight.protocol.util.BitArray)

Example 14 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.Flags in project bgpcep by opendaylight.

the class PCEPSvecObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof Svec, "Wrong instance of PCEPObject. Passed %s. Needed SvecObject.", object.getClass());
    final Svec svecObj = (Svec) object;
    final ByteBuf body = Unpooled.buffer();
    body.writeZero(FLAGS_F_OFFSET);
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(L_FLAG_OFFSET, svecObj.isLinkDiverse());
    flags.set(N_FLAG_OFFSET, svecObj.isNodeDiverse());
    flags.set(S_FLAG_OFFSET, svecObj.isSrlgDiverse());
    flags.toByteBuf(body);
    final List<RequestId> requestIDs = svecObj.getRequestsIds();
    assert !(requestIDs.isEmpty()) : "Empty Svec Object - no request ids.";
    for (final RequestId requestId : requestIDs) {
        writeUnsignedInt(requestId.getValue(), body);
    }
    ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
Also used : RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId) Svec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.svec.object.Svec) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 15 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.adj.flags.Flags in project bgpcep by opendaylight.

the class PCEPLspaObjectParser method parseObject.

@Override
public Lspa 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 LspaBuilder builder = new LspaBuilder();
    builder.setIgnore(header.isIgnore());
    builder.setProcessingRule(header.isProcessingRule());
    builder.setExcludeAny(new AttributeFilter(bytes.readUnsignedInt()));
    builder.setIncludeAll(new AttributeFilter(bytes.readUnsignedInt()));
    builder.setIncludeAny(new AttributeFilter(bytes.readUnsignedInt()));
    builder.setSetupPriority(bytes.readUnsignedByte());
    builder.setHoldPriority(bytes.readUnsignedByte());
    final BitArray flags = BitArray.valueOf(bytes.readByte());
    builder.setLocalProtectionDesired(flags.get(L_FLAG_OFFSET));
    final TlvsBuilder tbuilder = new TlvsBuilder();
    bytes.skipBytes(RESERVED);
    parseTlvs(tbuilder, bytes.slice());
    builder.setTlvs(tbuilder.build());
    return builder.build();
}
Also used : LspaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.LspaBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.lspa.TlvsBuilder) AttributeFilter(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter) BitArray(org.opendaylight.protocol.util.BitArray)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)117 Test (org.junit.Test)104 BitArray (org.opendaylight.protocol.util.BitArray)63 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)61 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)40 ArrayList (java.util.ArrayList)25 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)25 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)23 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)20 BigInteger (java.math.BigInteger)15 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)12 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)12 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)10 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)10 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8 BundleFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)8 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)8 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)7 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder)7 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder)7