Skip to content
Snippets Groups Projects
Commit 76079082 authored by Rob Sherwood's avatar Rob Sherwood
Browse files

Made OFMatch.fromString() take hex for VLAN

added Unittest
code submitted from  roberto.doriguzzi@create-net.org
    Thanks!
parent 713c2f85
No related branches found
No related tags found
No related merge requests found
...@@ -865,7 +865,11 @@ public class OFMatch implements Cloneable, Serializable { ...@@ -865,7 +865,11 @@ public class OFMatch implements Cloneable, Serializable {
this.dataLayerType = U16.t(Integer.valueOf(values[1])); this.dataLayerType = U16.t(Integer.valueOf(values[1]));
this.wildcards &= ~OFPFW_DL_TYPE; this.wildcards &= ~OFPFW_DL_TYPE;
} else if (values[0].equals(STR_DL_VLAN)) { } else if (values[0].equals(STR_DL_VLAN)) {
this.dataLayerVirtualLan = U16.t(Integer.valueOf(values[1])); if (values[1].startsWith("0x"))
this.dataLayerVirtualLan = U16.t(Integer.valueOf(
values[1].replaceFirst("0x", ""),16));
else
this.dataLayerVirtualLan = U16.t(Integer.valueOf(values[1]));
this.wildcards &= ~OFPFW_DL_VLAN; this.wildcards &= ~OFPFW_DL_VLAN;
} else if (values[0].equals(STR_DL_VLAN_PCP)) { } else if (values[0].equals(STR_DL_VLAN_PCP)) {
this.dataLayerVirtualLanPriorityCodePoint = U8.t(Short this.dataLayerVirtualLanPriorityCodePoint = U8.t(Short
......
...@@ -48,7 +48,15 @@ public class OFMatchTest extends TestCase { ...@@ -48,7 +48,15 @@ public class OFMatchTest extends TestCase {
TestCase.assertEquals(correct.getNetworkSourceMaskLen(), tester TestCase.assertEquals(correct.getNetworkSourceMaskLen(), tester
.getNetworkSourceMaskLen()); .getNetworkSourceMaskLen());
TestCase.assertEquals(correct, tester); TestCase.assertEquals(correct, tester);
}
// 0xVlan
correct = new OFMatch();
correct.setDataLayerVirtualLan((short)65535);
correct.setWildcards(~OFMatch.OFPFW_DL_VLAN);
tester = new OFMatch();
tester.fromString("dl_vlan=0xffff");
TestCase.assertEquals(correct, tester);
}
public void testToString() { public void testToString() {
OFMatch match = new OFMatch(); OFMatch match = new OFMatch();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment