ONOS-2403 Support setting TCP/UDP port action in flow rule for OpenFlow13
Change-Id: I4ce84aba9db03a66ebcfb34959c11cc4acadb07b
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 0467a91..3cacfa5 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
@@ -32,6 +32,8 @@
import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction;
import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModTtlInstruction;
+import org.onosproject.net.flow.instructions.L4ModificationInstruction.L4SubType;
+import org.onosproject.net.flow.instructions.L4ModificationInstruction.ModTransportPortInstruction;
import java.util.Objects;
@@ -361,6 +363,50 @@
}
/**
+ * Creates a TCP src modification.
+ *
+ * @param port the TCP port number to modify to
+ * @return a L4 modification
+ */
+ public static L4ModificationInstruction modTcpSrc(short port) {
+ checkNotNull(port, "Src TCP port cannot be null");
+ return new ModTransportPortInstruction(L4SubType.TCP_SRC, port);
+ }
+
+ /**
+ * Creates a TCP dst modification.
+ *
+ * @param port the TCP port number to modify to
+ * @return a L4 modification
+ */
+ public static L4ModificationInstruction modTcpDst(short port) {
+ checkNotNull(port, "Dst TCP port cannot be null");
+ return new ModTransportPortInstruction(L4SubType.TCP_DST, port);
+ }
+
+ /**
+ * Creates a UDP src modification.
+ *
+ * @param port the UDP port number to modify to
+ * @return a L4 modification
+ */
+ public static L4ModificationInstruction modUdpSrc(short port) {
+ checkNotNull(port, "Src UDP port cannot be null");
+ return new ModTransportPortInstruction(L4SubType.UDP_SRC, port);
+ }
+
+ /**
+ * Creates a UDP dst modification.
+ *
+ * @param port the UDP port number to modify to
+ * @return a L4 modification
+ */
+ public static L4ModificationInstruction modUdpDst(short port) {
+ checkNotNull(port, "Dst UDP port cannot be null");
+ return new ModTransportPortInstruction(L4SubType.UDP_DST, port);
+ }
+
+ /**
* Drop instruction.
*/
public static final class DropInstruction implements Instruction {