Search in sources :

Example 1 with FlowSpecObjectBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.flow.spec.object.FlowSpecObjectBuilder 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)1 Float32 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32)1 FlowSpecObjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.flow.spec.object.FlowSpecObjectBuilder)1 TspecObjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObjectBuilder)1