Search in sources :

Example 1 with MultipartRequestInputFactory

use of org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory in project openflowplugin by opendaylight.

the class MessageFactoryInitializer method registerMessageSerializers.

/**
 * Registers message serializers into provided registry.
 * @param serializerRegistry registry to be initialized with message serializers
 */
public static void registerMessageSerializers(SerializerRegistry serializerRegistry) {
    CommonMessageRegistryHelper registryHelper;
    // register OF v1.0 message serializers
    registryHelper = new CommonMessageRegistryHelper(EncodeConstants.OF10_VERSION_ID, serializerRegistry);
    registryHelper.registerSerializer(BarrierInput.class, new OF10BarrierInputMessageFactory());
    registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory());
    registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory());
    registryHelper.registerSerializer(ExperimenterInput.class, new VendorInputMessageFactory());
    registryHelper.registerSerializer(FlowModInput.class, new OF10FlowModInputMessageFactory());
    registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory());
    registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory());
    registryHelper.registerSerializer(GetQueueConfigInput.class, new OF10QueueGetConfigInputMessageFactory());
    registryHelper.registerSerializer(HelloInput.class, new OF10HelloInputMessageFactory());
    registryHelper.registerSerializer(MultipartRequestInput.class, new OF10StatsRequestInputFactory());
    registryHelper.registerSerializer(PacketOutInput.class, new OF10PacketOutInputMessageFactory());
    registryHelper.registerSerializer(PortModInput.class, new OF10PortModInputMessageFactory());
    registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory());
    // register OF v1.3 message serializers
    registryHelper = new CommonMessageRegistryHelper(EncodeConstants.OF13_VERSION_ID, serializerRegistry);
    registryHelper.registerSerializer(BarrierInput.class, new BarrierInputMessageFactory());
    registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory());
    registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory());
    registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory());
    registryHelper.registerSerializer(FlowModInput.class, new FlowModInputMessageFactory());
    registryHelper.registerSerializer(GetAsyncInput.class, new GetAsyncRequestMessageFactory());
    registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory());
    registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory());
    registryHelper.registerSerializer(GetQueueConfigInput.class, new GetQueueConfigInputMessageFactory());
    registryHelper.registerSerializer(GroupModInput.class, new GroupModInputMessageFactory(serializerRegistry.isGroupAddModEnabled()));
    registryHelper.registerSerializer(HelloInput.class, new HelloInputMessageFactory());
    registryHelper.registerSerializer(MeterModInput.class, new MeterModInputMessageFactory());
    registryHelper.registerSerializer(MultipartRequestInput.class, new MultipartRequestInputFactory());
    registryHelper.registerSerializer(PacketOutInput.class, new PacketOutInputMessageFactory());
    registryHelper.registerSerializer(PortModInput.class, new PortModInputMessageFactory());
    registryHelper.registerSerializer(RoleRequestInput.class, new RoleRequestInputMessageFactory());
    registryHelper.registerSerializer(SetAsyncInput.class, new SetAsyncInputMessageFactory());
    registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory());
    registryHelper.registerSerializer(TableModInput.class, new TableModInputMessageFactory());
}
Also used : BarrierInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.BarrierInputMessageFactory) OF10BarrierInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10BarrierInputMessageFactory) CommonMessageRegistryHelper(org.opendaylight.openflowjava.protocol.impl.util.CommonMessageRegistryHelper) ExperimenterInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.ExperimenterInputMessageFactory) OF10HelloInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10HelloInputMessageFactory) HelloInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.HelloInputMessageFactory) OF10QueueGetConfigInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10QueueGetConfigInputMessageFactory) GetConfigInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetConfigInputMessageFactory) OF10StatsRequestInputFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory) GetAsyncRequestMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetAsyncRequestMessageFactory) PacketOutInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.PacketOutInputMessageFactory) OF10PacketOutInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PacketOutInputMessageFactory) OF10PortModInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PortModInputMessageFactory) VendorInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.VendorInputMessageFactory) GetFeaturesInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetFeaturesInputMessageFactory) OF10PacketOutInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PacketOutInputMessageFactory) GroupModInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.GroupModInputMessageFactory) SetConfigMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetConfigMessageFactory) OF10BarrierInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10BarrierInputMessageFactory) GetQueueConfigInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetQueueConfigInputMessageFactory) MultipartRequestInputFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory) EchoReplyInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoReplyInputMessageFactory) EchoInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoInputMessageFactory) OF10QueueGetConfigInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10QueueGetConfigInputMessageFactory) PortModInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.PortModInputMessageFactory) OF10PortModInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10PortModInputMessageFactory) RoleRequestInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.RoleRequestInputMessageFactory) OF10HelloInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10HelloInputMessageFactory) OF10FlowModInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FlowModInputMessageFactory) TableModInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.TableModInputMessageFactory) OF10FlowModInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FlowModInputMessageFactory) FlowModInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.FlowModInputMessageFactory) MeterModInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.MeterModInputMessageFactory) SetAsyncInputMessageFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.SetAsyncInputMessageFactory)

