use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.
the class OF10StatsRequestInputFlowFactoryTest method test.
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("00 01 00 00 00 34 18 ff 00 33 00 01 02 03 04 " + "05 05 04 03 02 01 00 00 34 35 00 00 36 37 38 00 00 0a 00 00 01 0a 00 00 02 " + "00 39 00 3a 01 00 00 2a ");
MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV10(deserializedMessage);
Assert.assertEquals("Wrong type", 1, deserializedMessage.getType().getIntValue());
Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags());
Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.
the class OF10StatsRequestInputQueueFactoryTest method test.
@Test
public void test() {
ByteBuf bb = BufferHelper.buildBuffer("00 05 00 00 00 0f 00 00 00 00 00 10");
MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV10(deserializedMessage);
Assert.assertEquals("Wrong type", 5, deserializedMessage.getType().getIntValue());
Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags());
Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags 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.common.types.rev130731.MultipartRequestFlags 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.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method testMultipartRequestInputAggregateBodyFactory.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestInputAggregateBodyFactory() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(2));
builder.setFlags(new MultipartRequestFlags(true));
builder.setMultipartRequestBody(createRequestAggregate());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 48);
Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
Assert.assertEquals("Wrong aggregate", message.getMultipartRequestBody(), decodeRequestAggregate(out));
}
Aggregations