Search in sources :

Example 6 with MeterBandDscpRemarkCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method setMeterConfig.

private MultipartReplyMeterConfigCase setMeterConfig(final ByteBuf input) {
    MultipartReplyMeterConfigCaseBuilder caseBuilder = new MultipartReplyMeterConfigCaseBuilder();
    MultipartReplyMeterConfigBuilder builder = new MultipartReplyMeterConfigBuilder();
    List<MeterConfig> meterConfigList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        MeterConfigBuilder meterConfigBuilder = new MeterConfigBuilder();
        int meterConfigBodyLength = input.readUnsignedShort();
        meterConfigBuilder.setFlags(createMeterFlags(input.readUnsignedShort()));
        meterConfigBuilder.setMeterId(new MeterId(input.readUnsignedInt()));
        int actualLength = METER_CONFIG_LENGTH;
        List<Bands> bandsList = new ArrayList<>();
        while (actualLength < meterConfigBodyLength) {
            int bandStartIndex = input.readerIndex();
            BandsBuilder bandsBuilder = new BandsBuilder();
            int bandType = input.readUnsignedShort();
            switch(bandType) {
                case 1:
                    final MeterBandDropCaseBuilder bandDropCaseBuilder = new MeterBandDropCaseBuilder();
                    MeterBandDropBuilder bandDropBuilder = new MeterBandDropBuilder();
                    bandDropBuilder.setType(MeterBandType.forValue(bandType));
                    actualLength += input.readUnsignedShort();
                    bandDropBuilder.setRate(input.readUnsignedInt());
                    bandDropBuilder.setBurstSize(input.readUnsignedInt());
                    input.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);
                    bandDropCaseBuilder.setMeterBandDrop(bandDropBuilder.build());
                    bandsBuilder.setMeterBand(bandDropCaseBuilder.build());
                    break;
                case 2:
                    final MeterBandDscpRemarkCaseBuilder bandDscpRemarkCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
                    MeterBandDscpRemarkBuilder bandDscpRemarkBuilder = new MeterBandDscpRemarkBuilder();
                    bandDscpRemarkBuilder.setType(MeterBandType.forValue(bandType));
                    actualLength += input.readUnsignedShort();
                    bandDscpRemarkBuilder.setRate(input.readUnsignedInt());
                    bandDscpRemarkBuilder.setBurstSize(input.readUnsignedInt());
                    bandDscpRemarkBuilder.setPrecLevel(input.readUnsignedByte());
                    input.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);
                    bandDscpRemarkCaseBuilder.setMeterBandDscpRemark(bandDscpRemarkBuilder.build());
                    bandsBuilder.setMeterBand(bandDscpRemarkCaseBuilder.build());
                    break;
                case 0xFFFF:
                    actualLength += input.readUnsignedShort();
                    final long expId = input.getUnsignedInt(input.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
                    input.readerIndex(bandStartIndex);
                    OFDeserializer<MeterBandExperimenterCase> deserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId));
                    bandsBuilder.setMeterBand(deserializer.deserialize(input));
                    break;
                default:
                    break;
            }
            bandsList.add(bandsBuilder.build());
        }
        meterConfigBuilder.setBands(bandsList);
        meterConfigList.add(meterConfigBuilder.build());
    }
    builder.setMeterConfig(meterConfigList);
    caseBuilder.setMultipartReplyMeterConfig(builder.build());
    return caseBuilder.build();
}
Also used : MultipartReplyMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder) MeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder) MeterBandDscpRemarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder) MultipartReplyMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder) ArrayList(java.util.ArrayList) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) MeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig) MeterBandExperimenterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId) MeterBandDscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) MultipartReplyMeterConfigCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCaseBuilder) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder)

Example 7 with MeterBandDscpRemarkCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method createBandsList.

