ONOS-2711 Replaced short to TpPort for tcp/udp ports

Change-Id: Ibf0474b5369d11d377fd33cf5ab48083cbca3308
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java
index ece32d4..c97b66a 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficSelector.java
@@ -21,6 +21,7 @@
 import org.onlab.packet.IpPrefix;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.MplsLabel;
+import org.onlab.packet.TpPort;
 import org.onlab.packet.VlanId;
 import org.onosproject.net.IndexedLambda;
 import org.onosproject.net.PortNumber;
@@ -208,37 +209,73 @@
             return add(Criteria.matchIPDst(ip));
         }
 
+        @Deprecated
         @Override
         public Builder matchTcpSrc(short tcpPort) {
             return add(Criteria.matchTcpSrc(tcpPort));
         }
 
         @Override
+        public Builder matchTcpSrc(TpPort tcpPort) {
+            return add(Criteria.matchTcpSrc(tcpPort));
+        }
+
+        @Deprecated
+        @Override
         public Builder matchTcpDst(short tcpPort) {
             return add(Criteria.matchTcpDst(tcpPort));
         }
 
         @Override
+        public Builder matchTcpDst(TpPort tcpPort) {
+            return add(Criteria.matchTcpDst(tcpPort));
+        }
+
+        @Deprecated
+        @Override
         public Builder matchUdpSrc(short udpPort) {
             return add(Criteria.matchUdpSrc(udpPort));
         }
 
         @Override
+        public Builder matchUdpSrc(TpPort udpPort) {
+            return add(Criteria.matchUdpSrc(udpPort));
+        }
+
+        @Deprecated
+        @Override
         public Builder matchUdpDst(short udpPort) {
             return add(Criteria.matchUdpDst(udpPort));
         }
 
         @Override
+        public Builder matchUdpDst(TpPort udpPort) {
+            return add(Criteria.matchUdpDst(udpPort));
+        }
+
+        @Deprecated
+        @Override
         public Builder matchSctpSrc(short sctpPort) {
             return add(Criteria.matchSctpSrc(sctpPort));
         }
 
         @Override
+        public Builder matchSctpSrc(TpPort sctpPort) {
+            return add(Criteria.matchSctpSrc(sctpPort));
+        }
+
+        @Deprecated
+        @Override
         public Builder matchSctpDst(short sctpPort) {
             return add(Criteria.matchSctpDst(sctpPort));
         }
 
         @Override
+        public Builder matchSctpDst(TpPort sctpPort) {
+            return add(Criteria.matchSctpDst(sctpPort));
+        }
+
+        @Override
         public Builder matchIcmpType(byte icmpType) {
             return add(Criteria.matchIcmpType(icmpType));
         }
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 f0937a7..8d787c4 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
@@ -22,6 +22,7 @@
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.MplsLabel;
+import org.onlab.packet.TpPort;
 import org.onlab.packet.VlanId;
 import org.onosproject.core.GroupId;
 import org.onosproject.net.IndexedLambda;
@@ -416,27 +417,51 @@
             return add(Instructions.modTunnelId(tunnelId));
         }
 
+        @Deprecated
         @Override
         public TrafficTreatment.Builder setTcpSrc(short port) {
             return add(Instructions.modTcpSrc(port));
         }
 
         @Override
+        public TrafficTreatment.Builder setTcpSrc(TpPort port) {
+            return add(Instructions.modTcpSrc(port));
+        }
+
+        @Deprecated
+        @Override
         public TrafficTreatment.Builder setTcpDst(short port) {
             return add(Instructions.modTcpDst(port));
         }
 
         @Override
+        public TrafficTreatment.Builder setTcpDst(TpPort port) {
+            return add(Instructions.modTcpDst(port));
+        }
+
+        @Deprecated
+        @Override
         public TrafficTreatment.Builder setUdpSrc(short port) {
             return add(Instructions.modUdpSrc(port));
         }
 
         @Override
+        public TrafficTreatment.Builder setUdpSrc(TpPort port) {
+            return add(Instructions.modUdpSrc(port));
+        }
+
+        @Deprecated
+        @Override
         public TrafficTreatment.Builder setUdpDst(short port) {
             return add(Instructions.modUdpDst(port));
         }
 
         @Override
