use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactory method setExperimenter.
private MultipartReplyExperimenterCase setExperimenter(ByteBuf input) {
final long expId = input.readUnsignedInt();
final OFDeserializer<ExperimenterDataOfChoice> deserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createMultipartReplyVendorMessageDeserializerKey(EncodeConstants.OF10_VERSION_ID, expId));
final MultipartReplyExperimenterBuilder mpExperimenterBld = new MultipartReplyExperimenterBuilder().setExperimenter(new ExperimenterId(expId)).setExperimenterDataOfChoice(deserializer.deserialize(input));
final MultipartReplyExperimenterCaseBuilder mpReplyExperimenterCaseBld = new MultipartReplyExperimenterCaseBuilder().setMultipartReplyExperimenter(mpExperimenterBld.build());
return mpReplyExperimenterCaseBld.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.
the class VendorMessageFactory method deserialize.
@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public ExperimenterMessage deserialize(ByteBuf message) {
Objects.requireNonNull(deserializerRegistry);
final long xid = message.readUnsignedInt();
final long expId = message.readUnsignedInt();
OFDeserializer<ExperimenterDataOfChoice> deserializer = deserializerRegistry.getDeserializer(ExperimenterDeserializerKeyFactory.createVendorMessageDeserializerKey(EncodeConstants.OF10_VERSION_ID, expId));
final ExperimenterDataOfChoice vendorData = deserializer.deserialize(message);
final ExperimenterMessageBuilder messageBld = new ExperimenterMessageBuilder().setVersion((short) EncodeConstants.OF10_VERSION_ID).setXid(xid).setExperimenter(new ExperimenterId(expId)).setExperimenterDataOfChoice(vendorData);
return messageBld.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.
the class OF10StatsRequestExperimenterTest method testExperimenter.
/**
* Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization.
*/
@Test
public void testExperimenter() throws Exception {
Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(serializer);
OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory();
multipartFactory.injectSerializerRegistry(mockRegistry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setType(MultipartType.OFPMPEXPERIMENTER);
builder.setFlags(new MultipartRequestFlags(false));
final MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
expBuilder.setExpType(21L);
expBuilder.setExperimenterDataOfChoice(vendorData);
caseBuilder.setMultipartRequestExperimenter(expBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV10(out, (byte) 16, 16);
Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.
the class ActionDeserializer method deserialize.
@Override
public Action deserialize(ByteBuf message) {
final int startPosition = message.readerIndex();
// size of experimenter type
message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
// size of length
message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
long experimenterId = message.readUnsignedInt();
if (NiciraConstants.NX_VENDOR_ID != experimenterId) {
throw new IllegalStateException("Experimenter ID is not Nicira vendor id but is " + experimenterId);
}
int subtype = message.readUnsignedShort();
NiciraActionDeserializerKey key = new NiciraActionDeserializerKey(version, subtype);
OFDeserializer<Action> actionDeserializer = NiciraExtensionCodecRegistratorImpl.getActionDeserializer(key);
if (actionDeserializer == null) {
LOG.info("No deserializer was found for key {}", key);
return null;
}
message.readerIndex(startPosition);
return actionDeserializer.deserialize(message);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId in project openflowplugin by opendaylight.
the class LearnCodec method deserialize.
@Override
public Action deserialize(final ByteBuf message) {
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setExperimenterId(new ExperimenterId(NiciraConstants.NX_VENDOR_ID));
short length = LearnCodecUtil.deserializeHeader(message);
final ActionLearnBuilder actionLearnBuilder = new ActionLearnBuilder();
NxActionLearnBuilder nxActionLearnBuilder = new NxActionLearnBuilder();
LearnCodecUtil.deserializeLearnHeader(message, nxActionLearnBuilder);
length -= LearnCodecUtil.HEADER_LENGTH;
LearnCodecUtil.buildFlowModSpecs(nxActionLearnBuilder, message, length);
actionLearnBuilder.setNxActionLearn(nxActionLearnBuilder.build());
actionBuilder.setActionChoice(actionLearnBuilder.build());
return actionBuilder.build();
}
Aggregations