import org.junit.Before;\r
import org.junit.Test;\r
import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.EnhancedMessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;\r
import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
+import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;\r
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\r
+import org.opendaylight.openflowjava.util.ByteBufUtils;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa;\r
public void testIpv4Address() {\r
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03");\r
\r
- OFDeserializer<MatchEntries> entryDeserializer = registry.getDeserializer(\r
- new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 12, MatchEntries.class));\r
+ MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID,\r
+ 0x8000, 12);\r
+ key.setExperimenterId(null);\r
+ OFDeserializer<MatchEntries> entryDeserializer = registry.getDeserializer(key);\r
MatchEntries entry = entryDeserializer.deserialize(buffer);\r
Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"),\r
entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
public void testIpv6Address() {\r
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 34 10 00 00 00 01 00 02 00 03 00 04 00 05 00 06 0F 07");\r
\r
- OFDeserializer<MatchEntries> entryDeserializer = registry.getDeserializer(\r
- new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 26, MatchEntries.class));\r
+ MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID,\r
+ 0x8000, 26);\r
+ key.setExperimenterId(null);\r
+ OFDeserializer<MatchEntries> entryDeserializer = registry.getDeserializer(key);\r
MatchEntries entry = entryDeserializer.deserialize(buffer);\r
Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"),\r
entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());\r
+ "80 00 48 01 01 "\r
+ "80 00 4B 06 00 00 02 00 00 01 "\r
+ "80 00 4D 10 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 FF "\r
- + "80 00 4F 04 01 66 03 04 "\r
+ + "80 00 4F 04 00 00 03 04 "\r
+ "00 00 00 00");\r
\r
Match match = matchDeserializer.deserialize(buffer);\r
Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry39.getOxmMatchField());\r
Assert.assertEquals("Wrong entry hasMask", true, entry39.isHasMask());\r
Assert.assertEquals("Wrong entry value",\r
- new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true),\r
+ new Ipv6ExthdrFlags(false, false, false, false, false, false, false, false, false),\r
entry39.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField());\r
Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("03 04"),\r
entry39.getAugmentation(MaskMatchEntry.class).getMask());\r
Assert.assertTrue("Unread data", buffer.readableBytes() == 0);\r
}\r
\r
-}\r
+ /**\r
+ * Testing header deserialization\r
+ */\r
+ @Test\r
+ public void testHeaders() {\r
+ ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03");\r
+\r
+ MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID,\r
+ 0x8000, 12);\r
+ key.setExperimenterId(null);\r
+ HeaderDeserializer<MatchEntries> entryDeserializer = registry.getDeserializer(key);\r
+ MatchEntries entry = entryDeserializer.deserializeHeader(buffer);\r
+ Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass());\r
+ Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry.getOxmMatchField());\r
+ Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask());\r
+ Assert.assertEquals("Wrong Ipv4 address", null, entry.getAugmentation(Ipv4AddressMatchEntry.class));\r
+ }\r
+\r
+ /**\r
+ * Testing standard match type\r
+ */\r
+ @Test\r
+ public void testStandardMatch() {\r
+ ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 10 80 00 04 08 00 00 00 00 00 00 00 01");\r
+\r
+ Match match = matchDeserializer.deserialize(buffer);\r
+\r
+ Assert.assertEquals("Wrong match type", StandardMatchType.class, match.getType());\r
+ Assert.assertEquals("Wrong match entries size", 1, match.getMatchEntries().size());\r
+ }\r
+}
\ No newline at end of file