Search in sources :

Example 1 with ExperimenterIdCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder in project openflowplugin by opendaylight.

the class OnfOxmTcpFlagsDeserializer method deserialize.

@Override
public MatchEntry deserialize(ByteBuf input) {
    MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(deserializeHeader(input));
    ExperimenterIdCaseBuilder expCaseBuilder = createExperimenterIdCase(matchEntryBuilder, input);
    addTcpFlagsAugmentation(input, expCaseBuilder, matchEntryBuilder.isHasMask());
    matchEntryBuilder.setMatchEntryValue(expCaseBuilder.build());
    return matchEntryBuilder.build();
}
Also used : MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) ExperimenterIdCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder)

Example 2 with ExperimenterIdCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder in project openflowplugin by opendaylight.

the class OF13MatchSerializerTest method testSerializeExperimenterMatchEntry.

/**
 * Test serialize experimenter match entry - with no experimenter
 * match entry serializer registered.
 */
@Test(expected = IllegalStateException.class)
public void testSerializeExperimenterMatchEntry() {
    final List<MatchEntry> entries = new ArrayList<>();
    MatchEntryBuilder builder = new MatchEntryBuilder();
    builder.setOxmClass(ExperimenterClass.class);
    builder.setOxmMatchField(OxmMatchFieldClass.class);
    builder.setHasMask(true);
    ExperimenterIdCaseBuilder caseBuilder = new ExperimenterIdCaseBuilder();
    ExperimenterBuilder expBuilder = new ExperimenterBuilder();
    expBuilder.setExperimenter(new ExperimenterId(42L));
    caseBuilder.setExperimenter(expBuilder.build());
    builder.setMatchEntryValue(caseBuilder.build());
    entries.add(builder.build());
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    ((OF13MatchSerializer) matchSerializer).serializeMatchEntries(entries, out);
}
Also used : MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) ExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) ExperimenterIdCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder) Test(org.junit.Test)

Example 3 with ExperimenterIdCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder in project openflowplugin by opendaylight.

the class OF13SetFieldActionSerializerTest method test.

/**
 * Test identify ExperimenterClass serializer.
 */
@Test
public void test() {
    OF13SetFieldActionSerializer ser = new OF13SetFieldActionSerializer();
    ser.injectSerializerRegistry(registry);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder = new ActionBuilder();
    long experimenterId = 12L;
    ExperimenterIdCaseBuilder expCaseBuilder = new ExperimenterIdCaseBuilder();
    ExperimenterBuilder expBuilder = new ExperimenterBuilder();
    expBuilder.setExperimenter(new ExperimenterId(experimenterId));
    expCaseBuilder.setExperimenter(expBuilder.build());
    MatchEntryBuilder meb = new MatchEntryBuilder();
    meb.setOxmClass(ExperimenterClass.class);
    meb.setOxmMatchField(OxmMatchFieldClass.class);
    meb.setMatchEntryValue(expCaseBuilder.build());
    List<MatchEntry> matchEntry = new ArrayList<>();
    MatchEntry me = meb.build();
    matchEntry.add(me);
    SetFieldCaseBuilder caseBuilder = new SetFieldCaseBuilder();
    SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
    setFieldBuilder.setMatchEntry(matchEntry);
    caseBuilder.setSetFieldAction(setFieldBuilder.build());
    actionBuilder.setActionChoice(caseBuilder.build());
    MatchEntrySerializerKey<?, ?> key = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, ExperimenterClass.class, OxmMatchFieldClass.class);
    key.setExperimenterId(experimenterId);
    registry.registerSerializer(key, serializerMock);
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    ser.serialize(actionBuilder.build(), out);
    Mockito.verify(serializerMock, Mockito.times(1)).serialize((MatchEntry) Mockito.anyObject(), (ByteBuf) Mockito.anyObject());
    int lenght = out.readableBytes();
    Assert.assertEquals("Wrong - bad field code", ActionConstants.SET_FIELD_CODE, out.readUnsignedShort());
    Assert.assertEquals("Wrong - bad lenght", lenght, out.readUnsignedShort());
}
Also used : SetFieldCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) SetFieldActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) ArrayList(java.util.ArrayList) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) ByteBuf(io.netty.buffer.ByteBuf) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) ExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder) SetFieldActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder) MatchEntrySerializerKey(org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey) ExperimenterIdCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder) Test(org.junit.Test)

Example 4 with ExperimenterIdCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder in project openflowplugin by opendaylight.

the class ActionExtensionHelperTest method testProcessAlienAction.

@Test
public void testProcessAlienAction() {
    ActionBuilder actionBuilder = new ActionBuilder();
    ExperimenterIdCaseBuilder experimenterIdCaseBuilder = new ExperimenterIdCaseBuilder();
    ExperimenterBuilder experimenterBuilder = new ExperimenterBuilder();
    experimenterBuilder.setExperimenter(new ExperimenterId(42L));
    experimenterIdCaseBuilder.setExperimenter(experimenterBuilder.build());
    actionBuilder.setActionChoice(experimenterIdCaseBuilder.build());
    Action action = ActionExtensionHelper.processAlienAction(actionBuilder.build(), OpenflowVersion.OF13, ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
    assertNotNull(action);
    assertEquals(MockAction.class, action.getImplementedInterface());
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) ExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.experimenter.id._case.ExperimenterBuilder) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) ExperimenterIdCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCaseBuilder) Test(org.junit.Test)

Example 5 with ExperimenterIdCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder in project openflowplugin by opendaylight.

the class OnfOxmTcpFlagsDeserializer method addTcpFlagsAugmentation.

private static void addTcpFlagsAugmentation(ByteBuf input, ExperimenterIdCaseBuilder expCaseBuilder, boolean hasMask) {
    TcpFlagsContainerBuilder flagsContainerBuilder = new TcpFlagsContainerBuilder();
    TcpFlagsBuilder flagsBuilder = new TcpFlagsBuilder();
    flagsBuilder.setFlags(input.readUnsignedShort());
    if (hasMask) {
        byte[] mask = new byte[EncodeConstants.SIZE_OF_SHORT_IN_BYTES];
        input.readBytes(mask);
        flagsBuilder.setMask(mask);
    }
    flagsContainerBuilder.setTcpFlags(flagsBuilder.build());
    expCaseBuilder.addAugmentation(TcpFlagsContainer.class, flagsContainerBuilder.build());
}
Also used : TcpFlagsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlagsBuilder) TcpFlagsContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainerBuilder)

Aggregations

ExperimenterIdCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder)6 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)6 ExperimenterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder)5 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)5 Test (org.junit.Test)4 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)3 ByteBuf (io.netty.buffer.ByteBuf)2 ArrayList (java.util.ArrayList)2 MatchEntrySerializerKey (org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey)2 TcpFlagsContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlagsContainerBuilder)2 TcpFlagsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.oxm.container.match.entry.value.experimenter.id._case.TcpFlagsBuilder)2 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)2 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action)1 ExperimenterIdCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCaseBuilder)1 ExperimenterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.experimenter.id._case.ExperimenterBuilder)1 SetFieldCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder)1 SetFieldActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder)1