+        public TrafficTreatment.Builder setUdpDst(TpPort port) {
+            return add(Instructions.modUdpDst(port));
+        }
+
+        @Override
         public TrafficTreatment build() {
             //Don't add DROP instruction by default when instruction
             //set is empty. This will be handled in DefaultSingleTablePipeline
diff --git a/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java b/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java
index 8ccc531..f2de9a0 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/TrafficSelector.java
@@ -17,14 +17,15 @@
 
 import java.util.Set;
 
+import org.onlab.packet.Ip6Address;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.MplsLabel;
+import org.onlab.packet.TpPort;
+import org.onlab.packet.VlanId;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.flow.DefaultTrafficSelector.Builder;
 import org.onosproject.net.flow.criteria.Criterion;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.Ip6Address;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.MplsLabel;
-import org.onlab.packet.VlanId;
 
 /**
  * Abstraction of a slice of network traffic.
@@ -170,16 +171,46 @@
          *
          * @param tcpPort a TCP source port number
          * @return a selection builder
+         * @deprecated in Drake release
          */
+        @Deprecated
         Builder matchTcpSrc(short tcpPort);
 
         /**
+         * Matches a TCP source port number.
+         *
+         * @param tcpPort a TCP source port number
+         * @return a selection builder
+         */
+        Builder matchTcpSrc(TpPort tcpPort);
+
+        /**
+         * Matches a TCP destination port number.
+         *
+         * @param tcpPort a TCP destination port number
+         * @return a selection builder
+         * @deprecated in Drake release
+         */
+        @Deprecated
+        Builder matchTcpDst(short tcpPort);
+
+        /**
          * Matches a TCP destination port number.
          *
          * @param tcpPort a TCP destination port number
          * @return a selection builder
          */
-        Builder matchTcpDst(short tcpPort);
+        Builder matchTcpDst(TpPort tcpPort);
+
+        /**
+         * Matches an UDP source port number.
+         *
+         * @param udpPort an UDP source port number
+         * @return a selection builder
+         * @deprecated in Drake release
+         */
+        @Deprecated
+        Builder matchUdpSrc(short udpPort);
 
         /**
          * Matches an UDP source port number.
@@ -187,7 +218,17 @@
          * @param udpPort an UDP source port number
          * @return a selection builder
          */
-        Builder matchUdpSrc(short udpPort);
+        Builder matchUdpSrc(TpPort udpPort);
+
+        /**
+         * Matches an UDP destination port number.
+         *
+         * @param udpPort an UDP destination port number
+         * @return a selection builder
+         * @deprecated in Drake release
+         */
+        @Deprecated
+        Builder matchUdpDst(short udpPort);
 
         /**
          * Matches an UDP destination port number.
@@ -195,7 +236,17 @@
          * @param udpPort an UDP destination port number
          * @return a selection builder
          */
-        Builder matchUdpDst(short udpPort);
+        Builder matchUdpDst(TpPort udpPort);
+
+        /**
+         * Matches a SCTP source port number.
+         *
+         * @param sctpPort a SCTP source port number
+         * @return a selection builder
+         * @deprecated in Drake release
+         */
+        @Deprecated
+        Builder matchSctpSrc(short sctpPort);
 
         /**
          * Matches a SCTP source port number.
@@ -203,7 +254,17 @@
          * @param sctpPort a SCTP source port number
          * @return a selection builder
          */
-        Builder matchSctpSrc(short sctpPort);
+        Builder matchSctpSrc(TpPort sctpPort);
+
+        /**
+         * Matches a SCTP destination port number.
+         *
+         * @param sctpPort a SCTP destination port number
+         * @return a selection builder
+         * @deprecated in Drake release
+         */
+        @Deprecated
+        Builder matchSctpDst(short sctpPort);
 
         /**
          * Matches a SCTP destination port number.
@@ -211,7 +272,7 @@
          * @param sctpPort a SCTP destination port number
          * @return a selection builder
          */
-        Builder matchSctpDst(short sctpPort);
+        Builder matchSctpDst(TpPort sctpPort);
 
         /**
          * Matches an ICMP type.
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 b982199..1ce669c 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
@@ -19,6 +19,7 @@
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.MplsLabel;
+import org.onlab.packet.TpPort;
 import org.onlab.packet.VlanId;
 import org.onosproject.core.GroupId;
 import org.onosproject.net.PortNumber;
@@ -346,16 +347,46 @@
          *
          * @param port a port number
          * @return a treatment builder
+         * @deprecated in Drake release
          */
+        @Deprecated
         Builder setTcpSrc(short port);
 
         /**
+         * Sets the src TCP port.
+         *
+         * @param port a port number
+         * @return a treatment builder
+         */
+        Builder setTcpSrc(TpPort port);
+
+        /**
+         * Sets the dst TCP port.
+         *
+         * @param port a port number
+         * @return a treatment builder
+         * @deprecated in Drake release
+         */
+        @Deprecated
+        Builder setTcpDst(short port);
+
+        /**
          * Sets the dst TCP port.
          *
          * @param port a port number
          * @return a treatment builder
          */
-        Builder setTcpDst(short port);
+        Builder setTcpDst(TpPort port);
+
+        /**
+         * Sets the src UDP port.
+         *
+         * @param port a port number
+         * @return a treatment builder
+         * @deprecated in Drake release
+         */
+        @Deprecated
+        Builder setUdpSrc(short port);
 
         /**
          * Sets the src UDP port.
@@ -363,7 +394,17 @@
          * @param port a port number
          * @return a treatment builder
          */
-        Builder setUdpSrc(short port);
+        Builder setUdpSrc(TpPort port);
+
+        /**
+         * Sets the dst UDP port.
+         *
+         * @param port a port number
+         * @return a treatment builder
+         * @deprecated in Drake release
+         */
+        @Deprecated
+        Builder setUdpDst(short port);
 
         /**
          * Sets the dst UDP port.
@@ -371,7 +412,7 @@
          * @param port a port number
          * @return a treatment builder
          */
-        Builder setUdpDst(short port);
+        Builder setUdpDst(TpPort port);
 
         /**
          * Builds an immutable traffic treatment descriptor.
diff --git a/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java b/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java
index 4d05be1..0252cfb 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/criteria/Criteria.java
@@ -16,16 +16,17 @@
 package org.onosproject.net.flow.criteria;
 
 import org.onlab.packet.EthType;
+import org.onlab.packet.Ip6Address;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.MplsLabel;
+import org.onlab.packet.TpPort;
+import org.onlab.packet.VlanId;
 import org.onosproject.net.IndexedLambda;
 import org.onosproject.net.Lambda;
 import org.onosproject.net.OchSignal;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.flow.criteria.Criterion.Type;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.Ip6Address;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.MplsLabel;
-import org.onlab.packet.VlanId;
 import org.onosproject.net.OchSignalType;
 
 /**
@@ -184,50 +185,110 @@
     /**
      * Creates a match on TCP source port field using the specified value.
      *
-     * @param tcpPort TCP source port (16 bits unsigned integer)
+     * @param tcpPort TCP source port
+     * @return match criterion
+     * @deprecated in Drake release
+     */
+    @Deprecated
+    public static Criterion matchTcpSrc(short tcpPort) {
+        return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_SRC);
+    }
+
+    /**
+     * Creates a match on TCP source port field using the specified value.
+     *
+     * @param tcpPort TCP source port
      * @return match criterion
      */
