Search in sources :

Example 6 with GotoTableCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder in project openflowplugin by opendaylight.

the class FlowInstructionResponseConvertor method convert.

@Override
public Instructions convert(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction> source, VersionConvertorData data) {
    InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
    List<Instruction> salInstructionList = new ArrayList<>();
    int instructionTreeNodekey = 0;
    org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction salInstruction;
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction switchInst : source) {
        if (switchInst.getInstructionChoice() instanceof ApplyActionsCase) {
            ApplyActionsCase actionsInstruction = (ApplyActionsCase) switchInst.getInstructionChoice();
            ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
            ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
            final ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(data.getVersion());
            actionResponseConvertorData.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
            final Optional<List<Action>> actions = getConvertorExecutor().convert(actionsInstruction.getApplyActions().getAction(), actionResponseConvertorData);
            applyActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(actions.orElse(Collections.emptyList())));
            applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
            salInstruction = applyActionsCaseBuilder.build();
        } else if (switchInst.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase) {
            ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
            salInstruction = clearActionsCaseBuilder.build();
        } else if (switchInst.getInstructionChoice() instanceof GotoTableCase) {
            GotoTableCase gotoTableCase = (GotoTableCase) switchInst.getInstructionChoice();
            GoToTableCaseBuilder goToTableCaseBuilder = new GoToTableCaseBuilder();
            GoToTableBuilder goToTableBuilder = new GoToTableBuilder();
            goToTableBuilder.setTableId(gotoTableCase.getGotoTable().getTableId());
            goToTableCaseBuilder.setGoToTable(goToTableBuilder.build());
            salInstruction = goToTableCaseBuilder.build();
        } else if (switchInst.getInstructionChoice() instanceof MeterCase) {
            MeterCase meterIdInstruction = (MeterCase) switchInst.getInstructionChoice();
            MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
            MeterBuilder meterBuilder = new MeterBuilder();
            meterBuilder.setMeterId(new MeterId(meterIdInstruction.getMeter().getMeterId()));
            meterCaseBuilder.setMeter(meterBuilder.build());
            salInstruction = meterCaseBuilder.build();
        } else if (switchInst.getInstructionChoice() instanceof WriteActionsCase) {
            WriteActionsCase writeActionsCase = (WriteActionsCase) switchInst.getInstructionChoice();
            WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
            WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
            final ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(data.getVersion());
            actionResponseConvertorData.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_WRITE_ACTIONS);
            final Optional<List<Action>> actions = getConvertorExecutor().convert(writeActionsCase.getWriteActions().getAction(), actionResponseConvertorData);
            writeActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(actions.orElse(Collections.emptyList())));
            writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
            salInstruction = writeActionsCaseBuilder.build();
        } else if (switchInst.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase) {
            org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase writeMetadataCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase) switchInst.getInstructionChoice();
            WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
            WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();
            writeMetadataBuilder.setMetadata(new BigInteger(OFConstants.SIGNUM_UNSIGNED, writeMetadataCase.getWriteMetadata().getMetadata()));
            writeMetadataBuilder.setMetadataMask(new BigInteger(OFConstants.SIGNUM_UNSIGNED, writeMetadataCase.getWriteMetadata().getMetadataMask()));
            writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build());
            salInstruction = writeMetadataCaseBuilder.build();
        } else {
            continue;
        }
        InstructionBuilder instBuilder = new InstructionBuilder();
        instBuilder.setInstruction(salInstruction);
        instBuilder.setKey(new InstructionKey(instructionTreeNodekey));
        instBuilder.setOrder(instructionTreeNodekey);
        instructionTreeNodekey++;
        salInstructionList.add(instBuilder.build());
    }
    instructionsBuilder.setInstruction(salInstructionList);
    return instructionsBuilder.build();
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder) InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) WriteMetadataCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder) MeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase) ArrayList(java.util.ArrayList) WriteActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase) InstructionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) WriteMetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) ArrayList(java.util.ArrayList) List(java.util.List) ClearActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder) GoToTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder) MeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder) GotoTableCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase) WriteActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActionsBuilder) WriteActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder) GoToTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder) BigInteger(java.math.BigInteger) ActionResponseConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData) ApplyActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase)

