Added support for matching TCP ports and fixed flow stat IP address matching
diff --git a/providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowEntryBuilder.java b/providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowEntryBuilder.java
index 14c2c22..9f6c658 100644
--- a/providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowEntryBuilder.java
+++ b/providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowEntryBuilder.java
@@ -223,7 +223,7 @@
if (di.isCidrMask()) {
dip = IpPrefix.valueOf(di.getInt(), di.asCidrMaskLength());
} else {
- dip = IpPrefix.valueOf(di.getInt());
+ dip = IpPrefix.valueOf(di.getInt(), IpPrefix.MAX_INET_MASK);
}
builder.matchIPDst(dip);
break;
@@ -233,7 +233,7 @@
if (si.isCidrMask()) {
sip = IpPrefix.valueOf(si.getInt(), si.asCidrMaskLength());
} else {
- sip = IpPrefix.valueOf(si.getInt());
+ sip = IpPrefix.valueOf(si.getInt(), IpPrefix.MAX_INET_MASK);
}
builder.matchIPSrc(sip);
break;
@@ -249,6 +249,12 @@
VlanId vlanId = VlanId.vlanId(match.get(MatchField.VLAN_VID).getVlan());
builder.matchVlanId(vlanId);
break;
+ case TCP_DST:
+ builder.matchTcpDst((short) match.get(MatchField.TCP_DST).getPort());
+ break;
+ case TCP_SRC:
+ builder.matchTcpSrc((short) match.get(MatchField.TCP_SRC).getPort());
+ break;
case ARP_OP:
case ARP_SHA:
case ARP_SPA:
@@ -272,8 +278,6 @@
case MPLS_TC:
case SCTP_DST:
case SCTP_SRC:
- case TCP_DST:
- case TCP_SRC:
case TUNNEL_ID:
case UDP_DST:
case UDP_SRC:
diff --git a/providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowModBuilder.java b/providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowModBuilder.java
index 9568f1f..aa50833 100644
--- a/providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowModBuilder.java
+++ b/providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowModBuilder.java
@@ -15,6 +15,7 @@
import org.onlab.onos.net.flow.criteria.Criteria.IPCriterion;
import org.onlab.onos.net.flow.criteria.Criteria.IPProtocolCriterion;
import org.onlab.onos.net.flow.criteria.Criteria.PortCriterion;
+import org.onlab.onos.net.flow.criteria.Criteria.TcpPortCriterion;
import org.onlab.onos.net.flow.criteria.Criteria.VlanIdCriterion;
import org.onlab.onos.net.flow.criteria.Criteria.VlanPcpCriterion;
import org.onlab.onos.net.flow.criteria.Criterion;
@@ -42,6 +43,7 @@
import org.projectfloodlight.openflow.types.OFBufferId;
import org.projectfloodlight.openflow.types.OFPort;
import org.projectfloodlight.openflow.types.OFVlanVidMatch;
+import org.projectfloodlight.openflow.types.TransportPort;
import org.projectfloodlight.openflow.types.U64;
import org.projectfloodlight.openflow.types.VlanPcp;
import org.projectfloodlight.openflow.types.VlanVid;
@@ -199,6 +201,7 @@
Match.Builder mBuilder = factory.buildMatch();
EthCriterion eth;
IPCriterion ip;
+ TcpPortCriterion tp;
for (Criterion c : selector.criteria()) {
switch (c.type()) {
case IN_PORT:
@@ -250,6 +253,14 @@
mBuilder.setExact(MatchField.VLAN_VID,
OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vid.vlanId().toShort())));
break;
+ case TCP_DST:
+ tp = (TcpPortCriterion) c;
+ mBuilder.setExact(MatchField.TCP_DST, TransportPort.of(tp.tcpPort()));
+ break;
+ case TCP_SRC:
+ tp = (TcpPortCriterion) c;
+ mBuilder.setExact(MatchField.TCP_SRC, TransportPort.of(tp.tcpPort()));
+ break;
case ARP_OP:
case ARP_SHA:
case ARP_SPA:
@@ -276,8 +287,6 @@
case PBB_ISID:
case SCTP_DST:
case SCTP_SRC:
- case TCP_DST:
- case TCP_SRC:
case TUNNEL_ID:
case UDP_DST:
case UDP_SRC: