Search in sources :

Example 1 with TspecObjectBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObjectBuilder in project bgpcep by opendaylight.

the class SenderTspecObjectParser method localParseObject.

@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
    final TspecObjectBuilder builder = new TspecObjectBuilder();
    // skip version number, reserved, Overall length
    byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
    // skip Service header, reserved, Length of service
    byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
    // skip Parameter ID, Parameter 127 flags, Parameter 127 length
    byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
    builder.setTokenBucketRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
    builder.setTokenBucketSize(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
    builder.setPeakDataRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
    builder.setMinimumPolicedUnit(byteBuf.readUnsignedInt());
    builder.setMaximumPacketSize(byteBuf.readUnsignedInt());
    return builder.build();
}
Also used : Float32(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32) ByteBufWriteUtil.writeFloat32(org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32) TspecObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObjectBuilder)

Example 2 with TspecObjectBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObjectBuilder in project bgpcep by opendaylight.

the class FlowSpecObjectParser method localParseObject.

@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
    final FlowSpecObjectBuilder builder = new FlowSpecObjectBuilder();
    // skip version number, reserved, overall length
    byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
    builder.setServiceHeader(ServiceNumber.forValue(byteBuf.readUnsignedByte()));
    // skip reserved
    byteBuf.skipBytes(ByteBufWriteUtil.ONE_BYTE_LENGTH);
    // skip Length of controlled-load data
    byteBuf.skipBytes(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
    // skip parameter ID 127 and 127 flags
    byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
    final TspecObjectBuilder tBuilder = new TspecObjectBuilder();
    tBuilder.setTokenBucketRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
    tBuilder.setTokenBucketSize(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
    tBuilder.setPeakDataRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
    tBuilder.setMinimumPolicedUnit(byteBuf.readUnsignedInt());
    tBuilder.setMaximumPacketSize(byteBuf.readUnsignedInt());
    builder.setTspecObject(tBuilder.build());
    if (builder.getServiceHeader().getIntValue() == 2) {
        // skip parameter ID 130, flags, lenght
        byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
        builder.setRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
        builder.setSlackTerm(byteBuf.readUnsignedInt());
    }
    return builder.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) TspecObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObjectBuilder) FlowSpecObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.flow.spec.object.FlowSpecObjectBuilder)

Aggregations

ByteBufWriteUtil.writeFloat32 (org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32)2 Float32 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32)2 TspecObjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObjectBuilder)2 FlowSpecObjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.flow.spec.object.FlowSpecObjectBuilder)1