private static List<Bands> createBandsList() {
    final List<Bands> bandsList = new ArrayList<>();
    final BandsBuilder bandsBuilder = new BandsBuilder();
    final MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
    MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
    dropBand.setType(MeterBandType.OFPMBTDROP);
    dropBand.setRate(1L);
    dropBand.setBurstSize(2L);
    dropCaseBuilder.setMeterBandDrop(dropBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build());
    final MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
    MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
    dscpRemarkBand.setType(MeterBandType.OFPMBTDSCPREMARK);
    dscpRemarkBand.setRate(1L);
    dscpRemarkBand.setBurstSize(2L);
    dscpRemarkBand.setPrecLevel((short) 3);
    dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build());
    return bandsList;
}
Also used : MeterBandDscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) MeterBandDscpRemarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder) ArrayList(java.util.ArrayList) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder)

Example 8 with MeterBandDscpRemarkCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder in project openflowplugin by opendaylight.

the class MeterModInputMessageFactoryTest method decodeBandsList.

private static List<Bands> decodeBandsList(ByteBuf input) {
    final List<Bands> bandsList = new ArrayList<>();
    final BandsBuilder bandsBuilder = new BandsBuilder();
    final MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
    MeterBandDropBuilder dropBand = new MeterBandDropBuilder();
    dropBand.setType(MeterBandType.forValue(input.readUnsignedShort()));
    input.skipBytes(Short.SIZE / Byte.SIZE);
    dropBand.setRate(input.readUnsignedInt());
    dropBand.setBurstSize(input.readUnsignedInt());
    input.skipBytes(4);
    dropCaseBuilder.setMeterBandDrop(dropBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dropCaseBuilder.build()).build());
    final MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
    MeterBandDscpRemarkBuilder dscpRemarkBand = new MeterBandDscpRemarkBuilder();
    dscpRemarkBand.setType(MeterBandType.forValue(input.readUnsignedShort()));
    input.skipBytes(Short.SIZE / Byte.SIZE);
    dscpRemarkBand.setRate(input.readUnsignedInt());
    dscpRemarkBand.setBurstSize(input.readUnsignedInt());
    dscpRemarkBand.setPrecLevel(input.readUnsignedByte());
    input.skipBytes(3);
    dscpCaseBuilder.setMeterBandDscpRemark(dscpRemarkBand.build());
    bandsList.add(bandsBuilder.setMeterBand(dscpCaseBuilder.build()).build());
    return bandsList;
}
Also used : MeterBandDscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) MeterBandDscpRemarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder) ArrayList(java.util.ArrayList) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder)

Example 9 with MeterBandDscpRemarkCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder in project openflowplugin by opendaylight.

the class MeterConvertor method getBandsFromSAL.

