package org.opendaylight.openflowjava.protocol.api.keys;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCase;
/**
* @author michal.polkorab
*/
-public final class ExperimenterInstructionSerializerKey extends InstructionSerializerKey<Experimenter>
+public final class ExperimenterInstructionSerializerKey extends InstructionSerializerKey<ExperimenterIdCase>
implements ExperimenterSerializerKey {
/**
* @param experimenterId experimenter / vendor ID
*/
public ExperimenterInstructionSerializerKey(short msgVersion, Long experimenterId) {
- super(msgVersion, Experimenter.class, experimenterId);
+ super(msgVersion, ExperimenterIdCase.class, experimenterId);
}
}
\ No newline at end of file
package org.opendaylight.openflowjava.protocol.api.keys;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;
/**
* @author michal.polkorab
* @param <T> instruction type
*/
-public class InstructionSerializerKey<T extends InstructionBase>
+public class InstructionSerializerKey<T extends InstructionChoice>
extends MessageTypeKey<Instruction>{
private Class<T> instructionType;
}
// OFP_INSTRUCTION AUGMENTS
- augment "/ofinstruction:instruction-container/ofinstruction:instruction" {
- ext:augment-identifier "table-id-instruction";
- leaf table-id {
- type uint8;
- }
- }
- augment "/ofinstruction:instruction-container/ofinstruction:instruction" {
- ext:augment-identifier "metadata-instruction";
- leaf metadata {
- type binary;
- }
- leaf metadata-mask {
- type binary;
- }
- }
- augment "/ofinstruction:instruction-container/ofinstruction:instruction" {
- ext:augment-identifier "actions-instruction";
- uses ofaction:actions-grouping;
- }
- augment "/ofinstruction:instruction-container/ofinstruction:instruction" {
- ext:augment-identifier "meter-id-instruction";
- leaf meter-id {
- type uint32;
- }
- }
- augment "/ofinstruction:instruction-container/ofinstruction:instruction" {
- ext:augment-identifier "experimenter-id-instruction";
- leaf experimenter {
- type oft:experimenter-id;
+ augment "/ofinstruction:instruction-container/ofinstruction:instruction-choice" {
+ case experimenter-id-case {
+ container experimenter {
+ leaf experimenter-id {
+ type oft:experimenter-id;
+ }
+ }
}
}
prefix "ofinstruction";
import openflow-types { prefix oft; }
+ import openflow-action {prefix ofaction;}
revision "2013-07-31" {
description "OpenFlow 1.3 - instruction model";
}
- identity goto_table {
- description " Setup the next table in the lookup pipeline";
- base oft:instruction-base;
- }
- identity write_metadata {
- description " Setup the metadata field for use later in pipeline";
- base oft:instruction-base;
- }
- identity write_actions {
- description " Write the action(s) onto the datapath action set";
- base oft:instruction-base;
- }
- identity apply_actions {
- description " Applies the action(s) immediately";
- base oft:instruction-base;
- }
- identity clear_actions {
- description " Clears all actions from the datapath action set";
- base oft:instruction-base;
- }
- identity meter {
- description " Apply meter (rate limiter)";
- base oft:instruction-base;
- }
- identity experimenter {
- description "Experimenter instruction";
- base oft:instruction-base;
- }
-
container instruction-container {
- uses instructions-grouping;
+ uses instruction-grouping;
}
grouping instructions-grouping {
list instruction {
config false;
- leaf type {
- type identityref {
- base oft:instruction-base;
+ uses instruction-grouping;
+ }
+ }
+
+ grouping instruction-grouping {
+ choice instruction-choice {
+ case goto-table-case {
+ container goto-table {
+ leaf table-id {
+ type uint8;
+ }
+ }
+ }
+ case write-metadata-case {
+ container write-metadata {
+ leaf metadata {
+ type binary;
+ }
+ leaf metadata-mask {
+ type binary;
+ }
+ }
+ }
+ case write-actions-case {
+ container write-actions {
+ uses ofaction:actions-grouping;
+ }
+ }
+ case apply-actions-case {
+ container apply-actions {
+ uses ofaction:actions-grouping;
+ }
+ }
+ case clear-actions-case {
+ // empty instruction
+ }
+ case meter-case {
+ container meter {
+ leaf meter-id {
+ type uint32;
+ }
}
}
}
}
-
}
\ No newline at end of file
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
/**
* @author michal.polkorab
@Test
public void test() {
InstructionSerializerKey<?> key1 =
- new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+ new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L);
InstructionSerializerKey<?> key2 =
- new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+ new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L);
Assert.assertTrue("Wrong equals", key1.equals(key2));
Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode());
- key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null);
+ key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, null);
Assert.assertFalse("Wrong equals", key1.equals(key2));
Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L);
Assert.assertFalse("Wrong equals", key1.equals(key2));
Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
- key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActions.class, 42L);
+ key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActionsCase.class, 42L);
Assert.assertFalse("Wrong equals", key1.equals(key2));
Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
- key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 55L);
+ key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 55L);
Assert.assertFalse("Wrong equals", key1.equals(key2));
Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
- key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActions.class, 42L);
+ key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActionsCase.class, 42L);
Assert.assertFalse("Wrong equals", key1.equals(key2));
Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
}
@Test
public void testEquals(){
InstructionSerializerKey<?> key1 =
- new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+ new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L);
InstructionSerializerKey<?> key2 =
- new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+ new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L);
Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object()));
- key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null);
+ key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, null);
Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2));
key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L);
@Test
public void testToString(){
InstructionSerializerKey<?> key1 =
- new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+ new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L);
- Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight"
- + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction"
- + " instructionType type: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".instruction.rev130731.ApplyActions vendorID: 42", key1.toString());
+ Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn"
+ + ".opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction "
+ + "instructionType type: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction"
+ + ".rev130731.instruction.grouping.instruction.choice.ApplyActionsCase vendorID: 42", key1.toString());
}
}
\ No newline at end of file
Assert.assertFalse(actionSerializerKey.equals(experimenterActionSerializerKey));
Assert.assertFalse(experimenterActionSerializerKey.equals(actionSerializerKey));
- InstructionSerializerKey<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter> instructionSerializerKey = new InstructionSerializerKey<>(
- EncodeConstants.OF13_VERSION_ID,
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter.class,
- 1L);
+ InstructionSerializerKey<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225
+ .instruction.container.instruction.choice.ExperimenterIdCase> instructionSerializerKey =
+ new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, org.opendaylight.yang.gen.v1.urn
+ .opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice
+ .ExperimenterIdCase.class, 1L);
ExperimenterInstructionSerializerKey experimenterInstructionSerializerKey = new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, 1L);
Assert.assertEquals(instructionSerializerKey, experimenterInstructionSerializerKey);
Assert.assertEquals(instructionSerializerKey.hashCode(), experimenterInstructionSerializerKey.hashCode());
import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker;
import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory;
import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;
/**
* @author michal.polkorab
*
*/
-public abstract class AbstractActionInstructionDeserializer extends AbstractInstructionDeserializer
- implements DeserializerRegistryInjector {
+public abstract class AbstractActionInstructionDeserializer implements OFDeserializer<Instruction>,
+ DeserializerRegistryInjector {
private DeserializerRegistry registry;
- @Override
- public Instruction deserialize(ByteBuf input) {
- InstructionBuilder builder = new InstructionBuilder();
- input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- builder.setType(getType());
- int instructionLength = input.readUnsignedShort();
- input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
- ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder();
+ protected List<Action> deserializeActions(ByteBuf input, int instructionLength) {
int length = instructionLength - InstructionConstants.STANDARD_INSTRUCTION_LENGTH;
CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
List<Action> actions = ListDeserializer.deserializeList(
EncodeConstants.OF13_VERSION_ID, length, input, keyMaker, getRegistry());
- actionsBuilder.setAction(actions);
- builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());
- return builder.build();
+ return actions;
}
- protected abstract Class<? extends InstructionBase> getType();
-
protected DeserializerRegistry getRegistry() {
return registry;
}
+++ /dev/null
-/*
- * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
-
-import io.netty.buffer.ByteBuf;
-
-import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
-
-/**
- * @author michal.polkorab
- *
- */
-public abstract class AbstractInstructionDeserializer implements OFDeserializer<Instruction>,
- HeaderDeserializer<Instruction> {
-
- @Override
- public Instruction deserializeHeader(ByteBuf rawMessage) {
- InstructionBuilder builder = processHeader(rawMessage);
- rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- return builder.build();
- }
-
- protected InstructionBuilder processHeader(ByteBuf input) {
- InstructionBuilder builder = new InstructionBuilder();
- int type = input.readUnsignedShort();
- switch (type) {
- case 1:
- builder.setType(GotoTable.class);
- break;
- case 2:
- builder.setType(WriteMetadata.class);
- break;
- case 3:
- builder.setType(WriteActions.class);
- break;
- case 4:
- builder.setType(ApplyActions.class);
- break;
- case 5:
- builder.setType(ClearActions.class);
- break;
- case 6:
- builder.setType(Meter.class);
- break;
- default:
- throw new IllegalStateException("Unknown instruction type received, type: " + type);
- }
- return builder;
- }
-}
package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
/**
* @author michal.polkorab
*
*/
-public class ApplyActionsInstructionDeserializer extends AbstractActionInstructionDeserializer {
+public class ApplyActionsInstructionDeserializer extends AbstractActionInstructionDeserializer
+ implements HeaderDeserializer<Instruction> {
+
+ @Override
+ public Instruction deserialize(ByteBuf input) {
+ InstructionBuilder builder = new InstructionBuilder();
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ int instructionLength = input.readUnsignedShort();
+ input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
+ ApplyActionsCaseBuilder caseBuilder = new ApplyActionsCaseBuilder();
+ ApplyActionsBuilder actionsBuilder = new ApplyActionsBuilder();
+ actionsBuilder.setAction(deserializeActions(input, instructionLength));
+ caseBuilder.setApplyActions(actionsBuilder.build());
+ builder.setInstructionChoice(caseBuilder.build());
+ return builder.build();
+ }
@Override
- protected Class<? extends InstructionBase> getType() {
- return ApplyActions.class;
+ public Instruction deserializeHeader(ByteBuf input) {
+ InstructionBuilder builder = new InstructionBuilder();
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ builder.setInstructionChoice(new ApplyActionsCaseBuilder().build());
+ return builder.build();
}
}
import io.netty.buffer.ByteBuf;
-import java.util.ArrayList;
-import java.util.List;
-
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
* @author michal.polkorab
*
*/
-public class ClearActionsInstructionDeserializer extends AbstractInstructionDeserializer {
+public class ClearActionsInstructionDeserializer implements OFDeserializer<Instruction>,
+ HeaderDeserializer<Instruction> {
@Override
public Instruction deserialize(ByteBuf input) {
- InstructionBuilder builder = super.processHeader(input);
- input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ InstructionBuilder builder = new InstructionBuilder();
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
- ActionsInstructionBuilder actionsBuilder =
- new ActionsInstructionBuilder();
- List<Action> actions = new ArrayList<>();
- actionsBuilder.setAction(actions);
- builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());
+ builder.setInstructionChoice(new ClearActionsCaseBuilder().build());
+ return builder.build();
+ }
+
+ @Override
+ public Instruction deserializeHeader(ByteBuf input) {
+ InstructionBuilder builder = new InstructionBuilder();
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ builder.setInstructionChoice(new ClearActionsCaseBuilder().build());
return builder.build();
}
}
\ No newline at end of file
import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
* @author michal.polkorab
*
*/
-public class GoToTableInstructionDeserializer extends AbstractInstructionDeserializer {
+public class GoToTableInstructionDeserializer implements OFDeserializer<Instruction>,
+ HeaderDeserializer<Instruction> {
@Override
public Instruction deserialize(ByteBuf input) {
InstructionBuilder builder = new InstructionBuilder();
- input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- builder.setType(GotoTable.class);
- input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder();
- tableBuilder.setTableId(input.readUnsignedByte());
- builder.addAugmentation(TableIdInstruction.class, tableBuilder.build());
+ GotoTableCaseBuilder caseBuilder = new GotoTableCaseBuilder();
+ GotoTableBuilder instructionBuilder = new GotoTableBuilder();
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ instructionBuilder.setTableId(input.readUnsignedByte());
+ caseBuilder.setGotoTable(instructionBuilder.build());
+ builder.setInstructionChoice(caseBuilder.build());
input.skipBytes(InstructionConstants.PADDING_IN_GOTO_TABLE);
return builder.build();
}
+
+ @Override
+ public Instruction deserializeHeader(ByteBuf input) {
+ InstructionBuilder builder = new InstructionBuilder();
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ builder.setInstructionChoice(new GotoTableCaseBuilder().build());
+ return builder.build();
+ }
}
import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
* @author michal.polkorab
*
*/
-public class MeterInstructionDeserializer extends AbstractInstructionDeserializer {
+public class MeterInstructionDeserializer implements OFDeserializer<Instruction>,
+ HeaderDeserializer<Instruction> {
@Override
public Instruction deserialize(ByteBuf input) {
InstructionBuilder builder = new InstructionBuilder();
- input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- builder.setType(Meter.class);
- input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder();
- meterBuilder.setMeterId(input.readUnsignedInt());
- builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build());
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ MeterCaseBuilder caseBuilder = new MeterCaseBuilder();
+ MeterBuilder instructionBuilder = new MeterBuilder();
+ instructionBuilder.setMeterId(input.readUnsignedInt());
+ caseBuilder.setMeter(instructionBuilder.build());
+ builder.setInstructionChoice(caseBuilder.build());
+ return builder.build();
+ }
+
+ @Override
+ public Instruction deserializeHeader(ByteBuf input) {
+ InstructionBuilder builder = new InstructionBuilder();
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ builder.setInstructionChoice(new MeterCaseBuilder().build());
return builder.build();
}
package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
/**
* @author michal.polkorab
*
*/
-public class WriteActionsInstructionDeserializer extends AbstractActionInstructionDeserializer {
+public class WriteActionsInstructionDeserializer extends AbstractActionInstructionDeserializer
+ implements HeaderDeserializer<Instruction> {
+
+ @Override
+ public Instruction deserialize(ByteBuf input) {
+ InstructionBuilder builder = new InstructionBuilder();
+ input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ int instructionLength = input.readUnsignedShort();
+ input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
+ WriteActionsCaseBuilder caseBuilder = new WriteActionsCaseBuilder();
+ WriteActionsBuilder actionsBuilder = new WriteActionsBuilder();
+ actionsBuilder.setAction(deserializeActions(input, instructionLength));
+ caseBuilder.setWriteActions(actionsBuilder.build());
+ builder.setInstructionChoice(caseBuilder.build());
+ return builder.build();
+ }
@Override
- protected Class<? extends InstructionBase> getType() {
- return WriteActions.class;
+ public Instruction deserializeHeader(ByteBuf input) {
+ InstructionBuilder builder = new InstructionBuilder();
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ builder.setInstructionChoice(new WriteActionsCaseBuilder().build());
+ return builder.build();
}
}
import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
* @author michal.polkorab
*
*/
-public class WriteMetadataInstructionDeserializer extends AbstractInstructionDeserializer {
+public class WriteMetadataInstructionDeserializer implements OFDeserializer<Instruction>,
+ HeaderDeserializer<Instruction> {
@Override
public Instruction deserialize(ByteBuf input) {
InstructionBuilder builder = new InstructionBuilder();
- input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
- builder.setType(WriteMetadata.class);
- input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
input.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA);
- MetadataInstructionBuilder metadataBuilder = new MetadataInstructionBuilder();
+ WriteMetadataCaseBuilder caseBuilder = new WriteMetadataCaseBuilder();
+ WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(metadata);
metadataBuilder.setMetadata(metadata);
byte[] metadataMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(metadataMask);
metadataBuilder.setMetadataMask(metadataMask);
- builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build());
+ caseBuilder.setWriteMetadata(metadataBuilder.build());
+ builder.setInstructionChoice(caseBuilder.build());
+ return builder.build();
+ }
+
+ @Override
+ public Instruction deserializeHeader(ByteBuf input) {
+ InstructionBuilder builder = new InstructionBuilder();
+ input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+ builder.setInstructionChoice(new WriteMetadataCaseBuilder().build());
return builder.build();
}
}
import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteActionsInstructionSerializer;
import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteMetadataInstructionSerializer;
import org.opendaylight.openflowjava.protocol.impl.util.InstructionSerializerRegistryHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase;
/**
* @author michal.polkorab
// register OF v1.3 instruction serializers
InstructionSerializerRegistryHelper helper= new InstructionSerializerRegistryHelper(
EncodeConstants.OF13_VERSION_ID, serializerRegistry);
- helper.registerSerializer(GotoTable.class, new GoToTableInstructionSerializer());
- helper.registerSerializer(WriteMetadata.class, new WriteMetadataInstructionSerializer());
- helper.registerSerializer(WriteActions.class, new WriteActionsInstructionSerializer());
- helper.registerSerializer(ApplyActions.class, new ApplyActionsInstructionSerializer());
- helper.registerSerializer(ClearActions.class, new ClearActionsInstructionSerializer());
- helper.registerSerializer(Meter.class, new MeterInstructionSerializer());
+ helper.registerSerializer(GotoTableCase.class, new GoToTableInstructionSerializer());
+ helper.registerSerializer(WriteMetadataCase.class, new WriteMetadataInstructionSerializer());
+ helper.registerSerializer(WriteActionsCase.class, new WriteActionsInstructionSerializer());
+ helper.registerSerializer(ApplyActionsCase.class, new ApplyActionsInstructionSerializer());
+ helper.registerSerializer(ClearActionsCase.class, new ClearActionsInstructionSerializer());
+ helper.registerSerializer(MeterCase.class, new MeterInstructionSerializer());
}
}
import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer;
import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker;
import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
/**
* @author michal.polkorab
private SerializerRegistry registry;
- @Override
- public void serialize(final Instruction instruction, final ByteBuf outBuffer) {
- int startIndex = outBuffer.writerIndex();
- outBuffer.writeShort(getType());
- if (instruction.getAugmentation(ActionsInstruction.class) != null) {
- List<Action> actions = instruction.getAugmentation(ActionsInstruction.class).getAction();
- int lengthIndex = outBuffer.writerIndex();
- outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
- outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
- ListSerializer.serializeList(actions, ACTION_KEY_MAKER, getRegistry(), outBuffer);
- int instructionLength = outBuffer.writerIndex() - startIndex;
- outBuffer.setShort(lengthIndex, instructionLength);
- } else {
- outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
- outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
- }
+ protected void writeActions(final List<Action> actions, final ByteBuf outBuffer, int startIndex) {
+ int lengthIndex = outBuffer.writerIndex();
+ outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
+ outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
+ ListSerializer.serializeList(actions, ACTION_KEY_MAKER, getRegistry(), outBuffer);
+ int instructionLength = outBuffer.writerIndex() - startIndex;
+ outBuffer.setShort(lengthIndex, instructionLength);
}
protected SerializerRegistry getRegistry() {
package org.opendaylight.openflowjava.protocol.impl.serialization.instruction;
+import io.netty.buffer.ByteBuf;
+
+import java.util.List;
+
import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
/**
* @author michal.polkorab
*/
public class ApplyActionsInstructionSerializer extends AbstractActionInstructionSerializer {
+ @Override
+ public void serialize(final Instruction instruction, final ByteBuf outBuffer) {
+ int startIndex = outBuffer.writerIndex();
+ outBuffer.writeShort(getType());
+ ApplyActionsCase actionsCase = (ApplyActionsCase) instruction.getInstructionChoice();
+ if (actionsCase != null) {
+ List<Action> actions = actionsCase.getApplyActions().getAction();
+ writeActions(actions, outBuffer, startIndex);
+ } else {
+ outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
+ outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
+ }
+ }
+
@Override
protected int getType() {
return InstructionConstants.APPLY_ACTIONS_TYPE;
package org.opendaylight.openflowjava.protocol.impl.serialization.instruction;
+import io.netty.buffer.ByteBuf;
+
import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
/**
* @author michal.polkorab
*
*/
-public class ClearActionsInstructionSerializer extends AbstractActionInstructionSerializer {
+public class ClearActionsInstructionSerializer extends AbstractInstructionSerializer {
+
+ @Override
+ public void serialize(final Instruction instruction, final ByteBuf outBuffer) {
+ outBuffer.writeShort(getType());
+ outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
+ outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
+ }
@Override
protected int getType() {
import io.netty.buffer.ByteBuf;
import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
/**
public void serialize(Instruction instruction, ByteBuf outBuffer) {
outBuffer.writeShort(getType());
outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
- outBuffer.writeByte(instruction.getAugmentation(TableIdInstruction.class).getTableId());
+ outBuffer.writeByte(((GotoTableCase) instruction.getInstructionChoice())
+ .getGotoTable().getTableId());
outBuffer.writeZero(InstructionConstants.PADDING_IN_GOTO_TABLE);
}
import io.netty.buffer.ByteBuf;
import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
/**
public void serialize(Instruction instruction, ByteBuf outBuffer) {
outBuffer.writeShort(getType());
outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
- outBuffer.writeInt(instruction.
- getAugmentation(MeterIdInstruction.class).getMeterId().intValue());
+ outBuffer.writeInt(((MeterCase) instruction.getInstructionChoice())
+ .getMeter().getMeterId().intValue());
}
@Override
package org.opendaylight.openflowjava.protocol.impl.serialization.instruction;
+import io.netty.buffer.ByteBuf;
+
+import java.util.List;
+
import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
/**
* @author michal.polkorab
*/
public class WriteActionsInstructionSerializer extends AbstractActionInstructionSerializer {
+ @Override
+ public void serialize(final Instruction instruction, final ByteBuf outBuffer) {
+ int startIndex = outBuffer.writerIndex();
+ outBuffer.writeShort(getType());
+ WriteActionsCase actionsCase = (WriteActionsCase) instruction.getInstructionChoice();
+ if (actionsCase != null) {
+ List<Action> actions = actionsCase.getWriteActions().getAction();
+ writeActions(actions, outBuffer, startIndex);
+ } else {
+ outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
+ outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
+ }
+ }
+
@Override
protected int getType() {
return InstructionConstants.WRITE_ACTIONS_TYPE;
import io.netty.buffer.ByteBuf;
import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadata;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
/**
outBuffer.writeShort(getType());
outBuffer.writeShort(InstructionConstants.WRITE_METADATA_LENGTH);
outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA);
- MetadataInstruction metadata = instruction.getAugmentation(MetadataInstruction.class);
+ WriteMetadata metadata = ((WriteMetadataCase) instruction.getInstructionChoice())
+ .getWriteMetadata();
outBuffer.writeBytes(metadata.getMetadata());
outBuffer.writeBytes(metadata.getMetadataMask());
}
import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer;
import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice;
/**
* @author michal.polkorab
* @param instructionType
* @param serializer
*/
- public <T extends InstructionBase> void registerSerializer(Class<T> instructionType,
+ public <T extends InstructionChoice> void registerSerializer(Class<T> instructionType,
OFGeneralSerializer serializer) {
serializerRegistry.registerSerializer(new InstructionSerializerKey<>(version,
instructionType, null), serializer);
import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;
import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
expIdCase.getExperimenter().getExperimenter().getValue(),
expIdCase.getExperimenter().getSubType());
}
- return new ActionSerializerKey<>(getVersion(), (Class<ActionChoice>) entry.getActionChoice().getImplementedInterface(), null);
+ return new ActionSerializerKey<>(getVersion(),
+ (Class<ActionChoice>) entry.getActionChoice().getImplementedInterface(), null);
}
};
}
return new AbstractTypeKeyMaker<Instruction>(version) {
@Override
public MessageTypeKey<?> make(Instruction entry) {
- if (entry.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
- .instruction.rev130731.Experimenter.class)) {
+ if (entry.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
+ .augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCase) {
return new ExperimenterInstructionSerializerKey(getVersion(),
- entry.getAugmentation(ExperimenterIdInstruction.class)
- .getExperimenter().getValue());
+ ((org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction
+ .container.instruction.choice.ExperimenterIdCase) entry.getInstructionChoice())
+ .getExperimenter().getExperimenterId().getValue());
}
- return new InstructionSerializerKey<>(getVersion(), entry.getType(), null);
+ return new InstructionSerializerKey<>(getVersion(),
+ (Class<InstructionChoice>) entry.getInstructionChoice().getImplementedInterface(), null);
}
};
}
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.util.ByteBufUtils;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
/**
* Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different
* instruction types
*/
- @Test(expected=IllegalStateException.class)
+ @Test
public void test() {
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04");
- GoToTableInstructionDeserializer deserializer = new GoToTableInstructionDeserializer();
- Instruction instruction = deserializer.deserializeHeader(buffer);
- Assert.assertEquals("Wrong type", GotoTable.class, instruction.getType());
+ Instruction instruction = new GoToTableInstructionDeserializer().deserializeHeader(buffer);
+ Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof GotoTableCase);
buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04");
- instruction = deserializer.deserializeHeader(buffer);
- Assert.assertEquals("Wrong type", WriteMetadata.class, instruction.getType());
+ instruction = new WriteMetadataInstructionDeserializer().deserializeHeader(buffer);
+ Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof WriteMetadataCase);
buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04");
- instruction = deserializer.deserializeHeader(buffer);
- Assert.assertEquals("Wrong type", WriteActions.class, instruction.getType());
+ instruction = new WriteActionsInstructionDeserializer().deserializeHeader(buffer);
+ Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof WriteActionsCase);
buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04");
- instruction = deserializer.deserializeHeader(buffer);
- Assert.assertEquals("Wrong type", ApplyActions.class, instruction.getType());
+ instruction = new ApplyActionsInstructionDeserializer().deserializeHeader(buffer);
+ Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof ApplyActionsCase);
buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04");
- instruction = deserializer.deserializeHeader(buffer);
- Assert.assertEquals("Wrong type", ClearActions.class, instruction.getType());
+ instruction = new ClearActionsInstructionDeserializer().deserializeHeader(buffer);
+ Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof ClearActionsCase);
buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04");
- instruction = deserializer.deserializeHeader(buffer);
- Assert.assertEquals("Wrong type", Meter.class, instruction.getType());
-
- buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 04");
- instruction = deserializer.deserializeHeader(buffer);
- // exception expected
+ instruction = new MeterInstructionDeserializer().deserializeHeader(buffer);
+ Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof MeterCase);
}
}
\ No newline at end of file
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
builder.setMatch(matchBuilder.build());
List<Instruction> instructions = new ArrayList<>();
InstructionBuilder insBuilder = new InstructionBuilder();
- insBuilder.setType(GotoTable.class);
- TableIdInstructionBuilder idBuilder = new TableIdInstructionBuilder();
- idBuilder.setTableId((short) 43);
- insBuilder.addAugmentation(TableIdInstruction.class, idBuilder.build());
+ GotoTableCaseBuilder goToCaseBuilder = new GotoTableCaseBuilder();
+ GotoTableBuilder instructionBuilder = new GotoTableBuilder();
+ instructionBuilder.setTableId((short) 43);
+ goToCaseBuilder.setGotoTable(instructionBuilder.build());
+ insBuilder.setInstructionChoice(goToCaseBuilder.build());
instructions.add(insBuilder.build());
- insBuilder.setType(WriteMetadata.class);
- MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder();
- metaBuilder.setMetadata(cookie);
- metaBuilder.setMetadataMask(cookieMask);
- insBuilder.addAugmentation(MetadataInstruction.class, metaBuilder.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();
- insBuilder.setType(ApplyActions.class);
+ ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
+ ApplyActionsBuilder actionsBuilder = new ApplyActionsBuilder();
List<Action> actions = new ArrayList<>();
ActionBuilder actionBuilder = new ActionBuilder();
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
caseBuilder.setOutputAction(outputBuilder.build());
actionBuilder.setActionChoice(caseBuilder.build());
actions.add(actionBuilder.build());
- ActionsInstructionBuilder actionInstructionBuilder = new ActionsInstructionBuilder();
- actionInstructionBuilder.setAction(actions);
- insBuilder.addAugmentation(ActionsInstruction.class, actionInstructionBuilder.build());
+ actionsBuilder.setAction(actions);
+ applyActionsCaseBuilder.setApplyActions(actionsBuilder.build());
+ insBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
instructions.add(insBuilder.build());
builder.setInstruction(instructions);
FlowModInput message = builder.build();
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
new InstructionRelatedTableFeaturePropertyBuilder();
List<Instruction> insIds = new ArrayList<>();
InstructionBuilder insBuilder = new InstructionBuilder();
- insBuilder.setType(WriteActions.class);
+ insBuilder.setInstructionChoice(new WriteActionsCaseBuilder().build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
- insBuilder.setType(GotoTable.class);
+ insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build());
insIds.add(insBuilder.build());
insPropBuilder.setInstruction(insIds);
propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
insIds = new ArrayList<>();
insBuilder = new InstructionBuilder();
- insBuilder.setType(WriteMetadata.class);
+ insBuilder.setInstructionChoice(new WriteMetadataCaseBuilder().build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
- insBuilder.setType(ApplyActions.class);
+ insBuilder.setInstructionChoice(new ApplyActionsCaseBuilder().build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
- insBuilder.setType(Meter.class);
+ insBuilder.setInstructionChoice(new MeterCaseBuilder().build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
- insBuilder.setType(ClearActions.class);
+ insBuilder.setInstructionChoice(new ClearActionsCaseBuilder().build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
- insBuilder.setType(GotoTable.class);
+ insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build());
insIds.add(insBuilder.build());
insPropBuilder.setInstruction(insIds);
propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
import org.opendaylight.openflowjava.util.ByteBufUtils;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
/**
List<Instruction> instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,
message.readableBytes(), message, keyMaker, registry);
Instruction i1 = instructions.get(0);
- Assert.assertEquals("Wrong type - i1", "org.opendaylight.yang.gen.v1.urn."
- + "opendaylight.openflow.common.instruction.rev130731.GotoTable", i1.getType().getName());
- Assert.assertEquals("Wrong table-id - i1", 10, i1.getAugmentation(TableIdInstruction.class).getTableId().intValue());
+ Assert.assertTrue("Wrong type - i1", i1.getInstructionChoice() instanceof GotoTableCase);
+ Assert.assertEquals("Wrong table-id - i1", 10, ((GotoTableCase) i1.getInstructionChoice())
+ .getGotoTable().getTableId().intValue());
Instruction i2 = instructions.get(1);
- Assert.assertEquals("Wrong type - i2", "org.opendaylight.yang.gen.v1.urn."
- + "opendaylight.openflow.common.instruction.rev130731.WriteMetadata", i2.getType().getName());
+ Assert.assertTrue("Wrong type - i2", i2.getInstructionChoice() instanceof WriteMetadataCase);
Assert.assertArrayEquals("Wrong metadata - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 20"),
- i2.getAugmentation(MetadataInstruction.class).getMetadata());
+ ((WriteMetadataCase) i2.getInstructionChoice()).getWriteMetadata().getMetadata());
Assert.assertArrayEquals("Wrong metadata-mask - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 30"),
- i2.getAugmentation(MetadataInstruction.class).getMetadataMask());
+ ((WriteMetadataCase) i2.getInstructionChoice()).getWriteMetadata().getMetadataMask());
Instruction i3 = instructions.get(2);
- Assert.assertEquals("Wrong type - i3", "org.opendaylight.yang.gen.v1.urn."
- + "opendaylight.openflow.common.instruction.rev130731.ClearActions", i3.getType().getName());
- Assert.assertEquals("Wrong instructions - i3", 0, i3.getAugmentation(ActionsInstruction.class).getAction().size());
+ Assert.assertTrue("Wrong type - i3", i3.getInstructionChoice() instanceof ClearActionsCase);
Instruction i4 = instructions.get(3);
- Assert.assertEquals("Wrong type - i4", "org.opendaylight.yang.gen.v1.urn."
- + "opendaylight.openflow.common.instruction.rev130731.Meter", i4.getType().getName());
- Assert.assertEquals("Wrong meterId - i4", 66051, i4.getAugmentation(MeterIdInstruction.class).getMeterId().intValue());
+ Assert.assertTrue("Wrong type - i4", i4.getInstructionChoice() instanceof MeterCase);
+ Assert.assertEquals("Wrong meterId - i4", 66051, ((MeterCase) i4.getInstructionChoice())
+ .getMeter().getMeterId().intValue());
Instruction i5 = instructions.get(4);
- Assert.assertEquals("Wrong type - i5", "org.opendaylight.yang.gen.v1.urn."
- + "opendaylight.openflow.common.instruction.rev130731.WriteActions", i5.getType().getName());
- Assert.assertEquals("Wrong instructions - i5", 2, i5.getAugmentation(ActionsInstruction.class).getAction().size());
- Action action1 = i5.getAugmentation(ActionsInstruction.class).getAction().get(0);
+ Assert.assertTrue("Wrong type - i5", i5.getInstructionChoice() instanceof WriteActionsCase);
+ Assert.assertEquals("Wrong instructions - i5", 2, ((WriteActionsCase) i5.getInstructionChoice())
+ .getWriteActions().getAction().size());
+ Action action1 = ((WriteActionsCase) i5.getInstructionChoice()).getWriteActions().getAction().get(0);
Assert.assertTrue("Wrong action", action1.getActionChoice() instanceof OutputActionCase);
Assert.assertEquals("Wrong action", 37, ((OutputActionCase) action1.getActionChoice()).getOutputAction()
.getPort().getValue().intValue());
Assert.assertEquals("Wrong action", 53, ((OutputActionCase) action1.getActionChoice()).getOutputAction()
.getMaxLength().intValue());
- Action action2 = i5.getAugmentation(ActionsInstruction.class).getAction().get(1);
+ Action action2 = ((WriteActionsCase) i5.getInstructionChoice()).getWriteActions().getAction().get(1);
Assert.assertTrue("Wrong action", action2.getActionChoice() instanceof GroupCase);
Assert.assertEquals("Wrong action", 80, ((GroupCase) action2.getActionChoice()).getGroupAction().getGroupId().intValue());
Instruction i6 = instructions.get(5);
- Assert.assertEquals("Wrong type - i6", "org.opendaylight.yang.gen.v1.urn."
- + "opendaylight.openflow.common.instruction.rev130731.ApplyActions", i6.getType().getName());
- Assert.assertEquals("Wrong instructions - i6", 2, i6.getAugmentation(ActionsInstruction.class).getAction().size());
- action1 = i6.getAugmentation(ActionsInstruction.class).getAction().get(0);
+ Assert.assertTrue("Wrong type - i6", i6.getInstructionChoice() instanceof ApplyActionsCase);
+ Assert.assertEquals("Wrong instructions - i6", 2, ((ApplyActionsCase) i6.getInstructionChoice())
+ .getApplyActions().getAction().size());
+ action1 = ((ApplyActionsCase) i6.getInstructionChoice()).getApplyActions().getAction().get(0);
Assert.assertTrue("Wrong action", action1.getActionChoice() instanceof SetQueueCase);
Assert.assertEquals("Wrong action", 37, ((SetQueueCase) action1.getActionChoice()).getSetQueueAction()
.getQueueId().intValue());
- action2 = i6.getAugmentation(ActionsInstruction.class).getAction().get(1);
+ action2 = ((ApplyActionsCase) i6.getInstructionChoice()).getApplyActions().getAction().get(1);
Assert.assertTrue("Wrong action", action2.getActionChoice() instanceof SetMplsTtlCase);
Assert.assertEquals("Wrong action", 5, ((SetMplsTtlCase) action2.getActionChoice()).getSetMplsTtlAction()
.getMplsTtl().shortValue());
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
import org.opendaylight.openflowjava.util.ByteBufUtils;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
List<Instruction> instructions = new ArrayList<>();
// Goto_table instruction
InstructionBuilder builder = new InstructionBuilder();
- builder.setType(GotoTable.class);
- TableIdInstructionBuilder tableIdBuilder = new TableIdInstructionBuilder();
- tableIdBuilder.setTableId((short) 5);
- builder.addAugmentation(TableIdInstruction.class, tableIdBuilder.build());
+ GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder();
+ GotoTableBuilder instructionBuilder = new GotoTableBuilder();
+ instructionBuilder.setTableId((short) 5);
+ gotoCaseBuilder.setGotoTable(instructionBuilder.build());
+ builder.setInstructionChoice(gotoCaseBuilder.build());
instructions.add(builder.build());
- builder = new InstructionBuilder();
// Write_metadata instruction
- builder.setType(WriteMetadata.class);
- MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder();
- metaBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07"));
- metaBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00"));
- builder.addAugmentation(MetadataInstruction.class, metaBuilder.build());
+ builder = 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());
+ builder.setInstructionChoice(metadataCaseBuilder.build());
instructions.add(builder.build());
// Clear_actions instruction
builder = new InstructionBuilder();
- builder.setType(ClearActions.class);
+ builder.setInstructionChoice(new ClearActionsCaseBuilder().build());
instructions.add(builder.build());
// Meter instruction
builder = new InstructionBuilder();
- builder.setType(Meter.class);
- MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder();
+ MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
+ MeterBuilder meterBuilder = new MeterBuilder();
meterBuilder.setMeterId(42L);
- builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build());
+ meterCaseBuilder.setMeter(meterBuilder.build());
+ builder.setInstructionChoice(meterCaseBuilder.build());
instructions.add(builder.build());
// Write_actions instruction
builder = new InstructionBuilder();
- builder.setType(WriteActions.class);
- ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder();
+ WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
+ WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
List<Action> actions = new ArrayList<>();
ActionBuilder actionBuilder = new ActionBuilder();
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
ttlCaseBuilder.setSetNwTtlAction(ttlActionBuilder.build());
actionBuilder.setActionChoice(ttlCaseBuilder.build());
actions.add(actionBuilder.build());
- actionsBuilder.setAction(actions);
- builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());
+ writeActionsBuilder.setAction(actions);
+ writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
+ builder.setInstructionChoice(writeActionsCaseBuilder.build());
instructions.add(builder.build());
// Apply_actions instruction
builder = new InstructionBuilder();
- builder.setType(ApplyActions.class);
- actionsBuilder = new ActionsInstructionBuilder();
+ ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
+ ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
actions = new ArrayList<>();
actionBuilder = new ActionBuilder();
PushVlanCaseBuilder vlanCaseBuilder = new PushVlanCaseBuilder();
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
actions.add(actionBuilder.build());
- actionsBuilder.setAction(actions);
- builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());
+ applyActionsBuilder.setAction(actions);
+ applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
+ builder.setInstructionChoice(applyActionsCaseBuilder.build());
instructions.add(builder.build());
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
Assert.assertNotNull("Null keyMaker", keyMaker);
InstructionBuilder builder = new InstructionBuilder();
- builder.setType(GotoTable.class);
+ builder.setInstructionChoice(new GotoTableCaseBuilder().build());
Instruction instruction = builder.build();
MessageTypeKey<?> key = keyMaker.make(instruction);
Assert.assertNotNull("Null key", key);
Assert.assertEquals("Wrong key", new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID,
- GotoTable.class, null), key);
+ GotoTableCase.class, null), key);
}
/**
Assert.assertNotNull("Null keyMaker", keyMaker);
InstructionBuilder builder = new InstructionBuilder();
- builder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
- .common.instruction.rev130731.Experimenter.class);
- ExperimenterIdInstructionBuilder expIdBuilder = new ExperimenterIdInstructionBuilder();
- expIdBuilder.setExperimenter(new ExperimenterId(42L));
- builder.addAugmentation(ExperimenterIdInstruction.class, expIdBuilder.build());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction.container
+ .instruction.choice.ExperimenterIdCaseBuilder caseBuilder = new org.opendaylight.yang.gen.v1.urn
+ .opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCaseBuilder();
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction.container
+ .instruction.choice.experimenter.id._case.ExperimenterBuilder expIdBuilder = new org.opendaylight.yang.gen
+ .v1.urn.opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice.experimenter.id
+ ._case.ExperimenterBuilder();
+ expIdBuilder.setExperimenterId(new ExperimenterId(42L));
+ caseBuilder.setExperimenter(expIdBuilder.build());
+ builder.setInstructionChoice(caseBuilder.build());
Instruction instruction = builder.build();
MessageTypeKey<?> key = keyMaker.make(instruction);