use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder in project openflowplugin by opendaylight.
the class OF10StatsRequestInputFactory method deserialize.
@Override
public MultipartRequestInput deserialize(ByteBuf rawMessage) {
Objects.requireNonNull(registry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
int type = rawMessage.readUnsignedShort();
builder.setType(getMultipartType(type));
builder.setFlags(getMultipartRequestFlags(rawMessage.readUnsignedShort()));
switch(getMultipartType(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 OFPMPPORTSTATS:
builder.setMultipartRequestBody(setPortStats(rawMessage));
break;
case OFPMPQUEUE:
builder.setMultipartRequestBody(setQueue(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 AllFlowsInTableService method buildRequest.
@Override
protected OfHeader buildRequest(final Xid xid, final GetAllFlowStatisticsFromFlowTableInput input) throws ServiceException {
final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
mprFlowRequestBuilder.setTableId(input.getTableId().getValue());
mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
final short version = getVersion();
FlowCreatorUtil.setWildcardedFlowMatch(version, mprFlowRequestBuilder);
final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(MultipartType.OFPMPFLOW, xid.getValue(), version);
mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
return mprInput.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder 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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method testMultipartRequestDescMessageFactory.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestDescMessageFactory() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(0));
builder.setFlags(new MultipartRequestFlags(true));
builder.setMultipartRequestBody(createRequestDesc());
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.readUnsignedShort());
Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method testMultipartRequestFlowInputFactory.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestFlowInputFactory() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(1));
builder.setFlags(new MultipartRequestFlags(true));
builder.setMultipartRequestBody(createRequestFlow());
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 flow", message.getMultipartRequestBody(), decodeRequestFlow(out));
}
Aggregations