Search in sources :

Example 6 with FlowMods

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.learn.grouping.nx.learn.FlowMods 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 7 with FlowMods

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.learn.grouping.nx.learn.FlowMods in project openflowplugin by opendaylight.

the class LearnCodecUtil method buildFlowModSpecs.

static synchronized void buildFlowModSpecs(NxActionLearnBuilder nxActionLearnBuilder, ByteBuf message, short messageLength) {
    LearnCodecUtil.length = messageLength;
    List<FlowMods> flowModeList = new ArrayList<>();
    while (LearnCodecUtil.length > 0) {
        FlowMods flowMod = readFlowMod(message);
        if (flowMod != null) {
            flowModeList.add(flowMod);
        } else {
            LOG.trace("skipping padding bytes");
        }
    }
    if (LearnCodecUtil.length != 0) {
        LOG.error("Learn Codec read " + Math.abs(messageLength) + " bytes more than needed from stream. Packet might be corrupted");
    }
    nxActionLearnBuilder.setFlowMods(flowModeList);
}
Also used : FlowMods(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.nx.action.learn.FlowMods) ArrayList(java.util.ArrayList)

Example 8 with FlowMods

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.learn.grouping.nx.learn.FlowMods in project openflowplugin by opendaylight.

the class LearnCodecTest method createFlowMods.

private List<FlowMods> createFlowMods() {
    final List<FlowMods> flowMods = new ArrayList<>();
    // length = 14
    final FlowModsBuilder flowMod = new FlowModsBuilder();
    FlowModAddMatchFromFieldBuilder spec = new FlowModAddMatchFromFieldBuilder();
    spec.setFlowModNumBits(48);
    spec.setSrcField((long) 9);
    spec.setSrcOfs(10);
    spec.setDstField((long) 11);
    spec.setDstOfs(12);
    FlowModAddMatchFromFieldCaseBuilder caseBuilder = new FlowModAddMatchFromFieldCaseBuilder();
    caseBuilder.setFlowModAddMatchFromField(spec.build());
    flowMod.setFlowModSpec(caseBuilder.build());
    flowMods.add(flowMod.build());
    // length = 14
    final FlowModsBuilder flowMod2 = new FlowModsBuilder();
    FlowModCopyFieldIntoFieldBuilder spec2 = new FlowModCopyFieldIntoFieldBuilder();
    spec2.setFlowModNumBits(48);
    spec2.setSrcField((long) 9);
    spec2.setSrcOfs(10);
    spec2.setDstField((long) 11);
    spec2.setDstOfs(12);
    FlowModCopyFieldIntoFieldCaseBuilder caseBuilder2 = new FlowModCopyFieldIntoFieldCaseBuilder();
    caseBuilder2.setFlowModCopyFieldIntoField(spec2.build());
    flowMod2.setFlowModSpec(caseBuilder2.build());
    flowMods.add(flowMod2.build());
    // length = 10
    final FlowModsBuilder flowMod3 = new FlowModsBuilder();
    FlowModCopyValueIntoFieldBuilder spec3 = new FlowModCopyValueIntoFieldBuilder();
    spec3.setFlowModNumBits(48);
    spec3.setValue(9);
    spec3.setDstField((long) 10);
    spec3.setDstOfs(11);
    FlowModCopyValueIntoFieldCaseBuilder caseBuilder3 = new FlowModCopyValueIntoFieldCaseBuilder();
    caseBuilder3.setFlowModCopyValueIntoField(spec3.build());
    flowMod3.setFlowModSpec(caseBuilder3.build());
    flowMods.add(flowMod3.build());
    // length = 10
    final FlowModsBuilder flowMod4 = new FlowModsBuilder();
    FlowModAddMatchFromValueBuilder spec4 = new FlowModAddMatchFromValueBuilder();
    spec4.setFlowModNumBits(48);
    spec4.setValue(9);
    spec4.setSrcField((long) 10);
    spec4.setSrcOfs(11);
    FlowModAddMatchFromValueCaseBuilder caseBuilder4 = new FlowModAddMatchFromValueCaseBuilder();
    caseBuilder4.setFlowModAddMatchFromValue(spec4.build());
    flowMod4.setFlowModSpec(caseBuilder4.build());
    flowMods.add(flowMod4.build());
    // length = 8
    final FlowModsBuilder flowMod5 = new FlowModsBuilder();
    FlowModOutputToPortBuilder spec5 = new FlowModOutputToPortBuilder();
    spec5.setFlowModNumBits(48);
    spec5.setSrcField((long) 9);
    spec5.setSrcOfs(10);
    FlowModOutputToPortCaseBuilder caseBuilder5 = new FlowModOutputToPortCaseBuilder();
    caseBuilder5.setFlowModOutputToPort(spec5.build());
    flowMod5.setFlowModSpec(caseBuilder5.build());
    flowMods.add(flowMod5.build());
    return flowMods;
}
Also used : FlowModAddMatchFromFieldCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModAddMatchFromFieldCaseBuilder) FlowModCopyValueIntoFieldBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.copy.value.into.field._case.FlowModCopyValueIntoFieldBuilder) FlowModOutputToPortCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModOutputToPortCaseBuilder) FlowModCopyFieldIntoFieldBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.copy.field.into.field._case.FlowModCopyFieldIntoFieldBuilder) FlowModCopyFieldIntoFieldCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModCopyFieldIntoFieldCaseBuilder) FlowModOutputToPortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.output.to.port._case.FlowModOutputToPortBuilder) ArrayList(java.util.ArrayList) FlowModsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.nx.action.learn.FlowModsBuilder) FlowModAddMatchFromValueCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModAddMatchFromValueCaseBuilder) FlowMods(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.nx.action.learn.FlowMods) FlowModAddMatchFromFieldBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.add.match.from.field._case.FlowModAddMatchFromFieldBuilder) FlowModAddMatchFromValueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.add.match.from.value._case.FlowModAddMatchFromValueBuilder) FlowModCopyValueIntoFieldCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModCopyValueIntoFieldCaseBuilder)

