use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterMessageBuilder in project openflowplugin by opendaylight.
the class MeterMessageDeserializer method deserialize.
@Override
public MeterMessage deserialize(ByteBuf message) {
final MeterMessageBuilder builder = new MeterMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(message.readUnsignedInt()).setCommand(MeterModCommand.forValue(message.readUnsignedShort())).setFlags(readMeterFlags(message)).setMeterId(new MeterId(message.readUnsignedInt()));
final List<MeterBandHeader> bands = new ArrayList<>();
while (message.readableBytes() > 0) {
final MeterBandHeaderBuilder bandBuilder = new MeterBandHeaderBuilder();
final int bandStartIndex = message.readerIndex();
final int bandType = message.readUnsignedShort();
switch(bandType) {
case OFPMBTDROP:
{
bandBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(true, false, false)).build()).setBandType(new DropBuilder().setDropRate(message.readUnsignedInt()).setDropBurstSize(message.readUnsignedInt()).build());
message.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);
break;
}
case OFPMBTDSCP:
{
bandBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, true, false)).build()).setBandType(new DscpRemarkBuilder().setDscpRemarkRate(message.readUnsignedInt()).setDscpRemarkBurstSize(message.readUnsignedInt()).setPrecLevel(message.readUnsignedByte()).build());
message.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);
break;
}
case OFPMBTEXPERIMENTER:
{
// TODO: Finish meter band experimenter deserialization
long expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
message.readerIndex(bandStartIndex);
OFDeserializer<Experimenter> deserializer = registry.getDeserializer(new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, Experimenter.class));
bandBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, false, true)).build()).setBandType(deserializer.deserialize(message));
break;
}
default:
}
bands.add(bandBuilder.build());
}
return builder.setMeterBandHeaders(new MeterBandHeadersBuilder().setMeterBandHeader(bands).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterMessageBuilder in project openflowplugin by opendaylight.
the class SingleLayerMeterService method buildRequest.
@Override
protected OfHeader buildRequest(final Xid xid, final Meter input) throws ServiceException {
final MeterMessageBuilder meterMessageBuilder = new MeterMessageBuilder(input);
final Class<? extends DataContainer> clazz = input.getImplementedInterface();
if (clazz.equals(AddMeterInput.class) || clazz.equals(UpdatedMeter.class)) {
meterMessageBuilder.setCommand(MeterModCommand.OFPMCADD);
} else if (clazz.equals(RemoveMeterInput.class) || clazz.equals(OriginalMeter.class)) {
meterMessageBuilder.setCommand(MeterModCommand.OFPMCDELETE);
}
return meterMessageBuilder.setVersion(getVersion()).setXid(xid.getValue()).build();
}
Aggregations