fix for cbench
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficTreatment.java b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficTreatment.java
index 6eaa2c3..6064263 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficTreatment.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficTreatment.java
@@ -6,6 +6,7 @@
import java.util.LinkedList;
import java.util.List;
+import org.onlab.onos.net.flow.instructions.Instruction;
import org.slf4j.Logger;
@SuppressWarnings("rawtypes")
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/Instructions.java b/core/api/src/main/java/org/onlab/onos/net/flow/Instructions.java
deleted file mode 100644
index cfe1440..0000000
--- a/core/api/src/main/java/org/onlab/onos/net/flow/Instructions.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.onlab.onos.net.flow;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onlab.onos.net.PortNumber;
-/**
- * Factory class for creating various traffic treatment instructions.
- */
-public final class Instructions {
-
- // Ban construction
- private Instructions() {}
-
- /**
- * Creates an output instruction using the specified port number. This can
- * include logical ports such as CONTROLLER, FLOOD, etc.
- *
- * @param number port number
- * @return output instruction
- */
- public static OutputInstruction createOutput(final PortNumber number) {
- checkNotNull(number, "PortNumber cannot be null");
- return new OutputInstruction(number);
- }
-
- // TODO: Move these out into separate classes and to flow.instruction package
- public static DropInstruction createDrop() {
- return new DropInstruction();
- }
-
- // TODO: add create methods
-
- public static final class DropInstruction implements Instruction {
- @Override
- public Type type() {
- return Type.DROP;
- }
- }
-
-
- public static final class OutputInstruction implements Instruction {
- private final PortNumber port;
-
- private OutputInstruction(PortNumber port) {
- this.port = port;
- }
-
- public PortNumber port() {
- return port;
- }
-
- @Override
- public Type type() {
- return Type.OUTPUT;
- }
- }
-
-}
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/TrafficTreatment.java b/core/api/src/main/java/org/onlab/onos/net/flow/TrafficTreatment.java
index b8b9c10..068bc2c 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/TrafficTreatment.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/TrafficTreatment.java
@@ -2,6 +2,8 @@
import java.util.List;
+import org.onlab.onos.net.flow.instructions.Instruction;
+
/**
* Abstraction of network traffic treatment.
*/
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/Instruction.java b/core/api/src/main/java/org/onlab/onos/net/flow/instructions/Instruction.java
similarity index 94%
rename from core/api/src/main/java/org/onlab/onos/net/flow/Instruction.java
rename to core/api/src/main/java/org/onlab/onos/net/flow/instructions/Instruction.java
index 67e3d67..5d34fc2 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/Instruction.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/instructions/Instruction.java
@@ -1,4 +1,4 @@
-package org.onlab.onos.net.flow;
+package org.onlab.onos.net.flow.instructions;
/**
* Abstraction of a single traffic treatment step.
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/instructions/Instructions.java b/core/api/src/main/java/org/onlab/onos/net/flow/instructions/Instructions.java
new file mode 100644
index 0000000..2365bf0
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/instructions/Instructions.java
@@ -0,0 +1,102 @@
+package org.onlab.onos.net.flow.instructions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onlab.onos.net.PortNumber;
+import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction;
+import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.SubType;
+import org.onlab.packet.MACAddress;
+/**
+ * Factory class for creating various traffic treatment instructions.
+ */
+public final class Instructions {
+
+
+ // Ban construction
+ private Instructions() {}
+
+ /**
+ * Creates an output instruction using the specified port number. This can
+ * include logical ports such as CONTROLLER, FLOOD, etc.
+ *
+ * @param number port number
+ * @return output instruction
+ */
+ public static OutputInstruction createOutput(final PortNumber number) {
+ checkNotNull(number, "PortNumber cannot be null");
+ return new OutputInstruction(number);
+ }
+
+ /**
+ * Creates a drop instruction.
+ * @return drop instruction
+ */
+ public static DropInstruction createDrop() {
+ return new DropInstruction();
+ }
+
+ /**
+ * Creates a l2 src modification.
+ * @param addr the mac address to modify to.
+ * @return a l2 modification
+ */
+ public static L2ModificationInstruction modL2Src(MACAddress addr) {
+ checkNotNull(addr, "Src l2 address cannot be null");
+ return new ModEtherInstruction(SubType.L2_SRC, addr);
+ }
+
+ /**
+ * Creates a L2 dst modification.
+ * @param addr the mac address to modify to.
+ * @return a L2 modification
+ */
+ public static L2ModificationInstruction modL2Dst(MACAddress addr) {
+ checkNotNull(addr, "Dst l2 address cannot be null");
+ return new L2ModificationInstruction.ModEtherInstruction(SubType.L2_DST, addr);
+ }
+
+ /**
+ * Creates a L2 type modification.
+ * @param l2Type the type to change to
+ * @return a L2 modifications
+ */
+ public static L2ModificationInstruction modL2Type(Short l2Type) {
+ checkNotNull(l2Type, "L2 type cannot be null");
+ return new L2ModificationInstruction.ModEtherTypeInstruction(l2Type);
+ }
+
+ public static L2ModificationInstruction modVlanId(Short vlanId) {
+ checkNotNull(vlanId, "VLAN id cannot be null");
+ return new L2ModificationInstruction.ModVlanIdInstruction(vlanId);
+ }
+
+ /*
+ * Output instructions
+ */
+
+ public static final class DropInstruction implements Instruction {
+ @Override
+ public Type type() {
+ return Type.DROP;
+ }
+ }
+
+
+ public static final class OutputInstruction implements Instruction {
+ private final PortNumber port;
+
+ private OutputInstruction(PortNumber port) {
+ this.port = port;
+ }
+
+ public PortNumber port() {
+ return port;
+ }
+
+ @Override
+ public Type type() {
+ return Type.OUTPUT;
+ }
+ }
+
+}
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/instructions/L2ModificationInstruction.java b/core/api/src/main/java/org/onlab/onos/net/flow/instructions/L2ModificationInstruction.java
new file mode 100644
index 0000000..f71ad2e
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/instructions/L2ModificationInstruction.java
@@ -0,0 +1,124 @@
+package org.onlab.onos.net.flow.instructions;
+
+import org.onlab.packet.MACAddress;
+
+/**
+ * Abstraction of a single traffic treatment step.
+ * @param <T> the type parameter for the instruction
+ */
+public abstract class L2ModificationInstruction implements Instruction {
+
+ /**
+ * Represents the type of traffic treatment.
+ */
+ public enum SubType {
+ /**
+ * Ether src modification.
+ */
+ L2_SRC,
+
+ /**
+ * Ether dst modification.
+ */
+ L2_DST,
+
+ /**
+ * Ethertype modification.
+ */
+ L2_TYPE,
+
+ /**
+ * VLAN id modification.
+ */
+ VLAN_ID,
+
+ /**
+ * VLAN priority modification.
+ */
+ VLAN_PCP
+ }
+
+ // TODO: Create factory class 'Instructions' that will have various factory
+ // to create specific instructions.
+
+ /**
+ * Returns the subtype of the modification instruction.
+ * @return type of instruction
+ */
+ public abstract SubType subtype();
+
+ @Override
+ public Type type() {
+ return Type.MODIFICATION;
+ }
+
+ /**
+ * Represents a L2 src/dst modification instruction.
+ */
+ public static final class ModEtherInstruction extends L2ModificationInstruction {
+
+ private final SubType subtype;
+ private final MACAddress mac;
+
+ public ModEtherInstruction(SubType subType, MACAddress addr) {
+ this.subtype = subType;
+ this.mac = addr;
+ }
+
+ @Override
+ public SubType subtype() {
+ return this.subtype;
+ }
+
+ public MACAddress mac() {
+ return this.mac;
+ }
+
+ }
+
+ /**
+ * Represents a L2 type modification instruction.
+ */
+ public static final class ModEtherTypeInstruction extends L2ModificationInstruction {
+
+ public final short l2Type;
+
+ public ModEtherTypeInstruction(short l2Type) {
+ this.l2Type = l2Type;
+ }
+
+ @Override
+ public SubType subtype() {
+ return SubType.L2_TYPE;
+ }
+
+ public short l2Type() {
+ return this.l2Type;
+ }
+
+ }
+
+ /**
+ * Represents a VLAN id modification instruction.
+ */
+ public static final class ModVlanIdInstruction extends L2ModificationInstruction {
+
+ public final Short vlanId;
+
+ public ModVlanIdInstruction(Short vlanId) {
+ this.vlanId = vlanId;
+ }
+
+ @Override
+ public SubType subtype() {
+ return SubType.VLAN_ID;
+ }
+
+ public Short vlanId() {
+ return this.vlanId;
+ }
+
+ }
+
+
+}