use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder in project openflowplugin by opendaylight.
the class MultipartRequestInputMessageFactory method deserialize.
@Override
public MultipartRequestInput deserialize(ByteBuf rawMessage) {
Objects.requireNonNull(registry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
int type = rawMessage.readUnsignedShort();
builder.setType(getMultipartType(type));
builder.setFlags(getMultipartRequestFlags(rawMessage.readUnsignedShort()));
rawMessage.skipBytes(PADDING);
switch(MultipartType.forValue(type)) {
case OFPMPDESC:
builder.setMultipartRequestBody(setDesc(rawMessage));
break;
case OFPMPFLOW:
builder.setMultipartRequestBody(setFlow(rawMessage));
break;
case OFPMPAGGREGATE:
builder.setMultipartRequestBody(setAggregate(rawMessage));
break;
case OFPMPTABLE:
builder.setMultipartRequestBody(setTable(rawMessage));
break;
case OFPMPTABLEFEATURES:
builder.setMultipartRequestBody(setTableFeatures(rawMessage));
break;
case OFPMPPORTSTATS:
builder.setMultipartRequestBody(setPortStats(rawMessage));
break;
case OFPMPPORTDESC:
builder.setMultipartRequestBody(setPortDesc(rawMessage));
break;
case OFPMPQUEUE:
builder.setMultipartRequestBody(setQueue(rawMessage));
break;
case OFPMPGROUP:
builder.setMultipartRequestBody(setGroup(rawMessage));
break;
case OFPMPGROUPDESC:
builder.setMultipartRequestBody(setGroupDesc(rawMessage));
break;
case OFPMPGROUPFEATURES:
builder.setMultipartRequestBody(setGroupFeatures(rawMessage));
break;
case OFPMPMETER:
builder.setMultipartRequestBody(setMeter(rawMessage));
break;
case OFPMPMETERCONFIG:
builder.setMultipartRequestBody(setMeterConfig(rawMessage));
break;
case OFPMPMETERFEATURES:
builder.setMultipartRequestBody(setMeterFeatures(rawMessage));
break;
case OFPMPEXPERIMENTER:
builder.setMultipartRequestBody(setExperimenter(rawMessage));
break;
default:
break;
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method testMultipartRequestPortStatsMessageFactory.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestPortStatsMessageFactory() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(4));
builder.setFlags(new MultipartRequestFlags(true));
builder.setMultipartRequestBody(createRequestPortStats());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 24);
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 portStatsBody", message.getMultipartRequestBody(), decodeRequestPortStats(out));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method testMultipartRequestGroupMessageFactory.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestGroupMessageFactory() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(6));
builder.setFlags(new MultipartRequestFlags(true));
builder.setMultipartRequestBody(createRequestGroup());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 24);
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 groupBody", message.getMultipartRequestBody(), decodeRequestGroup(out));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method testMultipartRequestInputTableFactory.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestInputTableFactory() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(3));
builder.setFlags(new MultipartRequestFlags(true));
// multipart request for registry does not have body
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 16);
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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method testMultipartRequestQueueMessageFactory.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestQueueMessageFactory() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(5));
builder.setFlags(new MultipartRequestFlags(true));
builder.setMultipartRequestBody(createRequestQueue());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 24);
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 queueBody", message.getMultipartRequestBody(), decodeRequestQueue(out));
}
Aggregations