Search in sources :

Example 91 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring.Flags in project bgpcep by opendaylight.

the class PCEPRequestParameterObjectParser method parseObject.

@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
    final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
    final Uint32 reqId = ByteBufUtils.readUint32(bytes);
    final TlvsBuilder tlvsBuilder = new TlvsBuilder();
    parseTlvs(tlvsBuilder, bytes.slice());
    final RpBuilder builder = new RpBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setFragmentation(flags.get(F_FLAG_OFFSET)).setP2mp(flags.get(N_FLAG_OFFSET)).setEroCompression(flags.get(E_FLAG_OFFSET)).setMakeBeforeBreak(flags.get(M_FLAG_OFFSET)).setOrder(flags.get(D_FLAG_OFFSET)).setPathKey(flags.get(P_FLAG_OFFSET)).setSupplyOf(flags.get(S_FLAG_OFFSET)).setLoose(flags.get(O_FLAG_OFFSET)).setBiDirectional(flags.get(B_FLAG_OFFSET)).setReoptimization(flags.get(R_FLAG_OFFSET)).setRequestId(new RequestId(reqId)).setTlvs(tlvsBuilder.build());
    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(Uint8.valueOf(priority));
    }
    return builder.build();
}
Also used : TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder) RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId) RpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.RpBuilder) BitArray(org.opendaylight.protocol.util.BitArray) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 92 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring.Flags in project bgpcep by opendaylight.

the class PCEPLspaObjectParser method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    checkArgument(object instanceof Lspa, "Wrong instance of PCEPObject. Passed %s. Needed LspaObject.", object.getClass());
    final Lspa lspaObj = (Lspa) object;
    final ByteBuf body = Unpooled.buffer();
    writeAttributeFilter(lspaObj.getExcludeAny(), body);
    writeAttributeFilter(lspaObj.getIncludeAny(), body);
    writeAttributeFilter(lspaObj.getIncludeAll(), body);
    ByteBufUtils.writeOrZero(body, lspaObj.getSetupPriority());
    ByteBufUtils.writeOrZero(body, lspaObj.getHoldPriority());
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(L_FLAG_OFFSET, lspaObj.getLocalProtectionDesired());
    flags.toByteBuf(body);
    body.writeZero(RESERVED);
    serializeTlvs(lspaObj.getTlvs(), body);
    ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray) Lspa(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.Lspa) ByteBuf(io.netty.buffer.ByteBuf)

Example 93 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring.Flags in project bgpcep by opendaylight.

the class PCEPLspaObjectParser method parseObject.

@Override
public Lspa parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
    final LspaBuilder builder = new LspaBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setExcludeAny(new AttributeFilter(ByteBufUtils.readUint32(bytes))).setIncludeAll(new AttributeFilter(ByteBufUtils.readUint32(bytes))).setIncludeAny(new AttributeFilter(ByteBufUtils.readUint32(bytes))).setSetupPriority(ByteBufUtils.readUint8(bytes)).setHoldPriority(ByteBufUtils.readUint8(bytes));
    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());
    return builder.setTlvs(tbuilder.build()).build();
}
Also used : LspaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.LspaBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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)

Example 94 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring.Flags in project bgpcep by opendaylight.

the class PCEPMonitoringObjectParser method parseObject.

@Override
public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
    checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
    buffer.skipBytes(RESERVED);
    final BitArray flagBits = BitArray.valueOf(buffer, FLAGS_SIZE);
    final Flags flags = new Flags(flagBits.get(G_FLAG_POS), flagBits.get(I_FLAG_POS), flagBits.get(L_FLAG_POS), flagBits.get(C_FLAG_POS), flagBits.get(P_FLAG_POS));
    final Uint32 monitoring = ByteBufUtils.readUint32(buffer);
    final TlvsBuilder tbuilder = new TlvsBuilder();
    parseTlvs(tbuilder, buffer.slice());
    return new MonitoringBuilder().setFlags(flags).setMonitoringId(monitoring).setTlvs(tbuilder.build()).build();
}
Also used : TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.monitoring.TlvsBuilder) MonitoringBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.MonitoringBuilder) BitArray(org.opendaylight.protocol.util.BitArray) Flags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring.Flags) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 95 with Flags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring.Flags in project bgpcep by opendaylight.

the class PCEPMetricObjectParser method parseObject.

@Override
public Metric parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
    if (bytes.readableBytes() != SIZE) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: " + SIZE + ".");
    }
    bytes.skipBytes(RESERVED);
    final BitArray flags = BitArray.valueOf(bytes.readByte());
    return new MetricBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setBound(flags.get(B_FLAG_OFFSET)).setComputed(flags.get(C_FLAG_OFFSET)).setMetricType(ByteBufUtils.readUint8(bytes)).setValue(new Float32(ByteArray.readBytes(bytes, METRIC_VALUE_F_LENGTH))).build();
}
Also used : ByteBufWriteUtil.writeFloat32(org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32) Float32(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32) BitArray(org.opendaylight.protocol.util.BitArray) MetricBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.MetricBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)120 Test (org.junit.Test)106 BitArray (org.opendaylight.protocol.util.BitArray)77 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)29 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 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)12 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)12 BigInteger (java.math.BigInteger)11 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)9 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)9 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)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.rev200120.path.attributes.Attributes)8 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)7 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.rev200120.UpdateBuilder)7