Example 7 with GotoTableCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder in project openflowplugin by opendaylight.

the class FlowModInputMessageFactoryTest method testFlowModInputMessageFactory.

/**
 * Testing of {@link FlowModInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testFlowModInputMessageFactory() throws Exception {
    FlowModInputBuilder builder = new FlowModInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x06, 0x00, 0x07, 0x01 };
    builder.setCookie(new BigInteger(1, cookie));
    byte[] cookieMask = new byte[] { (byte) 0xFF, 0x05, 0x00, 0x00, 0x09, 0x30, 0x00, 0x30 };
    builder.setCookieMask(new BigInteger(1, cookieMask));
    builder.setTableId(new TableId(65L));
    builder.setCommand(FlowModCommand.forValue(2));
    builder.setIdleTimeout(12);
    builder.setHardTimeout(0);
    builder.setPriority(126);
    builder.setBufferId(2L);
    builder.setOutPort(new PortNumber(4422L));
    builder.setOutGroup(98L);
    builder.setFlags(new FlowModFlags(true, false, true, false, true));
    MatchBuilder matchBuilder = new MatchBuilder();
    matchBuilder.setType(OxmMatchType.class);
    final List<MatchEntry> entries = new ArrayList<>();
    MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(InPhyPort.class);
    entriesBuilder.setHasMask(false);
    InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
    InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
    inPhyPortBuilder.setPortNumber(new PortNumber(42L));
    inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
    entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
    entries.add(entriesBuilder.build());
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(IpEcn.class);
    entriesBuilder.setHasMask(false);
    IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
    IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
    ipEcnBuilder.setEcn((short) 4);
    ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
    entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
    entries.add(entriesBuilder.build());
    matchBuilder.setMatchEntry(entries);
    builder.setMatch(matchBuilder.build());
    final List<Instruction> instructions = new ArrayList<>();
    InstructionBuilder insBuilder = new InstructionBuilder();
    GotoTableCaseBuilder goToCaseBuilder = new GotoTableCaseBuilder();
    GotoTableBuilder instructionBuilder = new GotoTableBuilder();
    instructionBuilder.setTableId((short) 43);
    goToCaseBuilder.setGotoTable(instructionBuilder.build());
    insBuilder.setInstructionChoice(goToCaseBuilder.build());
    instructions.add(insBuilder.build());
    WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
    WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
    metadataBuilder.setMetadata(cookie);
    metadataBuilder.setMetadataMask(cookieMask);
    metadataCaseBuilder.setWriteMetadata(metadataBuilder.build());
    insBuilder.setInstructionChoice(metadataCaseBuilder.build());
    instructions.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    final ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
    final ApplyActionsBuilder actionsBuilder = new ApplyActionsBuilder();
    final List<Action> actions = new ArrayList<>();
    final ActionBuilder actionBuilder = new ActionBuilder();
    OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
    OutputActionBuilder outputBuilder = new OutputActionBuilder();
    outputBuilder.setPort(new PortNumber(42L));
    outputBuilder.setMaxLength(52);
    caseBuilder.setOutputAction(outputBuilder.build());
    actionBuilder.setActionChoice(caseBuilder.build());
    actions.add(actionBuilder.build());
    actionsBuilder.setAction(actions);
    applyActionsCaseBuilder.setApplyActions(actionsBuilder.build());
    insBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
    instructions.add(insBuilder.build());
    builder.setInstruction(instructions);
    final FlowModInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    // simulate parent message
    out.writeInt(1);
    out.writeZero(2);
    out.writeShort(3);
    flowModFactory.serialize(message, out);
    // read parent message
    out.readInt();
    out.skipBytes(2);
    out.readShort();
    BufferHelper.checkHeaderV13(out, (byte) 14, 128);
    cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    out.readBytes(cookie);
    Assert.assertEquals("Wrong cookie", message.getCookie(), new BigInteger(1, cookie));
    cookieMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    out.readBytes(cookieMask);
    Assert.assertEquals("Wrong cookieMask", message.getCookieMask(), new BigInteger(1, cookieMask));
    Assert.assertEquals("Wrong tableId", message.getTableId().getValue().intValue(), out.readUnsignedByte());
    Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedByte());
    Assert.assertEquals("Wrong idleTimeOut", message.getIdleTimeout().intValue(), out.readShort());
    Assert.assertEquals("Wrong hardTimeOut", message.getHardTimeout().intValue(), out.readShort());
    Assert.assertEquals("Wrong priority", message.getPriority().intValue(), out.readUnsignedShort());
    Assert.assertEquals("Wrong bufferId", message.getBufferId().intValue(), out.readUnsignedInt());
    Assert.assertEquals("Wrong outPort", message.getOutPort().getValue().intValue(), out.readUnsignedInt());
    Assert.assertEquals("Wrong outGroup", message.getOutGroup().intValue(), out.readUnsignedInt());
    Assert.assertEquals("Wrong flags", message.getFlags(), createFlowModFlagsFromBitmap(out.readUnsignedShort()));
    out.skipBytes(PADDING_IN_FLOW_MOD_MESSAGE);
    Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort());
    out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    Assert.assertEquals("Wrong oxm class", 0x8000, out.readUnsignedShort());
    short fieldAndMask = out.readUnsignedByte();
    Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
    Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1);
    out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
    Assert.assertEquals("Wrong oxm value", 42, out.readUnsignedInt());
    Assert.assertEquals("Wrong oxm class", 0x8000, out.readUnsignedShort());
    fieldAndMask = out.readUnsignedByte();
    Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
    Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1);
    out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
    Assert.assertEquals("Wrong oxm value", 4, out.readUnsignedByte());
    out.skipBytes(7);
    Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort());
    out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    Assert.assertEquals("Wrong instruction value", 43, out.readUnsignedByte());
    out.skipBytes(3);
    Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort());
    out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    out.skipBytes(EncodeConstants.SIZE_OF_INT_IN_BYTES);
    byte[] cookieRead = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    out.readBytes(cookieRead);
    byte[] cookieMaskRead = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    out.readBytes(cookieMaskRead);
    Assert.assertArrayEquals("Wrong metadata", cookie, cookieRead);
    Assert.assertArrayEquals("Wrong metadata mask", cookieMask, cookieMaskRead);
    Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort());
    out.skipBytes(4);
    Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
    Assert.assertEquals("Wrong port", 42, out.readUnsignedInt());
    Assert.assertEquals("Wrong max-length", 52, out.readUnsignedShort());
    out.skipBytes(6);
    Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId) InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder) OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) WriteMetadataCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder) ArrayList(java.util.ArrayList) GotoTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction) ByteBuf(io.netty.buffer.ByteBuf) WriteMetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder) InPhyPortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) InPhyPortCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) IpEcnCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder) IpEcnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags) FlowModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder) FlowModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput) GotoTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder) BigInteger(java.math.BigInteger) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder) Test(org.junit.Test)

Example 8 with GotoTableCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder in project openflowplugin by opendaylight.

the class MultipartRequestTableFeaturesInputMessageFactoryTest method createInstructions.

public List<Instruction> createInstructions() {
    List<Instruction> instructions = new ArrayList<>();
    InstructionBuilder insBuilder = new InstructionBuilder();
    GotoTableCaseBuilder goToCaseBuilder = new GotoTableCaseBuilder();
    insBuilder.setInstructionChoice(goToCaseBuilder.build());
    instructions.add(insBuilder.build());
    WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
    insBuilder.setInstructionChoice(metadataCaseBuilder.build());
    instructions.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
    insBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
    instructions.add(insBuilder.build());
    return instructions;
}
Also used : InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder) WriteMetadataCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder) ArrayList(java.util.ArrayList) GotoTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction)

Example 9 with GotoTableCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method createFlowStats.

private static List<FlowStats> createFlowStats() {
    FlowStatsBuilder builder = new FlowStatsBuilder();
    builder.setTableId((short) 1);
    builder.setDurationSec(1L);
    builder.setDurationNsec(1L);
    builder.setPriority(1);
    builder.setIdleTimeout(1);
    builder.setHardTimeout(1);
    builder.setCookie(BigInteger.valueOf(1234L));
    builder.setPacketCount(BigInteger.valueOf(1234L));
    builder.setByteCount(BigInteger.valueOf(1234L));
    MatchBuilder matchBuilder = new MatchBuilder();
    matchBuilder.setType(OxmMatchType.class);
    final List<MatchEntry> entries = new ArrayList<>();
    MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(InPhyPort.class);
    entriesBuilder.setHasMask(false);
    InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
    InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
    inPhyPortBuilder.setPortNumber(new PortNumber(42L));
    inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
    entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
    entries.add(entriesBuilder.build());
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(IpEcn.class);
    entriesBuilder.setHasMask(false);
    IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
    IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
    ipEcnBuilder.setEcn((short) 4);
    ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
    entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
    entries.add(entriesBuilder.build());
    matchBuilder.setMatchEntry(entries);
    builder.setMatch(matchBuilder.build());
    final List<Instruction> instructions = new ArrayList<>();
    // Goto_table instruction
    InstructionBuilder builderInstruction = new InstructionBuilder();
    GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder();
    GotoTableBuilder instructionBuilder = new GotoTableBuilder();
    instructionBuilder.setTableId((short) 5);
    gotoCaseBuilder.setGotoTable(instructionBuilder.build());
    builderInstruction.setInstructionChoice(gotoCaseBuilder.build());
    instructions.add(builderInstruction.build());
    // Write_metadata instruction
    builderInstruction = new InstructionBuilder();
    WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
    WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
    metadataBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07"));
    metadataBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00"));
    metadataCaseBuilder.setWriteMetadata(metadataBuilder.build());
    builderInstruction.setInstructionChoice(metadataCaseBuilder.build());
    instructions.add(builderInstruction.build());
    // Clear_actions instruction
    builderInstruction = new InstructionBuilder();
    builderInstruction.setInstructionChoice(new ClearActionsCaseBuilder().build());
    instructions.add(builderInstruction.build());
    // Meter instruction
    builderInstruction = new InstructionBuilder();
    MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
    MeterBuilder meterBuilder = new MeterBuilder();
    meterBuilder.setMeterId(42L);
    meterCaseBuilder.setMeter(meterBuilder.build());
    builderInstruction.setInstructionChoice(meterCaseBuilder.build());
    instructions.add(builderInstruction.build());
    // Write_actions instruction
    builderInstruction = new InstructionBuilder();
    final WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
    final WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
    OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
    OutputActionBuilder outputBuilder = new OutputActionBuilder();
    outputBuilder.setPort(new PortNumber(45L));
    outputBuilder.setMaxLength(55);
    caseBuilder.setOutputAction(outputBuilder.build());
    ActionBuilder actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(caseBuilder.build());
    List<Action> actions = new ArrayList<>();
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    SetNwTtlCaseBuilder ttlCaseBuilder = new SetNwTtlCaseBuilder();
    SetNwTtlActionBuilder ttlActionBuilder = new SetNwTtlActionBuilder();
    ttlActionBuilder.setNwTtl((short) 64);
    ttlCaseBuilder.setSetNwTtlAction(ttlActionBuilder.build());
    actionBuilder.setActionChoice(ttlCaseBuilder.build());
    actions.add(actionBuilder.build());
    writeActionsBuilder.setAction(actions);
    writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
    builderInstruction.setInstructionChoice(writeActionsCaseBuilder.build());
    instructions.add(builderInstruction.build());
    // Apply_actions instruction
    builderInstruction = new InstructionBuilder();
    final ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
    final ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
    actions = new ArrayList<>();
    actionBuilder = new ActionBuilder();
    PushVlanCaseBuilder vlanCaseBuilder = new PushVlanCaseBuilder();
    PushVlanActionBuilder vlanBuilder = new PushVlanActionBuilder();
    vlanBuilder.setEthertype(new EtherType(new EtherType(14)));
    vlanCaseBuilder.setPushVlanAction(vlanBuilder.build());
    actionBuilder.setActionChoice(vlanCaseBuilder.build());
    actions.add(actionBuilder.build());
    actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
    actions.add(actionBuilder.build());
    applyActionsBuilder.setAction(actions);
    applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
    builderInstruction.setInstructionChoice(applyActionsCaseBuilder.build());
    instructions.add(builderInstruction.build());
    builder.setInstruction(instructions);
    List<FlowStats> list = new ArrayList<>();
    list.add(builder.build());
    return list;
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder) MultipartReplyMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeterBuilder) InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder) OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder) SetNwTtlCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) SetNwTtlActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) WriteMetadataCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder) PopPbbCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder) ArrayList(java.util.ArrayList) GotoTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder) EtherType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction) SetNwTtlActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder) WriteMetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder) InPhyPortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder) FlowStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats) FlowStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) InPhyPortCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) IpEcnCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder) ClearActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder) MultipartReplyMeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCaseBuilder) MeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder) WriteActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder) IpEcnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder) WriteActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder) PushVlanCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder) GotoTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder)

Example 10 with GotoTableCaseBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testMultipartRequestTableFeaturesMessageFactory.

@Test
public void testMultipartRequestTableFeaturesMessageFactory() throws Exception {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(12));
    final MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder();
    final MultipartReplyTableFeaturesBuilder featuresBuilder = new MultipartReplyTableFeaturesBuilder();
    final List<TableFeatures> tableFeaturesList = new ArrayList<>();
    TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
    tableFeaturesBuilder.setTableId((short) 8);
    tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
    tableFeaturesBuilder.setMetadataMatch(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 });
    tableFeaturesBuilder.setMetadataWrite(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.OFPTFPTNEXTTABLES);
    NextTableRelatedTableFeaturePropertyBuilder nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
    List<NextTableIds> nextIds = new ArrayList<>();
    nextIds.add(new NextTableIdsBuilder().setTableId((short) 1).build());
    nextIds.add(new NextTableIdsBuilder().setTableId((short) 2).build());
    nextPropBuilder.setNextTableIds(nextIds);
    propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());
    List<TableFeatureProperties> properties = new ArrayList<>();
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS);
    nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
    nextIds = new ArrayList<>();
    nextPropBuilder.setNextTableIds(nextIds);
    propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS);
    List<Instruction> insIds = new ArrayList<>();
    InstructionBuilder insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new WriteActionsCaseBuilder().build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build());
    insIds.add(insBuilder.build());
    InstructionRelatedTableFeaturePropertyBuilder insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
    insPropBuilder.setInstruction(insIds);
    propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS);
    insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
    insIds = new ArrayList<>();
    insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new WriteMetadataCaseBuilder().build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new ApplyActionsCaseBuilder().build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new MeterCaseBuilder().build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new ClearActionsCaseBuilder().build());
    insIds.add(insBuilder.build());
    insBuilder = new InstructionBuilder();
    insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build());
    insIds.add(insBuilder.build());
    insPropBuilder.setInstruction(insIds);
    propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
    properties.add(propBuilder.build());
    tableFeaturesBuilder.setTableFeatureProperties(properties);
    tableFeaturesList.add(tableFeaturesBuilder.build());
    tableFeaturesBuilder = new TableFeaturesBuilder();
    tableFeaturesBuilder.setTableId((short) 8);
    tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
    byte[] metadataMatch = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 };
    tableFeaturesBuilder.setMetadataMatch(metadataMatch);
    byte[] metadataWrite = new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 };
    tableFeaturesBuilder.setMetadataWrite(metadataWrite);
    tableFeaturesBuilder.setConfig(new TableConfig(true));
    tableFeaturesBuilder.setMaxEntries(67L);
    properties = new ArrayList<>();
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS);
    ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
    List<Action> actions = new ArrayList<>();
    ActionBuilder actionBuilder = new ActionBuilder();
    actionBuilder.setActionChoice(new OutputActionCaseBuilder().build());
    actions.add(actionBuilder.build());
    actBuilder.setAction(actions);
    propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS);
    actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
    actions = new ArrayList<>();
    actBuilder.setAction(actions);
    propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS);
    actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
    actions = new ArrayList<>();
    actBuilder.setAction(actions);
    propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS);
    actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
    actions = new ArrayList<>();
    actBuilder.setAction(actions);
    propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH);
    MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(InPhyPort.class);
    entriesBuilder.setHasMask(false);
    List<MatchEntry> entries = new ArrayList<>();
    entries.add(entriesBuilder.build());
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(InPort.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(IpProto.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    entriesBuilder = new MatchEntryBuilder();
    entriesBuilder.setOxmClass(OpenflowBasicClass.class);
    entriesBuilder.setOxmMatchField(IpEcn.class);
    entriesBuilder.setHasMask(false);
    entries.add(entriesBuilder.build());
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS);
    oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
    entries = new ArrayList<>();
    oxmBuilder.setMatchEntry(entries);
    propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
    properties.add(propBuilder.build());
    tableFeaturesBuilder.setTableFeatureProperties(properties);
    tableFeaturesList.add(tableFeaturesBuilder.build());
    featuresBuilder.setTableFeatures(tableFeaturesList);
    caseBuilder.setMultipartReplyTableFeatures(featuresBuilder.build());
    builder.setMultipartReplyBody(caseBuilder.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 520);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPTABLEFEATURES.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    serializedBuffer.skipBytes(PADDING);
    Assert.assertEquals("Wrong length", 232, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong registry-id", 8, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(5);
    Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(serializedBuffer, 32));
    byte[] metadataMatchOutput = new byte[metadataMatch.length];
    serializedBuffer.readBytes(metadataMatchOutput);
    Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, metadataMatchOutput);
    serializedBuffer.skipBytes(64 - metadataMatch.length);
    byte[] metadataWriteOutput = new byte[metadataWrite.length];
    serializedBuffer.readBytes(metadataWriteOutput);
    Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, metadataWriteOutput);
    serializedBuffer.skipBytes(64 - metadataWrite.length);
    Assert.assertEquals("Wrong config", 1, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong max-entries", 65, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong property type", 2, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 6, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong next-registry-id", 1, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong next-registry-id", 2, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(2);
    Assert.assertEquals("Wrong property type", 3, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 0, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 3, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 1, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 1, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 24, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 2, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 6, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 5, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction type", 1, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong length", 272, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong registry-id", 8, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(5);
    Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(serializedBuffer, 32));
    metadataMatchOutput = new byte[metadataMatch.length];
    serializedBuffer.readBytes(metadataMatchOutput);
    serializedBuffer.skipBytes(64 - metadataMatch.length);
    Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, metadataMatchOutput);
    metadataWriteOutput = new byte[metadataWrite.length];
    serializedBuffer.readBytes(metadataWriteOutput);
    serializedBuffer.skipBytes(64 - metadataWrite.length);
    Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, metadataWriteOutput);
    Assert.assertEquals("Wrong config", 1, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong max-entries", 67, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong property type", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 8, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong action type", 0, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 4, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property type", 5, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 6, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 7, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 8, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong match field&mask", 2, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong match length", 4, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong match field&mask", 0, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong match length", 4, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 10, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 12, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 13, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 14, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong match field&mask", 20, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong match length", 1, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong match field&mask", 18, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong match length", 1, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong property type", 15, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(4);
    Assert.assertTrue("Unread data", serializedBuffer.readableBytes() == 0);
}
Also used : InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder) OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) NextTableIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) SetNwTtlActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder) PushVlanActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) WriteMetadataCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder) ArrayList(java.util.ArrayList) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) GotoTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder) NextTableRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) InstructionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder) ActionRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) 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.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder) TableConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig) ClearActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder) MultipartReplyMeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCaseBuilder) MeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder) WriteActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) MultipartReplyTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) NextTableIds(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds) OxmRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)16 GotoTableCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder)14 InstructionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder)14 ApplyActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder)10 WriteMetadataCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder)10 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction)10 Test (org.junit.Test)9 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)8 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)8 GotoTableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder)8 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)7 ClearActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder)7 OutputActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder)6 MeterCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder)6 WriteActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder)6 ApplyActionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder)6 WriteMetadataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder)6 BigInteger (java.math.BigInteger)5 InstructionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)5 GoToTableCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder)5