[ONOS-5939] added traffic selector bitwise match on TCP/UDP/SCTP source/destination port
Change-Id: Ibf5947f7a6cac86fab77d15990116040fd8e5ef5
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 bec8151..6d7bc4b 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
@@ -24,18 +24,32 @@
*/
public final class UdpPortCriterion implements Criterion {
private final TpPort udpPort;
+ private final TpPort mask;
private final Type type;
/**
* Constructor.
*
* @param udpPort the UDP port to match
+ * @param mask the mask for the UDP port
+ * @param type the match type. Should be either Type.UDP_SRC_MASKED or
+ * Type.UDP_DST_MASKED
+ */
+ UdpPortCriterion(TpPort udpPort, TpPort mask, Type type) {
+ this.udpPort = udpPort;
+ this.mask = mask;
+ this.type = type;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param udpPort the UDP port to match
* @param type the match type. Should be either Type.UDP_SRC or
* Type.UDP_DST
*/
UdpPortCriterion(TpPort udpPort, Type type) {
- this.udpPort = udpPort;
- this.type = type;
+ this(udpPort, null, type);
}
@Override
@@ -52,14 +66,25 @@
return this.udpPort;
}
+ /**
+ * Gets the mask for the UDP port to match.
+ *
+ * @return the UDP port mask, null if not specified
+ */
+ public TpPort mask() {
+ return this.mask;
+ }
+
@Override
public String toString() {
- return type().toString() + SEPARATOR + udpPort;
+ return (mask != null) ?
+ type().toString() + SEPARATOR + udpPort + "/" + mask :
+ type().toString() + SEPARATOR + udpPort;
}
@Override
public int hashCode() {
- return Objects.hash(type().ordinal(), udpPort);
+ return Objects.hash(type.ordinal(), udpPort, mask);
}
@Override
@@ -70,6 +95,7 @@
if (obj instanceof UdpPortCriterion) {
UdpPortCriterion that = (UdpPortCriterion) obj;
return Objects.equals(udpPort, that.udpPort) &&
+ Objects.equals(mask, that.mask) &&
Objects.equals(type, that.type);
}
return false;