Fixed minimum values for TP_SRC/TP_DST match fields. 22/822/1
authorHideyuki Tai <h-tai@cd.jp.nec.com>
Wed, 7 Aug 2013 16:53:28 +0000 (12:53 -0400)
committerHideyuki Tai <h-tai@cd.jp.nec.com>
Wed, 7 Aug 2013 16:53:28 +0000 (12:53 -0400)
In OpenFlow 1.0, the tp_src and tp_dst match fields are used for transport source/destination ports or ICMP type/code.
Therefore, the range of the fields must include 0.

Change-Id: I7011109ced925e198ec2785f5ed9dc9a8e81623c
Signed-off-by: Hideyuki Tai <h-tai@cd.jp.nec.com>
opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java
opendaylight/forwardingrulesmanager/api/src/test/java/org/opendaylight/controller/forwardingrulesmanager/frmTest.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/MatchType.java
opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/match/MatchTest.java
opendaylight/web/flows/src/main/resources/js/page.js

index 1ac7cb2f51360e634dec98e33857c848ce48e069..5db7d32745f12b3bd8e264222291ae8d4cf766c6 100644 (file)
@@ -647,7 +647,7 @@ public class FlowConfig implements Serializable {
 
     public boolean isTpPortValid(String tpPort) {
         int port = Integer.decode(tpPort);
-        return ((port > 0) && (port <= 0xffff));
+        return ((port >= 0) && (port <= 0xffff));
     }
 
     public boolean isTimeoutValid(String timeout) {
index fc22ee7dddaef5752bd03647e2e4830c0f77205d..176d8e9ebdfea8a2f0bb341eed68177d69a235ed 100644 (file)
@@ -611,9 +611,15 @@ public class frmTest {
         Assert.assertFalse(status.isSuccess());
         Assert.assertTrue(status.getDescription().contains("Transport source port"));
 
+        fc.setSrcPort("0");
+        Assert.assertTrue(fc.validate(null).isSuccess());
+
         fc.setSrcPort("0x00ff");
         Assert.assertTrue(fc.validate(null).isSuccess());
 
+        fc.setSrcPort("0xffff");
+        Assert.assertTrue(fc.validate(null).isSuccess());
+
         fc.setDstPort("-1");
         status = fc.validate(null);
         Assert.assertFalse(status.isSuccess());
@@ -624,9 +630,15 @@ public class frmTest {
         Assert.assertFalse(status.isSuccess());
         Assert.assertTrue(status.getDescription().contains("Transport destination port"));
 
+        fc.setDstPort("0");
+        Assert.assertTrue(fc.validate(null).isSuccess());
+
         fc.setDstPort("0x00ff");
         Assert.assertTrue(fc.validate(null).isSuccess());
 
+        fc.setDstPort("0xffff");
+        Assert.assertTrue(fc.validate(null).isSuccess());
+
         fc.setSrcMac("abc");
         status = fc.validate(null);
         Assert.assertFalse(status.isSuccess());
index 1c964267b130d8b9f82d5e3726cc446683dbc4bd..f4c8f4ae8039e8c18fbe35adb277de8c1db053df 100644 (file)
@@ -34,8 +34,8 @@ public enum MatchType {
     NW_PROTO("nwProto", 1 << 9, Byte.class, 0, 0xff), // 1 byte
     NW_SRC("nwSrc", 1 << 10, InetAddress.class, 0, 0),
     NW_DST("nwDst", 1 << 11, InetAddress.class, 0, 0),
-    TP_SRC("tpSrc", 1 << 12, Short.class, 1, 0xffff), // 2 bytes
-    TP_DST("tpDst", 1 << 13, Short.class, 1, 0xffff); // 2 bytes
+    TP_SRC("tpSrc", 1 << 12, Short.class, 0, 0xffff), // 2 bytes
+    TP_DST("tpDst", 1 << 13, Short.class, 0, 0xffff); // 2 bytes
 
     // Used to indicate that no VLAN ID is set.
     public static final short DL_VLAN_NONE = (short) 0;
index 55b5cabf11c30f11a54ba1e10769e864106441a2..ae78e1acc8af45f8ef879b0ad16477bf9040330a 100644 (file)
@@ -137,6 +137,44 @@ public class MatchTest {
         Assert.assertTrue(o.equals(proto));
     }
 
+    @Test
+    public void testSetTpSrc() {
+        // Minimum value validation.
+        Match match = new Match();
+        short tp_src = 0;
+        match.setField(MatchType.TP_SRC, tp_src);
+
+        Object o = match.getField(MatchType.TP_SRC).getValue();
+        Assert.assertTrue(o.equals(tp_src));
+
+        // Maximum value validation.
+        match = new Match();
+        tp_src = (short) 0xffff;
+        match.setField(MatchType.TP_SRC, tp_src);
+
+        o = match.getField(MatchType.TP_SRC).getValue();
+        Assert.assertTrue(o.equals(tp_src));
+    }
+
+    @Test
+    public void testSetTpDst() {
+        // Minimum value validation.
+        Match match = new Match();
+        short tp_dst = 0;
+        match.setField(MatchType.TP_DST, tp_dst);
+
+        Object o = match.getField(MatchType.TP_DST).getValue();
+        Assert.assertTrue(o.equals(tp_dst));
+
+        // Maximum value validation.
+        match = new Match();
+        tp_dst = (short) 0xffff;
+        match.setField(MatchType.TP_DST, tp_dst);
+
+        o = match.getField(MatchType.TP_DST).getValue();
+        Assert.assertTrue(o.equals(tp_dst));
+    }
+
     @Test
     public void testMatchMask() {
         Match x = new Match();
index 59557dccd22e2ffccc05a3dd0f09e09287df9dd8..7ff54ed4dca511a6e4ba1238b1b962e004efd261 100644 (file)
@@ -715,13 +715,13 @@ one.f.flows = {
                        var $label = one.lib.form.label("Source Port");
                        var $input = one.lib.form.input("Source Port");
                        $input.attr('id', one.f.flows.id.modal.form.srcPort);
-                       var $help = one.lib.form.help("Range: 1 - 65535");
+                       var $help = one.lib.form.help("Range: 0 - 65535");
                        $fieldset.append($label).append($input).append($help);
                        // dstPort
                        var $label = one.lib.form.label("Destination Port");
                        var $input = one.lib.form.input("Destination Port");
                        $input.attr('id', one.f.flows.id.modal.form.dstPort);
-                       var $help = one.lib.form.help("Range: 1 - 65535");
+                       var $help = one.lib.form.help("Range: 0 - 65535");
                        $fieldset.append($label).append($input).append($help);
                        // protocol
                        var $label = one.lib.form.label("Protocol");