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>
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) {
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());
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());
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;
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();
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");