Example 9 with FlowMods

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.learn.grouping.nx.learn.FlowMods in project openflowplugin by opendaylight.

the class LearnCodecUtil method readFlowToPort.

private static FlowMods readFlowToPort(ByteBuf message, short numBits) {
    FlowModOutputToPortBuilder builder = new FlowModOutputToPortBuilder();
    builder.setSrcField((long) message.readInt());
    builder.setSrcOfs((int) message.readShort());
    builder.setFlowModNumBits((int) numBits);
    length -= TO_PORT_LENGTH - EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
    FlowModsBuilder flowModsBuilder = new FlowModsBuilder();
    FlowModOutputToPortCaseBuilder caseBuilder = new FlowModOutputToPortCaseBuilder();
    caseBuilder.setFlowModOutputToPort(builder.build());
    flowModsBuilder.setFlowModSpec(caseBuilder.build());
    return flowModsBuilder.build();
}
Also used : FlowModOutputToPortCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModOutputToPortCaseBuilder) FlowModOutputToPortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.output.to.port._case.FlowModOutputToPortBuilder) FlowModsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.nx.action.learn.FlowModsBuilder)

Example 10 with FlowMods

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.learn.grouping.nx.learn.FlowMods in project openflowplugin by opendaylight.

the class LearnCodecUtil method readFlowModAddMatchFromField.

private static FlowMods readFlowModAddMatchFromField(ByteBuf message, short numBits) {
    FlowModAddMatchFromFieldBuilder builder = new FlowModAddMatchFromFieldBuilder();
    builder.setSrcField((long) message.readInt());
    builder.setSrcOfs((int) message.readShort());
    builder.setDstField((long) message.readInt());
    builder.setDstOfs((int) message.readShort());
    builder.setFlowModNumBits((int) numBits);
    length -= FROM_FIELD_LENGTH - EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
    FlowModsBuilder flowModsBuilder = new FlowModsBuilder();
    FlowModAddMatchFromFieldCaseBuilder caseBuilder = new FlowModAddMatchFromFieldCaseBuilder();
    caseBuilder.setFlowModAddMatchFromField(builder.build());
    flowModsBuilder.setFlowModSpec(caseBuilder.build());
    return flowModsBuilder.build();
}
Also used : FlowModAddMatchFromFieldCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModAddMatchFromFieldCaseBuilder) FlowModAddMatchFromFieldBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.add.match.from.field._case.FlowModAddMatchFromFieldBuilder) FlowModsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.nx.action.learn.FlowModsBuilder)

Aggregations

FlowModsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.nx.action.learn.FlowModsBuilder)6 ArrayList (java.util.ArrayList)4 FlowMods (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.learn.grouping.nx.action.learn.FlowMods)3 FlowMods (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.learn.grouping.nx.learn.FlowMods)3 FlowModAddMatchFromFieldCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModAddMatchFromFieldCaseBuilder)2 FlowModAddMatchFromValueCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModAddMatchFromValueCaseBuilder)2 FlowModCopyFieldIntoFieldCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModCopyFieldIntoFieldCaseBuilder)2 FlowModCopyValueIntoFieldCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModCopyValueIntoFieldCaseBuilder)2 FlowModOutputToPortCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.FlowModOutputToPortCaseBuilder)2 FlowModAddMatchFromFieldBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.add.match.from.field._case.FlowModAddMatchFromFieldBuilder)2 FlowModAddMatchFromValueBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.add.match.from.value._case.FlowModAddMatchFromValueBuilder)2 FlowModCopyFieldIntoFieldBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.copy.field.into.field._case.FlowModCopyFieldIntoFieldBuilder)2 FlowModCopyValueIntoFieldBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.copy.value.into.field._case.FlowModCopyValueIntoFieldBuilder)2 FlowModOutputToPortBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.flow.mod.spec.flow.mod.spec.flow.mod.output.to.port._case.FlowModOutputToPortBuilder)2 FlowModsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.learn.grouping.nx.learn.FlowModsBuilder)2 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