Example 2 with MultipartRequestInputFactory

use of org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory in project openflowplugin by opendaylight.

the class MultipartRequestTableFeaturesTest method testMultipartRequestTableFeaturesExperimenter.

/**
 * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
 */
@Test
public void testMultipartRequestTableFeaturesExperimenter() throws Exception {
    MultipartRequestInputFactory factory = new MultipartRequestInputFactory();
    factory.injectSerializerRegistry(mockRegistry);
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setType(MultipartType.forValue(12));
    builder.setFlags(new MultipartRequestFlags(true));
    TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
    tableFeaturesBuilder.setTableId((short) 8);
    tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
    tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }));
    tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }));
    tableFeaturesBuilder.setConfig(new TableConfig(true));
    tableFeaturesBuilder.setMaxEntries(65L);
    TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER);
    ExperimenterIdTableFeaturePropertyBuilder expBuilder = new ExperimenterIdTableFeaturePropertyBuilder();
    expBuilder.setExperimenter(new ExperimenterId(42L));
    propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build());
    List<TableFeatureProperties> properties = new ArrayList<>();
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS);
    expBuilder = new ExperimenterIdTableFeaturePropertyBuilder();
    expBuilder.setExperimenter(new ExperimenterId(43L));
    propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build());
    properties.add(propBuilder.build());
    tableFeaturesBuilder.setTableFeatureProperties(properties);
    List<TableFeatures> tableFeaturesList = new ArrayList<>();
    tableFeaturesList.add(tableFeaturesBuilder.build());
    MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder();
    featuresBuilder.setTableFeatures(tableFeaturesList);
    MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
    caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, (byte) 18, 80);
    Assert.assertEquals("Wrong type", 12, out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort());
    out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
    Assert.assertEquals("Wrong length", 64, out.readUnsignedShort());
    Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte());
    out.skipBytes(5);
    Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(out, 32));
    byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    out.readBytes(metadataMatch);
    Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, metadataMatch);
    byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    out.readBytes(metadataWrite);
    Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, metadataWrite);
    Assert.assertEquals("Wrong config", 8, out.readUnsignedInt());
    Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt());
    Mockito.verify(serializer, Mockito.times(2)).serialize(Matchers.any(TableFeatureProperties.class), Matchers.any(ByteBuf.class));
}
Also used : ExperimenterIdTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdTableFeaturePropertyBuilder) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) ArrayList(java.util.ArrayList) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder) MultipartRequestTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder) ByteBuf(io.netty.buffer.ByteBuf) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) MultipartRequestInputFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory) MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder) MultipartRequestTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder) TableFeaturePropertiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures) BigInteger(java.math.BigInteger) TableConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) MultipartRequestInputFactoryTest(org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest) Test(org.junit.Test)

Example 3 with MultipartRequestInputFactory

use of org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory in project openflowplugin by opendaylight.

the class MultipartRequestExperimenterTest method testExperimenter.

/**
 * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization.
 */
@Test
public void testExperimenter() throws Exception {
    Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(serializer);
    MultipartRequestInputFactory multipartFactory = new MultipartRequestInputFactory();
    multipartFactory.injectSerializerRegistry(mockRegistry);
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_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.checkHeaderV13(out, (byte) 18, 24);
    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) 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) MultipartRequestInputFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Aggregations

MultipartRequestInputFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory)3 ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)2 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)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 ArrayList (java.util.ArrayList)1 BarrierInputMessageFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.BarrierInputMessageFactory)1 EchoInputMessageFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoInputMessageFactory)1 EchoReplyInputMessageFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.EchoReplyInputMessageFactory)1 ExperimenterInputMessageFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.ExperimenterInputMessageFactory)1 FlowModInputMessageFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.FlowModInputMessageFactory)1 GetAsyncRequestMessageFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetAsyncRequestMessageFactory)1 GetConfigInputMessageFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetConfigInputMessageFactory)1 GetFeaturesInputMessageFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetFeaturesInputMessageFactory)1 GetQueueConfigInputMessageFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.GetQueueConfigInputMessageFactory)1 GroupModInputMessageFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.GroupModInputMessageFactory)1 HelloInputMessageFactory (org.opendaylight.openflowjava.protocol.impl.serialization.factories.HelloInputMessageFactory)1