Search in sources :

Example 11 with ExperimenterId

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();
}
Also used : MultipartReplyExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCaseBuilder) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) MultipartReplyExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.experimenter._case.MultipartReplyExperimenterBuilder)

Example 12 with ExperimenterId

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();
}
Also used : ExperimenterMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 13 with ExperimenterId

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);
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) OF10StatsRequestInputFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory) MultipartRequestExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder) MultipartRequestExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 14 with ExperimenterId

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);
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) NiciraActionDeserializerKey(org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey)

Example 15 with ExperimenterId

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();
}
Also used : NxActionLearnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.NxActionLearnBuilder) ActionLearnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionLearnBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) NxActionLearnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.NxActionLearnBuilder)

Aggregations

ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)37 Test (org.junit.Test)14 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)13 ExperimenterDataOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)9 ByteBuf (io.netty.buffer.ByteBuf)6 ExperimenterIdCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder)5 ExperimenterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder)5 ExperimenterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput)5 ExperimenterInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder)5 ArrayList (java.util.ArrayList)4 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)4 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)3 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)3 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)3 MatchEntrySerializerKey (org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey)2 MultipartRequestInputFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory)2 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)2 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)2 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)2 BigInteger (java.math.BigInteger)1