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);
}
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());
}
}
}
}
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);
}
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);
}
}
Aggregations