use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.DscpCase in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testMultipartReplyMeterConfigBodyMulti.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyMeterConfigBodyMulti() {
ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 " + // len
"00 28 " + // flags
"00 06 " + // meterId
"00 00 00 09 " + // meterBandDrop.type
"00 01 " + // meterBandDrop.len
"00 10 " + // meterBandDrop.rate
"00 00 00 11 " + // meterBandDrop.burstSize
"00 00 00 20 " + // meterBandDrop.pad
"00 00 00 00 " + // meterBandDscp.type
"00 02 " + // meterBandDscp.len
"00 10 " + // meterBandDscp.rate
"00 00 00 11 " + // meterBandDscp.burstSize
"00 00 00 20 " + // meterBandDscp.precLevel
"04 " + // meterBandDscp.pad
"00 00 00 " + // len01
"00 18 " + // flags01
"00 03 " + // meterId01
"00 00 00 07 " + // meterBandDscp01.type
"00 02 " + // meterBandDscp01.len
"00 10 " + // meterBandDscp01.rate
"00 00 00 11 " + // meterBandDscp01.burstSize
"00 00 00 20 " + // meterBandDscp01.precLevel
"04 " + // meterBandDscp01.pad
"00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody();
MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
Assert.assertEquals("Wrong flags", new MeterFlags(true, false, true, false), message.getMeterConfig().get(0).getFlags());
Assert.assertEquals("Wrong meterId", 9, message.getMeterConfig().get(0).getMeterId().getValue().intValue());
MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark();
Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
LOG.info(message.getMeterConfig().get(0).getFlags().toString());
Assert.assertEquals("Wrong flags01", new MeterFlags(false, true, true, false), message.getMeterConfig().get(1).getFlags());
Assert.assertEquals("Wrong meterId01", 7, message.getMeterConfig().get(1).getMeterId().getValue().intValue());
MeterBandDscpRemarkCase dscpCase01 = (MeterBandDscpRemarkCase) message.getMeterConfig().get(1).getBands().get(0).getMeterBand();
MeterBandDscpRemark meterBandDscp01 = dscpCase01.getMeterBandDscpRemark();
Assert.assertEquals("Wrong meterBandDscp01.type", 2, meterBandDscp01.getType().getIntValue());
Assert.assertEquals("Wrong meterBandDscp01.rate", 17, meterBandDscp01.getRate().intValue());
Assert.assertEquals("Wrong meterBandDscp01.burstSize", 32, meterBandDscp01.getBurstSize().intValue());
Assert.assertEquals("Wrong meterBandDscp01.precLevel", 4, meterBandDscp01.getPrecLevel().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.DscpCase in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testMultipartReplyMeterConfigBody.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyMeterConfigBody() {
ByteBuf bb = BufferHelper.buildBuffer("00 0A 00 01 00 00 00 00 " + // len
"00 28 " + // flags
"00 0A " + // meterId
"00 00 00 09 " + // meterBandDrop.type
"00 01 " + // meterBandDrop.len
"00 10 " + // meterBandDrop.rate
"00 00 00 11 " + // meterBandDrop.burstSize
"00 00 00 20 " + // meterBandDrop.pad
"00 00 00 00 " + // meterBandDscp.type
"00 02 " + // meterBandDscp.len
"00 10 " + // meterBandDscp.rate
"00 00 00 11 " + // meterBandDscp.burstSize
"00 00 00 20 " + // meterBandDscp.precLevel
"04 " + // meterBandDscp.pad
"00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 10, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyMeterConfigCase messageCase = (MultipartReplyMeterConfigCase) builtByFactory.getMultipartReplyBody();
MultipartReplyMeterConfig message = messageCase.getMultipartReplyMeterConfig();
Assert.assertEquals("Wrong flags", new MeterFlags(false, false, true, true), message.getMeterConfig().get(0).getFlags());
Assert.assertEquals("Wrong meterId", 9, message.getMeterConfig().get(0).getMeterId().getValue().intValue());
MeterBandDropCase dropCase = (MeterBandDropCase) message.getMeterConfig().get(0).getBands().get(0).getMeterBand();
MeterBandDrop meterBandDrop = dropCase.getMeterBandDrop();
Assert.assertEquals("Wrong meterBandDrop.type", 1, meterBandDrop.getType().getIntValue());
Assert.assertEquals("Wrong meterBandDrop.rate", 17, meterBandDrop.getRate().intValue());
Assert.assertEquals("Wrong meterBandDrop.burstSize", 32, meterBandDrop.getBurstSize().intValue());
MeterBandDscpRemarkCase dscpCase = (MeterBandDscpRemarkCase) message.getMeterConfig().get(0).getBands().get(1).getMeterBand();
MeterBandDscpRemark meterBandDscp = dscpCase.getMeterBandDscpRemark();
Assert.assertEquals("Wrong meterBandDscp.type", 2, meterBandDscp.getType().getIntValue());
Assert.assertEquals("Wrong meterBandDscp.rate", 17, meterBandDscp.getRate().intValue());
Assert.assertEquals("Wrong meterBandDscp.burstSize", 32, meterBandDscp.getBurstSize().intValue());
Assert.assertEquals("Wrong meterBandDscp.precLevel", 4, meterBandDscp.getPrecLevel().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.DscpCase in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method encodeFlow.
@VisibleForTesting
final String encodeFlow(final Flowspec flow) {
final StringBuilder buffer = new StringBuilder();
final FlowspecType value = flow.getFlowspecType();
if (value instanceof PortCase) {
buffer.append("where port ");
buffer.append(NumericTwoByteOperandParser.INSTANCE.toString(((PortCase) value).getPorts()));
} else if (value instanceof DestinationPortCase) {
buffer.append("where destination port ");
buffer.append(NumericTwoByteOperandParser.INSTANCE.toString(((DestinationPortCase) value).getDestinationPorts()));
} else if (value instanceof SourcePortCase) {
buffer.append("where source port ");
buffer.append(NumericTwoByteOperandParser.INSTANCE.toString(((SourcePortCase) value).getSourcePorts()));
} else if (value instanceof IcmpTypeCase) {
buffer.append("where ICMP type ");
buffer.append(NumericOneByteOperandParser.INSTANCE.toString(((IcmpTypeCase) value).getTypes()));
} else if (value instanceof IcmpCodeCase) {
buffer.append("where ICMP code ");
buffer.append(NumericOneByteOperandParser.INSTANCE.toString(((IcmpCodeCase) value).getCodes()));
} else if (value instanceof TcpFlagsCase) {
buffer.append(stringTcpFlags(((TcpFlagsCase) value).getTcpFlags()));
} else if (value instanceof PacketLengthCase) {
buffer.append("where packet length ");
buffer.append(NumericTwoByteOperandParser.INSTANCE.toString(((PacketLengthCase) value).getPacketLengths()));
} else if (value instanceof DscpCase) {
buffer.append(stringDscp(((DscpCase) value).getDscps()));
} else if (value instanceof FragmentCase) {
buffer.append(stringFragment(((FragmentCase) value).getFragments()));
} else {
stringSpecificFSNlriType(value, buffer);
}
return buffer.toString();
}
Aggregations