use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage in project openflowplugin by opendaylight.
the class MultipartReplyGroupFeaturesTest method testMultipartReplyGroupFeatures2.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
* (with different group types and capabilities).
*/
@Test
public void testMultipartReplyGroupFeatures2() {
ByteBuf bb = BufferHelper.buildBuffer(//
"00 08 00 01 00 00 00 00 " + // types
"00 00 00 00 " + // capabilities
"00 00 00 00 " + // max groups
"00 00 00 01 " + // max groups
"00 00 00 02 " + // max groups
"00 00 00 03 " + // max groups
"00 00 00 04 " + // actions bitmap (all actions included)
"00 00 00 00 " + // actions bitmap (no actions included)
"00 00 00 00 " + // actions bitmap (no actions included)
"00 00 00 00 " + // actions bitmap (no actions included)
"00 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyGroupFeaturesCase messageCase = (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures();
Assert.assertEquals("Wrong group types", new GroupTypes(false, false, false, false), message.getTypes());
Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false), message.getCapabilities());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method deserialize.
@Override
public MultipartReplyMessage deserialize(final ByteBuf rawMessage) {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
int type = rawMessage.readUnsignedShort();
builder.setType(MultipartType.forValue(type));
builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0));
rawMessage.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER);
switch(MultipartType.forValue(type)) {
case OFPMPDESC:
builder.setMultipartReplyBody(setDesc(rawMessage));
break;
case OFPMPFLOW:
builder.setMultipartReplyBody(setFlow(rawMessage));
break;
case OFPMPAGGREGATE:
builder.setMultipartReplyBody(setAggregate(rawMessage));
break;
case OFPMPTABLE:
builder.setMultipartReplyBody(setTable(rawMessage));
break;
case OFPMPPORTSTATS:
builder.setMultipartReplyBody(setPortStats(rawMessage));
break;
case OFPMPQUEUE:
builder.setMultipartReplyBody(setQueue(rawMessage));
break;
case OFPMPGROUP:
builder.setMultipartReplyBody(setGroup(rawMessage));
break;
case OFPMPGROUPDESC:
builder.setMultipartReplyBody(setGroupDesc(rawMessage));
break;
case OFPMPGROUPFEATURES:
builder.setMultipartReplyBody(setGroupFeatures(rawMessage));
break;
case OFPMPMETER:
builder.setMultipartReplyBody(setMeter(rawMessage));
break;
case OFPMPMETERCONFIG:
builder.setMultipartReplyBody(setMeterConfig(rawMessage));
break;
case OFPMPMETERFEATURES:
builder.setMultipartReplyBody(setMeterFeatures(rawMessage));
break;
case OFPMPTABLEFEATURES:
builder.setMultipartReplyBody(setTableFeatures(rawMessage));
break;
case OFPMPPORTDESC:
builder.setMultipartReplyBody(setPortDesc(rawMessage));
break;
case OFPMPEXPERIMENTER:
builder.setMultipartReplyBody(setExperimenter(rawMessage));
break;
default:
break;
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactory method deserialize.
@Override
public MultipartReplyMessage deserialize(ByteBuf rawMessage) {
Objects.requireNonNull(registry);
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
int type = rawMessage.readUnsignedShort();
builder.setType(MultipartType.forValue(type));
builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0));
switch(MultipartType.forValue(type)) {
case OFPMPDESC:
builder.setMultipartReplyBody(setDesc(rawMessage));
break;
case OFPMPFLOW:
builder.setMultipartReplyBody(setFlow(rawMessage));
break;
case OFPMPAGGREGATE:
builder.setMultipartReplyBody(setAggregate(rawMessage));
break;
case OFPMPTABLE:
builder.setMultipartReplyBody(setTable(rawMessage));
break;
case OFPMPPORTSTATS:
builder.setMultipartReplyBody(setPortStats(rawMessage));
break;
case OFPMPQUEUE:
builder.setMultipartReplyBody(setQueue(rawMessage));
break;
case OFPMPEXPERIMENTER:
builder.setMultipartReplyBody(setExperimenter(rawMessage));
break;
default:
break;
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testGroupFeaturesSerialize.
@Test
public void testGroupFeaturesSerialize() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(8));
final MultipartReplyGroupFeaturesCaseBuilder featureCase = new MultipartReplyGroupFeaturesCaseBuilder();
MultipartReplyGroupFeaturesBuilder feature = new MultipartReplyGroupFeaturesBuilder();
feature.setTypes(new GroupTypes(true, false, true, false));
feature.setCapabilities(new GroupCapabilities(true, false, true, true));
List<Long> maxGroups = new ArrayList<>();
maxGroups.add(1L);
maxGroups.add(2L);
maxGroups.add(3L);
maxGroups.add(4L);
feature.setMaxGroups(maxGroups);
feature.setActionsBitmap(createActionType());
featureCase.setMultipartReplyGroupFeatures(feature.build());
builder.setMultipartReplyBody(featureCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 56);
Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUPFEATURES.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
MultipartReplyGroupFeaturesCase body = (MultipartReplyGroupFeaturesCase) message.getMultipartReplyBody();
MultipartReplyGroupFeatures messageOutput = body.getMultipartReplyGroupFeatures();
Assert.assertEquals("Wrong type", messageOutput.getTypes(), createGroupTypes(serializedBuffer.readInt()));
Assert.assertEquals("Wrong capabilities", messageOutput.getCapabilities(), createGroupCapabilities(serializedBuffer.readInt()));
Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(0).intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(1).intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(2).intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(3).intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(0), createActionType(serializedBuffer.readInt()));
Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(1), createActionType(serializedBuffer.readInt()));
Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(2), createActionType(serializedBuffer.readInt()));
Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(3), createActionType(serializedBuffer.readInt()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testGroupSerialize.
@Test
public void testGroupSerialize() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(6));
MultipartReplyGroupCaseBuilder groupCase = new MultipartReplyGroupCaseBuilder();
MultipartReplyGroupBuilder group = new MultipartReplyGroupBuilder();
group.setGroupStats(createGroupStats());
groupCase.setMultipartReplyGroup(group.build());
builder.setMultipartReplyBody(groupCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 72);
Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUP.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
MultipartReplyGroupCase body = (MultipartReplyGroupCase) message.getMultipartReplyBody();
MultipartReplyGroup messageOutput = body.getMultipartReplyGroup();
GroupStats groupStats = messageOutput.getGroupStats().get(0);
Assert.assertEquals("Wrong length", 56, serializedBuffer.readShort());
serializedBuffer.skipBytes(2);
Assert.assertEquals("Wrong group id", groupStats.getGroupId().getValue().intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong ref count", groupStats.getRefCount().intValue(), serializedBuffer.readInt());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong Packet count", groupStats.getPacketCount().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong Byte count", groupStats.getByteCount().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong duration sec", groupStats.getDurationSec().intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong duration nsec", groupStats.getDurationNsec().intValue(), serializedBuffer.readInt());
BucketStats bucketStats = groupStats.getBucketStats().get(0);
Assert.assertEquals("Wrong Packet count", bucketStats.getPacketCount().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong Byte count", bucketStats.getByteCount().longValue(), serializedBuffer.readLong());
}
Aggregations