-    public static Criterion matchTcpSrc(int tcpPort) {
+    public static Criterion matchTcpSrc(TpPort tcpPort) {
         return new TcpPortCriterion(tcpPort, Type.TCP_SRC);
     }
 
     /**
      * Creates a match on TCP destination port field using the specified value.
      *
-     * @param tcpPort TCP destination port (16 bits unsigned integer)
+     * @param tcpPort TCP destination port
+     * @return match criterion
+     * @deprecated in Drake release
+     */
+    @Deprecated
+    public static Criterion matchTcpDst(short tcpPort) {
+        return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_DST);
+    }
+
+    /**
+     * Creates a match on TCP destination port field using the specified value.
+     *
+     * @param tcpPort TCP destination port
      * @return match criterion
      */
-    public static Criterion matchTcpDst(int tcpPort) {
+    public static Criterion matchTcpDst(TpPort tcpPort) {
         return new TcpPortCriterion(tcpPort, Type.TCP_DST);
     }
 
     /**
      * Creates a match on UDP source port field using the specified value.
      *
-     * @param udpPort UDP source port (16 bits unsigned integer)
+     * @param udpPort UDP source port
+     * @return match criterion
+     * @deprecated in Drake release
+     */
+    @Deprecated
+    public static Criterion matchUdpSrc(short udpPort) {
+        return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_SRC);
+    }
+
+    /**
+     * Creates a match on UDP source port field using the specified value.
+     *
+     * @param udpPort UDP source port
      * @return match criterion
      */
-    public static Criterion matchUdpSrc(int udpPort) {
+    public static Criterion matchUdpSrc(TpPort udpPort) {
         return new UdpPortCriterion(udpPort, Type.UDP_SRC);
     }
 
     /**
      * Creates a match on UDP destination port field using the specified value.
      *
-     * @param udpPort UDP destination port (16 bits unsigned integer)
+     * @param udpPort UDP destination port
+     * @return match criterion
+     * @deprecated in Drake release
+     */
+    @Deprecated
+    public static Criterion matchUdpDst(short udpPort) {
+        return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_DST);
+    }
+
+    /**
+     * Creates a match on UDP destination port field using the specified value.
+     *
+     * @param udpPort UDP destination port
      * @return match criterion
      */
-    public static Criterion matchUdpDst(int udpPort) {
+    public static Criterion matchUdpDst(TpPort udpPort) {
         return new UdpPortCriterion(udpPort, Type.UDP_DST);
     }
 
     /**
      * Creates a match on SCTP source port field using the specified value.
      *
-     * @param sctpPort SCTP source port (16 bits unsigned integer)
+     * @param sctpPort SCTP source port
+     * @return match criterion
+     * @deprecated in Drake release
+     */
+    @Deprecated
+    public static Criterion matchSctpSrc(short sctpPort) {
+        return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_SRC);
+    }
+
+    /**
+     * Creates a match on SCTP source port field using the specified value.
+     *
+     * @param sctpPort SCTP source port
      * @return match criterion
      */
