support for corsa pipeline. EXPERIMENTAL.

Change-Id: Ic3db0a7a18f11c41c8a84f25a249dfb63109da97
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
index 37dcd06..de5c328 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
@@ -249,6 +249,11 @@
         }
 
         @Override
+        public TrafficTreatment.Builder transition(FlowRule.Type type) {
+            return add(Instructions.transition(type));
+        }
+
+        @Override
         public TrafficTreatment build() {
 
             //If we are dropping should we just return an empty list?
diff --git a/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java b/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java
index b03f620..462875a 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java
@@ -40,7 +40,19 @@
         /* Used in flow entry for MPLS table */
         MPLS,
         /* Used in flow entry for ACL table */
-        ACL
+        ACL,
+
+        /* VLAN-to-MPLS table */
+        VLAN_MPLS,
+
+        /* VLAN table */
+        VLAN,
+
+        /* L2 table */
+        ETHER,
+
+        /* Class of Service table */
+        COS,
     }
 
     //TODO: build cookie value
diff --git a/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
index bfb8f2e..e890e62 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
@@ -195,6 +195,15 @@
          */
         public Builder group(GroupId groupId);
 
+
+        /**
+         * Sets the next table type to transition to.
+         *
+         * @param type the table type
+         * @return a treatement builder
+         */
+        public Builder transition(FlowRule.Type type);
+
         /**
          * Builds an immutable traffic treatment descriptor.
          *
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java
index 6f2162f..807aaf8 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/Instruction.java
@@ -50,6 +50,11 @@
         L2MODIFICATION,
 
         /**
+         * Signifies that the traffic should be passed to another table.
+         */
+        TABLE,
+
+        /**
          * Signifies that the traffic should be modified in L3 way.
          */
         L3MODIFICATION
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
index 09ec536..246d21a 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
@@ -23,6 +23,7 @@
 
 import org.onosproject.core.GroupId;
 import org.onosproject.net.PortNumber;
+import org.onosproject.net.flow.FlowRule;
 import org.onosproject.net.flow.instructions.L0ModificationInstruction.L0SubType;
 import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction;
 import org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType;
@@ -254,6 +255,11 @@
         return new PushHeaderInstructions(L2SubType.MPLS_POP, etherType);
     }
 
+    public static Instruction transition(FlowRule.Type type) {
+        checkNotNull(type, "Table type cannot be null");
+        return new TableTypeTransition(type);
+    }
+
     /*
      *  Drop instructions
      */
@@ -352,6 +358,7 @@
         public Type type() {
             return Type.GROUP;
         }
+
         @Override
         public String toString() {
             return toStringHelper(type().toString())
@@ -377,6 +384,49 @@
         }
     }
 
+    // FIXME: Temporary support for this. This should probably become it's own
+    // type like other instructions.
+    public static class TableTypeTransition implements Instruction {
+        private final FlowRule.Type tableType;
+
+        public TableTypeTransition(FlowRule.Type type) {
+            this.tableType = type;
+        }
+
+        @Override
+        public Type type() {
+            return Type.TABLE;
+        }
+
+        public FlowRule.Type tableType() {
+            return this.tableType;
+        }
+
+        @Override
+        public String toString() {
+            return toStringHelper(type().toString())
+                    .add("group ID", this.tableType).toString();
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(type(), tableType);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj instanceof TableTypeTransition) {
+                TableTypeTransition that = (TableTypeTransition) obj;
+                return Objects.equals(tableType, that.tableType);
+
+            }
+            return false;
+        }
+
+    }
 }