use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.DscpCaseBuilder 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.DscpCaseBuilder 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.");
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.DscpCaseBuilder in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv4NlriParserTest method testExtractFlowspecDscps.
@Test
public void testExtractFlowspecDscps() {
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> entry = Builders.mapEntryBuilder();
entry.withNodeIdentifier(NodeIdentifierWithPredicates.of(FlowspecRoute.QNAME, FlowspecRoute.QNAME, entry));
entry.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_NID).withChild(Builders.choiceBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.FLOWSPEC_TYPE_NID).withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.DSCP_NID).withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID).withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID).withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE, AbstractOperandParser.END_OF_LIST_VALUE, AbstractNumericOperandParser.GREATER_THAN_VALUE)).build()).withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID).withValue(Uint8.valueOf(15)).build()).build()).build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new DscpCaseBuilder().setDscps(Lists.newArrayList(new DscpsBuilder().setValue(new Dscp(Uint8.valueOf(15))).setOp(new NumericOperand(true, true, false, true, false)).build())).build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
}
Aggregations