Search in sources :

Example 1 with ActionLearn

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionLearn in project openflowplugin by opendaylight.

the class LearnConvertor method convert.

@Override
public org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action convert(final Action input, final ActionPath path) {
    NxActionLearn action = ((ActionLearn) input.getActionChoice()).getNxActionLearn();
    NxLearnBuilder builder = new NxLearnBuilder();
    LearnConvertorUtil.convertUp(action, builder);
    return resolveAction(builder.build(), path);
}
Also used : NxLearnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.learn.grouping.NxLearnBuilder) ActionLearn(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionLearn) NxActionLearn(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.NxActionLearn) NxActionLearn(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.NxActionLearn)

Example 2 with ActionLearn

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionLearn in project openflowplugin by opendaylight.

the class LearnCodecUtil method serializeFlowMods.

static void serializeFlowMods(final ByteBuf outBuffer, ActionLearn action) {
    if (action.getNxActionLearn().getFlowMods() != null) {
        for (FlowMods flowMod : action.getNxActionLearn().getFlowMods()) {
            if (flowMod.getFlowModSpec() instanceof FlowModAddMatchFromFieldCase) {
                FlowModAddMatchFromField flowModSpecFromField = ((FlowModAddMatchFromFieldCase) flowMod.getFlowModSpec()).getFlowModAddMatchFromField();
                toFlowModSpecHeader(flowModSpecFromField, outBuffer);
                outBuffer.writeInt(flowModSpecFromField.getSrcField().intValue());
                outBuffer.writeShort(flowModSpecFromField.getSrcOfs().shortValue());
                outBuffer.writeInt(flowModSpecFromField.getDstField().intValue());
                outBuffer.writeShort(flowModSpecFromField.getDstOfs().shortValue());
            } else if (flowMod.getFlowModSpec() instanceof FlowModAddMatchFromValueCase) {
                FlowModAddMatchFromValue flowModSpec = ((FlowModAddMatchFromValueCase) flowMod.getFlowModSpec()).getFlowModAddMatchFromValue();
                toFlowModSpecHeader(flowModSpec, outBuffer);
                outBuffer.writeShort(flowModSpec.getValue().shortValue());
                outBuffer.writeInt(flowModSpec.getSrcField().intValue());
                outBuffer.writeShort(flowModSpec.getSrcOfs().shortValue());
            } else if (flowMod.getFlowModSpec() instanceof FlowModCopyFieldIntoFieldCase) {
                FlowModCopyFieldIntoField flowModSpec = ((FlowModCopyFieldIntoFieldCase) flowMod.getFlowModSpec()).getFlowModCopyFieldIntoField();
                toFlowModSpecHeader(flowModSpec, outBuffer);
                outBuffer.writeInt(flowModSpec.getSrcField().intValue());
                outBuffer.writeShort(flowModSpec.getSrcOfs().shortValue());
                outBuffer.writeInt(flowModSpec.getDstField().intValue());
                outBuffer.writeShort(flowModSpec.getDstOfs().shortValue());
            } else if (flowMod.getFlowModSpec() instanceof FlowModCopyValueIntoFieldCase) {
                FlowModCopyValueIntoField flowModSpec = ((FlowModCopyValueIntoFieldCase) flowMod.getFlowModSpec()).getFlowModCopyValueIntoField();
                toFlowModSpecHeader(flowModSpec, outBuffer);
                outBuffer.writeShort(flowModSpec.getValue().shortValue());
                outBuffer.writeInt(flowModSpec.getDstField().intValue());
                outBuffer.writeShort(flowModSpec.getDstOfs().shortValue());
            } else if (flowMod.getFlowModSpec() instanceof FlowModOutputToPortCase) {
                FlowModOutputToPort flowModSpec = ((FlowModOutputToPortCase) flowMod.getFlowModSpec()).getFlowModOutputToPort();
                toFlowModSpecHeader(flowModSpec, outBuffer);
                outBuffer.writeInt(flowModSpec.getSrcField().intValue());
                outBuffer.writeShort(flowModSpec.getSrcOfs().shortValue());
            }
        }
    }
}
Also used : FlowModAddMatchFromFieldCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModAddMatchFromFieldCase) FlowModAddMatchFromField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.add.match.from.field._case.FlowModAddMatchFromField) FlowMods(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.nx.action.learn.FlowMods) FlowModOutputToPortCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModOutputToPortCase) FlowModAddMatchFromValueCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModAddMatchFromValueCase) FlowModOutputToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.output.to.port._case.FlowModOutputToPort) FlowModCopyFieldIntoFieldCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModCopyFieldIntoFieldCase) FlowModCopyValueIntoField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.copy.value.into.field._case.FlowModCopyValueIntoField) FlowModAddMatchFromValue(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.add.match.from.value._case.FlowModAddMatchFromValue) FlowModCopyFieldIntoField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.copy.field.into.field._case.FlowModCopyFieldIntoField) FlowModCopyValueIntoFieldCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModCopyValueIntoFieldCase)

Example 3 with ActionLearn

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionLearn in project openflowplugin by opendaylight.

the class LearnCodecTest method deserializeTest.

@Test
public void deserializeTest() {
    createBufer(buffer);
    action = learnCodec.deserialize(buffer);
    ActionLearn result = (ActionLearn) action.getActionChoice();
    Action act = createAction();
    ActionLearn expResult = (ActionLearn) act.getActionChoice();
    Assert.assertEquals(expResult, result);
}
Also used : ActionLearn(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionLearn) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) Test(org.junit.Test)

Example 4 with ActionLearn

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionLearn in project openflowplugin by opendaylight.

the class LearnCodec method serialize.

@Override
public void serialize(final Action input, final ByteBuf outBuffer) {
    ActionLearn action = (ActionLearn) input.getActionChoice();
    int length = LearnCodecUtil.calcLength(action);
    int lengthMod = length % MUL_LENGTH;
    if (lengthMod != 0) {
        lengthMod = MUL_LENGTH - lengthMod;
    }
    serializeHeader(length + lengthMod, NXAST_LEARN_SUBTYPE, outBuffer);
    LearnCodecUtil.serializeLearnHeader(outBuffer, action);
    LearnCodecUtil.serializeFlowMods(outBuffer, action);
    // pad with zeros for the length to be multiplication by 8
    if (lengthMod != 0) {
        outBuffer.writeZero(lengthMod);
    }
}
Also used : ActionLearn(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionLearn)

Aggregations

ActionLearn (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionLearn)3 Test (org.junit.Test)1 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)1 FlowModAddMatchFromFieldCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModAddMatchFromFieldCase)1 FlowModAddMatchFromValueCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModAddMatchFromValueCase)1 FlowModCopyFieldIntoFieldCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModCopyFieldIntoFieldCase)1 FlowModCopyValueIntoFieldCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModCopyValueIntoFieldCase)1 FlowModOutputToPortCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModOutputToPortCase)1 FlowModAddMatchFromField (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.add.match.from.field._case.FlowModAddMatchFromField)1 FlowModAddMatchFromValue (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.add.match.from.value._case.FlowModAddMatchFromValue)1 FlowModCopyFieldIntoField (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.copy.field.into.field._case.FlowModCopyFieldIntoField)1 FlowModCopyValueIntoField (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.copy.value.into.field._case.FlowModCopyValueIntoField)1 FlowModOutputToPort (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.output.to.port._case.FlowModOutputToPort)1 NxActionLearn (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.NxActionLearn)1 FlowMods (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.nx.action.learn.FlowMods)1 NxLearnBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.learn.grouping.NxLearnBuilder)1