-    public static Criterion matchSctpSrc(int sctpPort) {
+    public static Criterion matchSctpSrc(TpPort sctpPort) {
         return new SctpPortCriterion(sctpPort, Type.SCTP_SRC);
     }
 
@@ -235,10 +296,23 @@
      * Creates a match on SCTP destination port field using the specified
      * value.
      *
-     * @param sctpPort SCTP destination port (16 bits unsigned integer)
+     * @param sctpPort SCTP destination port
+     * @return match criterion
+     * @deprecated in Drake release
+     */
+    @Deprecated
+    public static Criterion matchSctpDst(short sctpPort) {
+        return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_DST);
+    }
+
+    /**
+     * Creates a match on SCTP destination port field using the specified
+     * value.
+     *
+     * @param sctpPort SCTP destination port
      * @return match criterion
      */
-    public static Criterion matchSctpDst(int sctpPort) {
+    public static Criterion matchSctpDst(TpPort sctpPort) {
         return new SctpPortCriterion(sctpPort, Type.SCTP_DST);
     }
 
diff --git a/core/api/src/main/java/org/onosproject/net/flow/criteria/SctpPortCriterion.java b/core/api/src/main/java/org/onosproject/net/flow/criteria/SctpPortCriterion.java
index a8e8e56..2d4cf15 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/criteria/SctpPortCriterion.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/criteria/SctpPortCriterion.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.net.flow.criteria;
 
+import org.onlab.packet.TpPort;
+
 import java.util.Objects;
 
 import static com.google.common.base.MoreObjects.toStringHelper;
@@ -23,19 +25,18 @@
  * Implementation of SCTP port criterion (16 bits unsigned integer).
  */
 public final class SctpPortCriterion implements Criterion {
-    private static final int MASK = 0xffff;
-    private final int sctpPort;             // Port value: 16 bits
+    private final TpPort sctpPort;
     private final Type type;
 
     /**
      * Constructor.
      *
-     * @param sctpPort the SCTP port to match (16 bits unsigned integer)
+     * @param sctpPort the SCTP port to match
      * @param type the match type. Should be either Type.SCTP_SRC or
      * Type.SCTP_DST
      */
-    SctpPortCriterion(int sctpPort, Type type) {
-        this.sctpPort = sctpPort & MASK;
+    SctpPortCriterion(TpPort sctpPort, Type type) {
+        this.sctpPort = sctpPort;
         this.type = type;
     }
 
@@ -47,9 +48,9 @@
     /**
      * Gets the SCTP port to match.
      *
-     * @return the SCTP port to match (16 bits unsigned integer)
+     * @return the SCTP port to match
      */
-    public int sctpPort() {
+    public TpPort sctpPort() {
         return this.sctpPort;
     }
 
diff --git a/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpPortCriterion.java b/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpPortCriterion.java
index 3f15375..e682b23 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpPortCriterion.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/criteria/TcpPortCriterion.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.net.flow.criteria;
 
+import org.onlab.packet.TpPort;
+
 import java.util.Objects;
 
 import static com.google.common.base.MoreObjects.toStringHelper;
@@ -23,19 +25,18 @@
  * Implementation of TCP port criterion (16 bits unsigned integer).
  */
 public final class TcpPortCriterion implements Criterion {
-    private static final int MASK = 0xffff;
-    private final int tcpPort;              // Port value: 16 bits
+    private final TpPort tcpPort;
     private final Type type;
 
     /**
      * Constructor.
      *
-     * @param tcpPort the TCP port to match (16 bits unsigned integer)
+     * @param tcpPort the TCP port to match
      * @param type the match type. Should be either Type.TCP_SRC or
      * Type.TCP_DST
      */
-    TcpPortCriterion(int tcpPort, Type type) {
-        this.tcpPort = tcpPort & MASK;
+    TcpPortCriterion(TpPort tcpPort, Type type) {
+        this.tcpPort = tcpPort;
         this.type = type;
     }
 
@@ -47,9 +48,9 @@
     /**
      * Gets the TCP port to match.
      *
-     * @return the TCP port to match (16 bits unsigned integer)
+     * @return the TCP port to match
      */
-    public int tcpPort() {
+    public TpPort tcpPort() {
         return this.tcpPort;
     }
 
diff --git a/core/api/src/main/java/org/onosproject/net/flow/criteria/UdpPortCriterion.java b/core/api/src/main/java/org/onosproject/net/flow/criteria/UdpPortCriterion.java
index 9764021..8a29f47 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/criteria/UdpPortCriterion.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/criteria/UdpPortCriterion.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.net.flow.criteria;
 
+import org.onlab.packet.TpPort;
+
 import java.util.Objects;
 
 import static com.google.common.base.MoreObjects.toStringHelper;
@@ -23,19 +25,18 @@
  * Implementation of UDP port criterion (16 bits unsigned integer).
  */
 public final class UdpPortCriterion implements Criterion {
-    private static final int MASK = 0xffff;
-    private final int udpPort;              // Port value: 16 bits
+    private final TpPort udpPort;
     private final Type type;
 
     /**
      * Constructor.
      *
-     * @param udpPort the UDP port to match (16 bits unsigned integer)
+     * @param udpPort the UDP port to match
      * @param type the match type. Should be either Type.UDP_SRC or
      * Type.UDP_DST
      */
-    UdpPortCriterion(int udpPort, Type type) {
-        this.udpPort = udpPort & MASK;
+    UdpPortCriterion(TpPort udpPort, Type type) {
+        this.udpPort = udpPort;
         this.type = type;
     }
 
@@ -47,9 +48,9 @@
     /**
      * Gets the UDP port to match.
      *
-     * @return the UDP port to match (16 bits unsigned integer)
+     * @return the UDP port to match
      */
-    public int udpPort() {
+    public TpPort udpPort() {
         return this.udpPort;
     }
 
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 97f57db..c5358a2 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
@@ -19,6 +19,7 @@
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.MplsLabel;
+import org.onlab.packet.TpPort;
 import org.onlab.packet.VlanId;
 import org.onosproject.core.GroupId;
 import org.onosproject.net.IndexedLambda;
@@ -383,9 +384,22 @@
      *
      * @param port the TCP port number to modify to
      * @return a L4 modification
+     * @deprecated in Drake release
      */
+    @Deprecated
     public static L4ModificationInstruction modTcpSrc(short port) {
        checkNotNull(port, "Src TCP port cannot be null");
+       return new ModTransportPortInstruction(L4SubType.TCP_SRC, TpPort.tpPort(port));
+    }
+
+    /**
+     * Creates a TCP src modification.
+     *
+     * @param port the TCP port number to modify to
+     * @return a L4 modification
+     */
+    public static L4ModificationInstruction modTcpSrc(TpPort port) {
+       checkNotNull(port, "Src TCP port cannot be null");
        return new ModTransportPortInstruction(L4SubType.TCP_SRC, port);
     }
 
@@ -394,9 +408,22 @@
      *
      * @param port the TCP port number to modify to
      * @return a L4 modification
+     * @deprecated in Drake release
      */
+    @Deprecated
     public static L4ModificationInstruction modTcpDst(short port) {
         checkNotNull(port, "Dst TCP port cannot be null");
+        return new ModTransportPortInstruction(L4SubType.TCP_DST, TpPort.tpPort(port));
+    }
+
+    /**
+     * Creates a TCP dst modification.
+     *
+     * @param port the TCP port number to modify to
+     * @return a L4 modification
+     */
+    public static L4ModificationInstruction modTcpDst(TpPort port) {
+        checkNotNull(port, "Dst TCP port cannot be null");
         return new ModTransportPortInstruction(L4SubType.TCP_DST, port);
     }
 
@@ -405,9 +432,22 @@
      *
      * @param port the UDP port number to modify to
      * @return a L4 modification
+     * @deprecated in Drake release
      */
+    @Deprecated
     public static L4ModificationInstruction modUdpSrc(short port) {
         checkNotNull(port, "Src UDP port cannot be null");
+        return new ModTransportPortInstruction(L4SubType.UDP_SRC, TpPort.tpPort(port));
+    }
+
+    /**
+     * Creates a UDP src modification.
+     *
+     * @param port the UDP port number to modify to
+     * @return a L4 modification
+     */
+    public static L4ModificationInstruction modUdpSrc(TpPort port) {
+        checkNotNull(port, "Src UDP port cannot be null");
         return new ModTransportPortInstruction(L4SubType.UDP_SRC, port);
     }
 
@@ -416,9 +456,22 @@
      *
      * @param port the UDP port number to modify to
      * @return a L4 modification
+     * @deprecated in Drake release
      */
+    @Deprecated
     public static L4ModificationInstruction modUdpDst(short port) {
         checkNotNull(port, "Dst UDP port cannot be null");
+        return new ModTransportPortInstruction(L4SubType.UDP_DST, TpPort.tpPort(port));
+    }
+
+    /**
+     * Creates a UDP dst modification.
+     *
+     * @param port the UDP port number to modify to
+     * @return a L4 modification
+     */
+    public static L4ModificationInstruction modUdpDst(TpPort port) {
+        checkNotNull(port, "Dst UDP port cannot be null");
         return new ModTransportPortInstruction(L4SubType.UDP_DST, port);
     }
 
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/L4ModificationInstruction.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/L4ModificationInstruction.java
index c78f639..441a2c5 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/L4ModificationInstruction.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/L4ModificationInstruction.java
@@ -15,6 +15,8 @@
  */
 package org.onosproject.net.flow.instructions;
 
+import org.onlab.packet.TpPort;
+
 import java.util.Objects;
 
 import static com.google.common.base.MoreObjects.toStringHelper;
@@ -69,9 +71,9 @@
     public static final class ModTransportPortInstruction extends L4ModificationInstruction {
 
         private final L4SubType subtype;
-        private final short port;
+        private final TpPort port;
 
-        public ModTransportPortInstruction(L4SubType subtype, short port) {
+        public ModTransportPortInstruction(L4SubType subtype, TpPort port) {
             this.subtype = subtype;
             this.port = port;
         }
@@ -81,7 +83,7 @@
             return this.subtype;
         }
 
-        public short port() {
+        public TpPort port() {
             return this.port;
         }
 
diff --git a/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficSelectorTest.java b/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficSelectorTest.java
index f7050ec..b871397 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficSelectorTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficSelectorTest.java
@@ -22,15 +22,16 @@
 import org.hamcrest.Matcher;
 import org.hamcrest.TypeSafeMatcher;
 import org.junit.Test;
-import org.onosproject.net.IndexedLambda;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.criteria.Criteria;
-import org.onosproject.net.flow.criteria.Criterion;
 import org.onlab.packet.Ip6Address;
 import org.onlab.packet.IpPrefix;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.MplsLabel;
+import org.onlab.packet.TpPort;
 import org.onlab.packet.VlanId;
+import org.onosproject.net.IndexedLambda;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.flow.criteria.Criteria;
+import org.onosproject.net.flow.criteria.Criterion;
 
 import com.google.common.testing.EqualsTester;
 
@@ -196,27 +197,27 @@
         assertThat(selector, hasCriterionWithType(Type.IPV4_DST));
 
         selector = DefaultTrafficSelector.builder()
-                .matchTcpSrc(shortValue).build();
+                .matchTcpSrc(TpPort.tpPort(intValue)).build();
         assertThat(selector, hasCriterionWithType(Type.TCP_SRC));
 
         selector = DefaultTrafficSelector.builder()
-                .matchTcpDst(shortValue).build();
+                .matchTcpDst(TpPort.tpPort(intValue)).build();
         assertThat(selector, hasCriterionWithType(Type.TCP_DST));
 
         selector = DefaultTrafficSelector.builder()
-                .matchUdpSrc(shortValue).build();
+                .matchUdpSrc(TpPort.tpPort(intValue)).build();
         assertThat(selector, hasCriterionWithType(Type.UDP_SRC));
 
         selector = DefaultTrafficSelector.builder()
-                .matchUdpDst(shortValue).build();
+                .matchUdpDst(TpPort.tpPort(intValue)).build();
         assertThat(selector, hasCriterionWithType(Type.UDP_DST));
 
         selector = DefaultTrafficSelector.builder()
-                .matchSctpSrc(shortValue).build();
+                .matchSctpSrc(TpPort.tpPort(intValue)).build();
         assertThat(selector, hasCriterionWithType(Type.SCTP_SRC));
 
         selector = DefaultTrafficSelector.builder()
-                .matchSctpDst(shortValue).build();
+                .matchSctpDst(TpPort.tpPort(intValue)).build();
         assertThat(selector, hasCriterionWithType(Type.SCTP_DST));
 
         selector = DefaultTrafficSelector.builder()
diff --git a/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java b/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
index de60b69..ee294f6 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/criteria/CriteriaTest.java
@@ -17,15 +17,16 @@
 
 import org.junit.Test;
 import org.onlab.packet.EthType;
+import org.onlab.packet.Ip6Address;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.MplsLabel;
+import org.onlab.packet.TpPort;
+import org.onlab.packet.VlanId;
 import org.onosproject.net.ChannelSpacing;
 import org.onosproject.net.GridType;
 import org.onosproject.net.Lambda;
 import org.onosproject.net.PortNumber;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.Ip6Address;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.MplsLabel;
-import org.onlab.packet.VlanId;
 
 import com.google.common.testing.EqualsTester;
 import org.onosproject.net.OchSignalType;
@@ -122,17 +123,19 @@
     Criterion sameAsMatchIpv61 = Criteria.matchIPSrc(ipv61);
     Criterion matchIpv62 = Criteria.matchIPSrc(ipv62);
 
-    Criterion matchTcpPort1 = Criteria.matchTcpSrc(1);
-    Criterion sameAsMatchTcpPort1 = Criteria.matchTcpSrc(1);
-    Criterion matchTcpPort2 = Criteria.matchTcpDst(2);
+    private TpPort tpPort1 = TpPort.tpPort(1);
+    private TpPort tpPort2 = TpPort.tpPort(2);
+    Criterion matchTcpPort1 = Criteria.matchTcpSrc(tpPort1);
+    Criterion sameAsMatchTcpPort1 = Criteria.matchTcpSrc(tpPort1);
+    Criterion matchTcpPort2 = Criteria.matchTcpDst(tpPort2);
 
-    Criterion matchUdpPort1 = Criteria.matchUdpSrc(1);
-    Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc(1);
-    Criterion matchUdpPort2 = Criteria.matchUdpDst(2);
+    Criterion matchUdpPort1 = Criteria.matchUdpSrc(tpPort1);
+    Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc(tpPort1);
+    Criterion matchUdpPort2 = Criteria.matchUdpDst(tpPort2);
 
-    Criterion matchSctpPort1 = Criteria.matchSctpSrc(1);
-    Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc(1);
-    Criterion matchSctpPort2 = Criteria.matchSctpDst(2);
+    Criterion matchSctpPort1 = Criteria.matchSctpSrc(tpPort1);
+    Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc(tpPort1);
+    Criterion matchSctpPort2 = Criteria.matchSctpDst(tpPort2);
 
     short icmpType1 = 1;
     short icmpType2 = 2;
@@ -652,12 +655,12 @@
      */
     @Test
     public void testMatchTcpSrcMethod() {
-        Criterion matchTcpSrc = Criteria.matchTcpSrc(1);
+        Criterion matchTcpSrc = Criteria.matchTcpSrc(tpPort1);
         TcpPortCriterion tcpPortCriterion =
                 checkAndConvert(matchTcpSrc,
                                 Criterion.Type.TCP_SRC,
                                 TcpPortCriterion.class);
-        assertThat(tcpPortCriterion.tcpPort(), is(equalTo(1)));
+        assertThat(tcpPortCriterion.tcpPort(), is(equalTo(tpPort1)));
     }
 
     /**
@@ -665,12 +668,12 @@
      */
     @Test
     public void testMatchTcpDstMethod() {
-        Criterion matchTcpDst = Criteria.matchTcpDst(1);
+        Criterion matchTcpDst = Criteria.matchTcpDst(tpPort1);
         TcpPortCriterion tcpPortCriterion =
                 checkAndConvert(matchTcpDst,
                         Criterion.Type.TCP_DST,
                         TcpPortCriterion.class);
-        assertThat(tcpPortCriterion.tcpPort(), is(equalTo(1)));
+        assertThat(tcpPortCriterion.tcpPort(), is(equalTo(tpPort1)));
     }
 
     /**
@@ -691,12 +694,12 @@
      */
     @Test
     public void testMatchUdpSrcMethod() {
-        Criterion matchUdpSrc = Criteria.matchUdpSrc(1);
+        Criterion matchUdpSrc = Criteria.matchUdpSrc(tpPort1);
         UdpPortCriterion udpPortCriterion =
                 checkAndConvert(matchUdpSrc,
                                 Criterion.Type.UDP_SRC,
                                 UdpPortCriterion.class);
-        assertThat(udpPortCriterion.udpPort(), is(equalTo(1)));
+        assertThat(udpPortCriterion.udpPort(), is(equalTo(tpPort1)));
     }
 
     /**
@@ -704,12 +707,12 @@
      */
     @Test
     public void testMatchUdpDstMethod() {
-        Criterion matchUdpDst = Criteria.matchUdpDst(1);
+        Criterion matchUdpDst = Criteria.matchUdpDst(tpPort1);
         UdpPortCriterion udpPortCriterion =
                 checkAndConvert(matchUdpDst,
                         Criterion.Type.UDP_DST,
                         UdpPortCriterion.class);
-        assertThat(udpPortCriterion.udpPort(), is(equalTo(1)));
+        assertThat(udpPortCriterion.udpPort(), is(equalTo(tpPort1)));
     }
 
     /**
@@ -730,12 +733,12 @@
      */
     @Test
     public void testMatchSctpSrcMethod() {
-        Criterion matchSctpSrc = Criteria.matchSctpSrc(1);
+        Criterion matchSctpSrc = Criteria.matchSctpSrc(tpPort1);
         SctpPortCriterion sctpPortCriterion =
                 checkAndConvert(matchSctpSrc,
                                 Criterion.Type.SCTP_SRC,
                                 SctpPortCriterion.class);
-        assertThat(sctpPortCriterion.sctpPort(), is(equalTo(1)));
+        assertThat(sctpPortCriterion.sctpPort(), is(equalTo(tpPort1)));
     }
 
     /**
@@ -743,12 +746,12 @@
      */
     @Test
     public void testMatchSctpDstMethod() {
-        Criterion matchSctpDst = Criteria.matchSctpDst(1);
+        Criterion matchSctpDst = Criteria.matchSctpDst(tpPort1);
         SctpPortCriterion sctpPortCriterion =
                 checkAndConvert(matchSctpDst,
                         Criterion.Type.SCTP_DST,
                         SctpPortCriterion.class);
-        assertThat(sctpPortCriterion.sctpPort(), is(equalTo(1)));
+        assertThat(sctpPortCriterion.sctpPort(), is(equalTo(tpPort1)));
     }
 
     /**
diff --git a/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java b/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
index e33e9d7f..d365e92 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
@@ -16,15 +16,16 @@
 package org.onosproject.net.flow.instructions;
 
 import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.MplsLabel;
+import org.onlab.packet.TpPort;
+import org.onlab.packet.VlanId;
 import org.onosproject.net.ChannelSpacing;
 import org.onosproject.net.GridType;
 import org.onosproject.net.IndexedLambda;
 import org.onosproject.net.Lambda;
 import org.onosproject.net.PortNumber;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.MplsLabel;
-import org.onlab.packet.VlanId;
 
 import com.google.common.testing.EqualsTester;
 
@@ -638,22 +639,22 @@
 
     // ModTransportPortInstruction
 
-    private final short l4port1 = 1;
-    private final short l4port2 = 2;
-    private final Instruction modTransportPortInstruction1 = Instructions.modTcpSrc(l4port1);
-    private final Instruction sameAsModTransportPortInstruction1 = Instructions.modTcpSrc(l4port1);
-    private final Instruction modTransportPortInstruction2 = Instructions.modTcpSrc(l4port2);
+    private final TpPort tpPort1 = TpPort.tpPort(1);
+    private final TpPort tpPort2 = TpPort.tpPort(2);
+    private final Instruction modTransportPortInstruction1 = Instructions.modTcpSrc(tpPort1);
+    private final Instruction sameAsModTransportPortInstruction1 = Instructions.modTcpSrc(tpPort1);
+    private final Instruction modTransportPortInstruction2 = Instructions.modTcpSrc(tpPort2);
 
     /**
      * Test the modTcpSrc() method.
      */
     @Test
     public void testModTcpSrcMethod() {
-        final Instruction instruction = Instructions.modTcpSrc(l4port1);
+        final Instruction instruction = Instructions.modTcpSrc(tpPort1);
         final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction =
                 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION,
                                 L4ModificationInstruction.ModTransportPortInstruction.class);
-        assertThat(modTransportPortInstruction.port(), is(equalTo(l4port1)));
+        assertThat(modTransportPortInstruction.port(), is(equalTo(tpPort1)));
         assertThat(modTransportPortInstruction.subtype(),
                    is(equalTo(L4ModificationInstruction.L4SubType.TCP_SRC)));
     }
@@ -663,11 +664,11 @@
      */
     @Test
     public void testModTcpDstMethod() {
-        final Instruction instruction = Instructions.modTcpDst(l4port1);
+        final Instruction instruction = Instructions.modTcpDst(tpPort1);
         final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction =
                 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION,
                                 L4ModificationInstruction.ModTransportPortInstruction.class);
-        assertThat(modTransportPortInstruction.port(), is(equalTo(l4port1)));
+        assertThat(modTransportPortInstruction.port(), is(equalTo(tpPort1)));
         assertThat(modTransportPortInstruction.subtype(),
                    is(equalTo(L4ModificationInstruction.L4SubType.TCP_DST)));
     }
@@ -677,11 +678,11 @@
      */
     @Test
     public void testModUdpSrcMethod() {
-        final Instruction instruction = Instructions.modUdpSrc(l4port1);
+        final Instruction instruction = Instructions.modUdpSrc(tpPort1);
         final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction =
                 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION,
                                 L4ModificationInstruction.ModTransportPortInstruction.class);
-        assertThat(modTransportPortInstruction.port(), is(equalTo(l4port1)));
+        assertThat(modTransportPortInstruction.port(), is(equalTo(tpPort1)));
         assertThat(modTransportPortInstruction.subtype(),
                    is(equalTo(L4ModificationInstruction.L4SubType.UDP_SRC)));
     }
@@ -691,11 +692,11 @@
      */
     @Test
     public void testModUdpDstMethod() {
-        final Instruction instruction = Instructions.modUdpDst(l4port1);
+        final Instruction instruction = Instructions.modUdpDst(tpPort1);
         final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction =
                 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION,
                                 L4ModificationInstruction.ModTransportPortInstruction.class);
-        assertThat(modTransportPortInstruction.port(), is(equalTo(l4port1)));
+        assertThat(modTransportPortInstruction.port(), is(equalTo(tpPort1)));
         assertThat(modTransportPortInstruction.subtype(),
                    is(equalTo(L4ModificationInstruction.L4SubType.UDP_DST)));
     }