Refactored driver to use new FlowRule api.
Deprecated transition with table types and added api for transition with table ids.
Change-Id: Ifcf2d87d16810666d992e4d9f5ddca3d0da460be
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
index 7d3525c..f944f4b 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
@@ -289,7 +289,7 @@
return new Builder();
}
- private static final class Builder implements FlowRule.Builder {
+ public static final class Builder implements FlowRule.Builder {
private FlowId flowId;
private Integer priority;
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 01c95bd..fbca078 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
@@ -328,7 +328,12 @@
@Override
public Builder transition(FlowRule.Type type) {
- return add(Instructions.transition(type));
+ return add(Instructions.transition(type.ordinal()));
+ }
+
+ @Override
+ public Builder transition(Integer tableId) {
+ return add(Instructions.transition(tableId));
}
@Override
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 f60e9f2..4e62a2a 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
@@ -230,9 +230,19 @@
* @param type the table type
* @return a treatement builder
*/
+ @Deprecated
public Builder transition(FlowRule.Type type);
/**
+ * Sets the next table id to transition to.
+ *
+ * @param tableId the table table
+ * @return a treatement builder
+ */
+ public Builder transition(Integer tableId);
+
+
+ /**
* Pops outermost VLAN tag.
*
* @return a treatment builder.
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 f422e14..03588b8 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
@@ -22,11 +22,8 @@
import org.onlab.packet.VlanId;
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;
-import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.L3SubType;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction;
@@ -36,12 +33,6 @@
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction;
-import static org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsTtlInstruction;
-import static org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction;
-import static org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction;
-import static org.onosproject.net.flow.instructions.L2ModificationInstruction.PopVlanInstruction;
-import static org.onosproject.net.flow.instructions.L2ModificationInstruction.PushHeaderInstructions;
/**
* Factory class for creating various traffic treatment instructions.
@@ -103,7 +94,8 @@
*/
public static L2ModificationInstruction modL2Src(MacAddress addr) {
checkNotNull(addr, "Src l2 address cannot be null");
- return new ModEtherInstruction(L2SubType.ETH_SRC, addr);
+ return new L2ModificationInstruction.ModEtherInstruction(
+ L2ModificationInstruction.L2SubType.ETH_SRC, addr);
}
/**
@@ -114,7 +106,8 @@
*/
public static L2ModificationInstruction modL2Dst(MacAddress addr) {
checkNotNull(addr, "Dst l2 address cannot be null");
- return new ModEtherInstruction(L2SubType.ETH_DST, addr);
+ return new L2ModificationInstruction.ModEtherInstruction(
+ L2ModificationInstruction.L2SubType.ETH_DST, addr);
}
/**
@@ -125,7 +118,7 @@
*/
public static L2ModificationInstruction modVlanId(VlanId vlanId) {
checkNotNull(vlanId, "VLAN id cannot be null");
- return new ModVlanIdInstruction(vlanId);
+ return new L2ModificationInstruction.ModVlanIdInstruction(vlanId);
}
/**
@@ -136,7 +129,7 @@
*/
public static L2ModificationInstruction modVlanPcp(Byte vlanPcp) {
checkNotNull(vlanPcp, "VLAN Pcp cannot be null");
- return new ModVlanPcpInstruction(vlanPcp);
+ return new L2ModificationInstruction.ModVlanPcpInstruction(vlanPcp);
}
/**
@@ -147,7 +140,7 @@
*/
public static L2ModificationInstruction modMplsLabel(MplsLabel mplsLabel) {
checkNotNull(mplsLabel, "MPLS label cannot be null");
- return new ModMplsLabelInstruction(mplsLabel);
+ return new L2ModificationInstruction.ModMplsLabelInstruction(mplsLabel);
}
/**
@@ -156,7 +149,7 @@
* @return a L2 Modification
*/
public static L2ModificationInstruction decMplsTtl() {
- return new ModMplsTtlInstruction();
+ return new L2ModificationInstruction.ModMplsTtlInstruction();
}
/**
@@ -246,7 +239,8 @@
* @return a L2 modification.
*/
public static Instruction pushMpls() {
- return new PushHeaderInstructions(L2SubType.MPLS_PUSH,
+ return new L2ModificationInstruction.PushHeaderInstructions(
+ L2ModificationInstruction.L2SubType.MPLS_PUSH,
Ethernet.MPLS_UNICAST);
}
@@ -256,7 +250,8 @@
* @return a L2 modification.
*/
public static Instruction popMpls() {
- return new PushHeaderInstructions(L2SubType.MPLS_POP,
+ return new L2ModificationInstruction.PushHeaderInstructions(
+ L2ModificationInstruction.L2SubType.MPLS_POP,
Ethernet.MPLS_UNICAST);
}
@@ -268,7 +263,8 @@
*/
public static Instruction popMpls(Short etherType) {
checkNotNull(etherType, "Ethernet type cannot be null");
- return new PushHeaderInstructions(L2SubType.MPLS_POP, etherType);
+ return new L2ModificationInstruction.PushHeaderInstructions(
+ L2ModificationInstruction.L2SubType.MPLS_POP, etherType);
}
/**
@@ -277,7 +273,8 @@
* @return a L2 modification
*/
public static Instruction popVlan() {
- return new PopVlanInstruction(L2SubType.VLAN_POP);
+ return new L2ModificationInstruction.PopVlanInstruction(
+ L2ModificationInstruction.L2SubType.VLAN_POP);
}
/**
@@ -286,18 +283,19 @@
* @return a L2 modification
*/
public static Instruction pushVlan() {
- return new PushHeaderInstructions(L2SubType.VLAN_PUSH, Ethernet.TYPE_VLAN);
+ return new L2ModificationInstruction.PushHeaderInstructions(
+ L2ModificationInstruction.L2SubType.VLAN_PUSH, Ethernet.TYPE_VLAN);
}
/**
- * Sends the packet to the table described in 'type'.
+ * Sends the packet to the table id.
*
- * @param type flow rule table type
+ * @param tableId flow rule table id
* @return table type transition instruction
*/
- public static Instruction transition(FlowRule.Type type) {
- checkNotNull(type, "Table type cannot be null");
- return new TableTypeTransition(type);
+ public static Instruction transition(Integer tableId) {
+ checkNotNull(tableId, "Table id cannot be null");
+ return new TableTypeTransition(tableId);
}
/**
@@ -421,13 +419,12 @@
}
}
- // 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;
- TableTypeTransition(FlowRule.Type type) {
- this.tableType = type;
+ public static class TableTypeTransition implements Instruction {
+ private final Integer tableId;
+
+ TableTypeTransition(Integer tableId) {
+ this.tableId = tableId;
}
@Override
@@ -435,19 +432,19 @@
return Type.TABLE;
}
- public FlowRule.Type tableType() {
- return this.tableType;
+ public Integer tableId() {
+ return this.tableId;
}
@Override
public String toString() {
return toStringHelper(type().toString())
- .add("tableType", this.tableType).toString();
+ .add("tableId", this.tableId).toString();
}
@Override
public int hashCode() {
- return Objects.hash(type(), tableType);
+ return Objects.hash(type(), tableId);
}
@Override
@@ -457,7 +454,7 @@
}
if (obj instanceof TableTypeTransition) {
TableTypeTransition that = (TableTypeTransition) obj;
- return Objects.equals(tableType, that.tableType);
+ return Objects.equals(tableId, that.tableId);
}
return false;