private static void getBandsFromSAL(MeterBandHeaders meterBandHeaders, List<Bands> bands) {
    for (MeterBandHeader meterBandHeader : meterBandHeaders.getMeterBandHeader()) {
        // The band types :drop,DSCP_Remark or experimenter.
        if (null != meterBandHeader.getMeterBandTypes() && null != meterBandHeader.getMeterBandTypes().getFlags()) {
            if (meterBandHeader.getMeterBandTypes().getFlags().isOfpmbtDrop()) {
                if (meterBandHeader.getBandType() != null) {
                    MeterBandDropBuilder meterBandDropBuilder = new MeterBandDropBuilder();
                    meterBandDropBuilder.setType(MeterBandType.OFPMBTDROP);
                    Drop drop = (Drop) meterBandHeader.getBandType();
                    meterBandDropBuilder.setBurstSize(drop.getDropBurstSize());
                    meterBandDropBuilder.setRate(drop.getDropRate());
                    MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
                    dropCaseBuilder.setMeterBandDrop(meterBandDropBuilder.build());
                    MeterBand meterBandItem = dropCaseBuilder.build();
                    BandsBuilder bandsB = new BandsBuilder();
                    bandsB.setMeterBand(meterBandItem);
                    // Bands list
                    bands.add(bandsB.build());
                } else {
                    logBandTypeMissing(MeterBandType.OFPMBTDROP);
                }
            } else if (meterBandHeader.getMeterBandTypes().getFlags().isOfpmbtDscpRemark()) {
                if (meterBandHeader.getBandType() != null) {
                    MeterBandDscpRemarkBuilder meterBandDscpRemarkBuilder = new MeterBandDscpRemarkBuilder();
                    meterBandDscpRemarkBuilder.setType(MeterBandType.OFPMBTDSCPREMARK);
                    DscpRemark dscpRemark = (DscpRemark) meterBandHeader.getBandType();
                    meterBandDscpRemarkBuilder.setBurstSize(dscpRemark.getDscpRemarkBurstSize());
                    meterBandDscpRemarkBuilder.setRate(dscpRemark.getDscpRemarkRate());
                    meterBandDscpRemarkBuilder.setPrecLevel(dscpRemark.getPrecLevel());
                    MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
                    dscpCaseBuilder.setMeterBandDscpRemark(meterBandDscpRemarkBuilder.build());
                    MeterBand meterBandItem = dscpCaseBuilder.build();
                    BandsBuilder bandsB = new BandsBuilder();
                    bandsB.setMeterBand(meterBandItem);
                    // Bands list
                    bands.add(bandsB.build());
                } else {
                    logBandTypeMissing(MeterBandType.OFPMBTDSCPREMARK);
                }
            } else if (meterBandHeader.getMeterBandTypes().getFlags().isOfpmbtExperimenter()) {
                if (meterBandHeader.getBandType() != null) {
                    MeterBandExperimenterBuilder meterBandExperimenterBuilder = new MeterBandExperimenterBuilder();
                    meterBandExperimenterBuilder.setType(MeterBandType.OFPMBTEXPERIMENTER);
                    Experimenter experimenter = (Experimenter) meterBandHeader.getBandType();
                    meterBandExperimenterBuilder.setBurstSize(experimenter.getExperimenterBurstSize());
                    meterBandExperimenterBuilder.setRate(experimenter.getExperimenterRate());
                    ExperimenterIdMeterBandBuilder expBuilder = new ExperimenterIdMeterBandBuilder();
                    expBuilder.setExperimenter(new ExperimenterId(experimenter.getExperimenter()));
                    meterBandExperimenterBuilder.addAugmentation(ExperimenterIdMeterBand.class, expBuilder.build());
                    // TODO - implement / finish experimenter meter band translation
                    MeterBandExperimenterCaseBuilder experimenterCaseBuilder = new MeterBandExperimenterCaseBuilder();
                    experimenterCaseBuilder.setMeterBandExperimenter(meterBandExperimenterBuilder.build());
                    MeterBand meterBandItem = experimenterCaseBuilder.build();
                    BandsBuilder bandsB = new BandsBuilder();
                    bandsB.setMeterBand(meterBandItem);
                    // Bands list
                    bands.add(bandsB.build());
                } else {
                    logBandTypeMissing(MeterBandType.OFPMBTEXPERIMENTER);
                }
            }
        } else {
            LOG.error("Invalid meter band data found.");
        }
    }
}
Also used : MeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand) ExperimenterIdMeterBand(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMeterBand) DscpRemark(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemark) MeterBandDscpRemarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder) Experimenter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) MeterBandExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCaseBuilder) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) Drop(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop) MeterBandDscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder) MeterBandExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenterBuilder) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) ExperimenterIdMeterBandBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMeterBandBuilder) MeterBandHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder)

Aggregations

MeterBandDropCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder)9 MeterBandDscpRemarkCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder)9 MeterBandDropBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder)9 MeterBandDscpRemarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder)9 ArrayList (java.util.ArrayList)8 BandsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.BandsBuilder)5 Bands (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.mod.Bands)4 Bands (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands)4 BandsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder)4 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId)3 MeterBandExperimenterCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase)2 MeterBandExperimenterCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCaseBuilder)2 MeterBandExperimenterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenterBuilder)2 MeterConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig)2 MeterConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 Drop (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop)1 DscpRemark (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemark)1 Experimenter (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter)1 MeterBandHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader)1