Updated extension registration keys
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / util / MatchDeserializerTest.java
1 /*\r
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.openflowjava.protocol.impl.util;\r
9 \r
10 import io.netty.buffer.ByteBuf;\r
11 \r
12 import java.util.List;\r
13 \r
14 import org.junit.Assert;\r
15 import org.junit.Before;\r
16 import org.junit.Test;\r
17 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
18 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
19 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
20 import org.opendaylight.openflowjava.protocol.api.extensibility.keys.MatchEntryDeserializerKey;\r
21 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
22 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;\r
23 import org.opendaylight.openflowjava.util.ByteBufUtils;\r
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;\r
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;\r
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry;\r
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry;\r
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry;\r
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry;\r
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry;\r
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry;\r
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry;\r
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry;\r
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry;\r
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry;\r
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry;\r
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry;\r
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry;\r
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry;\r
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry;\r
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry;\r
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry;\r
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry;\r
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry;\r
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry;\r
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry;\r
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry;\r
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry;\r
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;\r
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;\r
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;\r
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;\r
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa;\r
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha;\r
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa;\r
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;\r
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;\r
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;\r
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;\r
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;\r
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;\r
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;\r
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;\r
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;\r
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp;\r
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn;\r
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto;\r
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst;\r
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;\r
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst;\r
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr;\r
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel;\r
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll;\r
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget;\r
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll;\r
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;\r
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata;\r
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;\r
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;\r
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;\r
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;\r
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;\r
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;\r
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;\r
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;\r
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;\r
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;\r
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;\r
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;\r
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp;\r
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;\r
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;\r
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
96 \r
97 /**\r
98  * @author michal.polkorab\r
99  *\r
100  */\r
101 public class MatchDeserializerTest {\r
102 \r
103     private OFDeserializer<Match> matchDeserializer;\r
104     private DeserializerRegistry registry;\r
105 \r
106     /**\r
107      * Initializes deserializer registry and lookups correct deserializer\r
108      */\r
109     @Before\r
110     public void startUp() {\r
111         registry = new DeserializerRegistryImpl();\r
112         registry.init();\r
113         matchDeserializer = registry.getDeserializer(\r
114                 new MessageCodeKey(EncodeConstants.OF13_VERSION_ID,\r
115                         EncodeConstants.EMPTY_VALUE, Match.class));\r
116     }\r
117 \r
118     /**\r
119      * Testing Ipv4 address deserialization\r
120      */\r
121     @Test\r
122     public void testIpv4Address() {\r
123         ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03");\r
124 \r
125         MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID,\r
126                 0x8000, 12);\r
127         key.setExperimenterId(null);\r
128         OFDeserializer<MatchEntries> entryDeserializer = registry.getDeserializer(key);\r
129         MatchEntries entry = entryDeserializer.deserialize(buffer);\r
130         Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"),\r
131                 entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
132     }\r
133     \r
134     /**\r
135      * Testing Ipv6 address deserialization\r
136      */\r
137     @Test\r
138     public void testIpv6Address() {\r
139         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
140         \r
141         MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID,\r
142                 0x8000, 26);\r
143         key.setExperimenterId(null);\r
144         OFDeserializer<MatchEntries> entryDeserializer = registry.getDeserializer(key);\r
145         MatchEntries entry = entryDeserializer.deserialize(buffer);\r
146         Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"),\r
147                 entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());\r
148     }\r
149     \r
150     /**\r
151      * Testing match deserialization\r
152      */\r
153     @Test\r
154     public void testMatch() {\r
155         ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 01 AC "\r
156                 + "80 00 00 04 00 00 00 01 "\r
157                 + "80 00 02 04 00 00 00 02 "\r
158                 + "80 00 05 10 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 04 "\r
159                 + "80 00 07 0C 00 00 00 00 00 05 00 00 00 00 00 06 "\r
160                 + "80 00 09 0C 00 00 00 00 00 07 00 00 00 00 00 08 "\r
161                 + "80 00 0A 02 00 09 "\r
162                 + "80 00 0D 04 00 0A 00 0B "\r
163                 + "80 00 0E 01 0C "\r
164                 + "80 00 10 01 0D "\r
165                 + "80 00 12 01 0E "\r
166                 + "80 00 14 01 0F "\r
167                 + "80 00 17 08 0A 00 00 01 00 00 FF 00 "\r
168                 + "80 00 19 08 0A 00 00 02 00 00 00 FF "\r
169                 + "80 00 1A 02 00 03 "\r
170                 + "80 00 1C 02 00 04 "\r
171                 + "80 00 1E 02 00 05 "\r
172                 + "80 00 20 02 00 06 "\r
173                 + "80 00 22 02 00 07 "\r
174                 + "80 00 24 02 00 08 "\r
175                 + "80 00 26 01 05 "\r
176                 + "80 00 28 01 07 "\r
177                 + "80 00 2A 02 00 10 "\r
178                 + "80 00 2D 08 0A 00 00 09 00 00 FF 00 "\r
179                 + "80 00 2F 08 0A 00 00 0A 00 00 00 FF "\r
180                 + "80 00 31 0C 00 00 00 00 00 01 00 00 00 00 00 03 "\r
181                 + "80 00 33 0C 00 00 00 00 00 02 00 00 00 00 00 04 "\r
182                 + "80 00 35 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 "\r
183                 +             "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 "\r
184                 + "80 00 37 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 "\r
185                 +             "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 "\r
186                 + "80 00 39 08 00 00 00 02 00 00 00 03 "\r
187                 + "80 00 3A 01 15 "\r
188                 + "80 00 3C 01 17 "\r
189                 + "80 00 3E 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 " //ipv6ndtarget\r
190                 + "80 00 40 06 00 05 00 00 00 01 "\r
191                 + "80 00 42 06 00 05 00 00 00 02 "\r
192                 + "80 00 44 04 00 00 02 03 "\r
193                 + "80 00 46 01 03 "\r
194                 + "80 00 48 01 01 "\r
195                 + "80 00 4B 06 00 00 02 00 00 01 "\r
196                 + "80 00 4D 10 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 FF "\r
197                 + "80 00 4F 04 01 66 03 04 "\r
198                 + "00 00 00 00");\r
199 \r
200         Match match = matchDeserializer.deserialize(buffer);\r
201         Assert.assertEquals("Wrong match type", OxmMatchType.class, match.getType());\r
202         Assert.assertEquals("Wrong match entries size", 40, match.getMatchEntries().size());\r
203         List<MatchEntries> entries = match.getMatchEntries();\r
204         MatchEntries entry0 = entries.get(0);\r
205         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry0.getOxmClass());\r
206         Assert.assertEquals("Wrong entry field", InPort.class, entry0.getOxmMatchField());\r
207         Assert.assertEquals("Wrong entry hasMask", false, entry0.isHasMask());\r
208         Assert.assertEquals("Wrong entry value", 1,\r
209                 entry0.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());\r
210         MatchEntries entry1 = entries.get(1);\r
211         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry1.getOxmClass());\r
212         Assert.assertEquals("Wrong entry field", InPhyPort.class, entry1.getOxmMatchField());\r
213         Assert.assertEquals("Wrong entry hasMask", false, entry1.isHasMask());\r
214         Assert.assertEquals("Wrong entry value", 2,\r
215                 entry1.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());\r
216         MatchEntries entry2 = entries.get(2);\r
217         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry2.getOxmClass());\r
218         Assert.assertEquals("Wrong entry field", Metadata.class, entry2.getOxmMatchField());\r
219         Assert.assertEquals("Wrong entry hasMask", true, entry2.isHasMask());\r
220         Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), \r
221                 entry2.getAugmentation(MetadataMatchEntry.class).getMetadata());\r
222         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 04"), \r
223                 entry2.getAugmentation(MaskMatchEntry.class).getMask());\r
224         MatchEntries entry3 = entries.get(3);\r
225         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry3.getOxmClass());\r
226         Assert.assertEquals("Wrong entry field", EthDst.class, entry3.getOxmMatchField());\r
227         Assert.assertEquals("Wrong entry hasMask", true, entry3.isHasMask());\r
228         Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:05"), \r
229                 entry3.getAugmentation(MacAddressMatchEntry.class).getMacAddress());\r
230         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 06"), \r
231                 entry3.getAugmentation(MaskMatchEntry.class).getMask());\r
232         MatchEntries entry4 = entries.get(4);\r
233         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry4.getOxmClass());\r
234         Assert.assertEquals("Wrong entry field", EthSrc.class, entry4.getOxmMatchField());\r
235         Assert.assertEquals("Wrong entry hasMask", true, entry4.isHasMask());\r
236         Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:07"), \r
237                 entry4.getAugmentation(MacAddressMatchEntry.class).getMacAddress());\r
238         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 08"), \r
239                 entry4.getAugmentation(MaskMatchEntry.class).getMask());\r
240         MatchEntries entry5 = entries.get(5);\r
241         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry5.getOxmClass());\r
242         Assert.assertEquals("Wrong entry field", EthType.class, entry5.getOxmMatchField());\r
243         Assert.assertEquals("Wrong entry hasMask", false, entry5.isHasMask());\r
244         Assert.assertEquals("Wrong entry value", 9,\r
245                 entry5.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().intValue());\r
246         MatchEntries entry6 = entries.get(6);\r
247         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry6.getOxmClass());\r
248         Assert.assertEquals("Wrong entry field", VlanVid.class, entry6.getOxmMatchField());\r
249         Assert.assertEquals("Wrong entry hasMask", true, entry6.isHasMask());\r
250         Assert.assertEquals("Wrong entry value", 10,\r
251                 entry6.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue());\r
252         Assert.assertEquals("Wrong entry value", false, \r
253                 entry6.getAugmentation(VlanVidMatchEntry.class).isCfiBit());\r
254         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 0B"), \r
255                 entry6.getAugmentation(MaskMatchEntry.class).getMask());\r
256         MatchEntries entry7 = entries.get(7);\r
257         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry7.getOxmClass());\r
258         Assert.assertEquals("Wrong entry field", VlanPcp.class, entry7.getOxmMatchField());\r
259         Assert.assertEquals("Wrong entry hasMask", false, entry7.isHasMask());\r
260         Assert.assertEquals("Wrong entry value", 12,\r
261                 entry7.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().intValue());\r
262         MatchEntries entry8 = entries.get(8);\r
263         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry8.getOxmClass());\r
264         Assert.assertEquals("Wrong entry field", IpDscp.class, entry8.getOxmMatchField());\r
265         Assert.assertEquals("Wrong entry hasMask", false, entry8.isHasMask());\r
266         Assert.assertEquals("Wrong entry value", 13,\r
267                 entry8.getAugmentation(DscpMatchEntry.class).getDscp().getValue().intValue());\r
268         MatchEntries entry9 = entries.get(9);\r
269         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry9.getOxmClass());\r
270         Assert.assertEquals("Wrong entry field", IpEcn.class, entry9.getOxmMatchField());\r
271         Assert.assertEquals("Wrong entry hasMask", false, entry9.isHasMask());\r
272         Assert.assertEquals("Wrong entry value", 14,\r
273                 entry9.getAugmentation(EcnMatchEntry.class).getEcn().intValue());\r
274         MatchEntries entry10 = entries.get(10);\r
275         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry10.getOxmClass());\r
276         Assert.assertEquals("Wrong entry field", IpProto.class, entry10.getOxmMatchField());\r
277         Assert.assertEquals("Wrong entry hasMask", false, entry10.isHasMask());\r
278         Assert.assertEquals("Wrong entry value", 15,\r
279                 entry10.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber().intValue());\r
280         MatchEntries entry11 = entries.get(11);\r
281         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry11.getOxmClass());\r
282         Assert.assertEquals("Wrong entry field", Ipv4Src.class, entry11.getOxmMatchField());\r
283         Assert.assertEquals("Wrong entry hasMask", true, entry11.isHasMask());\r
284         Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.1"),\r
285                 entry11.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
286         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), \r
287                 entry11.getAugmentation(MaskMatchEntry.class).getMask());\r
288         MatchEntries entry12 = entries.get(12);\r
289         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry12.getOxmClass());\r
290         Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry12.getOxmMatchField());\r
291         Assert.assertEquals("Wrong entry hasMask", true, entry12.isHasMask());\r
292         Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.2"),\r
293                 entry12.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
294         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), \r
295                 entry12.getAugmentation(MaskMatchEntry.class).getMask());\r
296         MatchEntries entry13 = entries.get(13);\r
297         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry13.getOxmClass());\r
298         Assert.assertEquals("Wrong entry field", TcpSrc.class, entry13.getOxmMatchField());\r
299         Assert.assertEquals("Wrong entry hasMask", false, entry13.isHasMask());\r
300         Assert.assertEquals("Wrong entry value", 3,\r
301                 entry13.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
302         MatchEntries entry14 = entries.get(14);\r
303         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry14.getOxmClass());\r
304         Assert.assertEquals("Wrong entry field", TcpDst.class, entry14.getOxmMatchField());\r
305         Assert.assertEquals("Wrong entry hasMask", false, entry14.isHasMask());\r
306         Assert.assertEquals("Wrong entry value", 4,\r
307                 entry14.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
308         MatchEntries entry15 = entries.get(15);\r
309         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry15.getOxmClass());\r
310         Assert.assertEquals("Wrong entry field", UdpSrc.class, entry15.getOxmMatchField());\r
311         Assert.assertEquals("Wrong entry hasMask", false, entry15.isHasMask());\r
312         Assert.assertEquals("Wrong entry value", 5,\r
313                 entry15.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
314         MatchEntries entry16 = entries.get(16);\r
315         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry16.getOxmClass());\r
316         Assert.assertEquals("Wrong entry field", UdpDst.class, entry16.getOxmMatchField());\r
317         Assert.assertEquals("Wrong entry hasMask", false, entry16.isHasMask());\r
318         Assert.assertEquals("Wrong entry value", 6,\r
319                 entry16.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
320         MatchEntries entry17 = entries.get(17);\r
321         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry17.getOxmClass());\r
322         Assert.assertEquals("Wrong entry field", SctpSrc.class, entry17.getOxmMatchField());\r
323         Assert.assertEquals("Wrong entry hasMask", false, entry17.isHasMask());\r
324         Assert.assertEquals("Wrong entry value", 7,\r
325                 entry17.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
326         MatchEntries entry18 = entries.get(18);\r
327         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry18.getOxmClass());\r
328         Assert.assertEquals("Wrong entry field", SctpDst.class, entry18.getOxmMatchField());\r
329         Assert.assertEquals("Wrong entry hasMask", false, entry18.isHasMask());\r
330         Assert.assertEquals("Wrong entry value", 8,\r
331                 entry18.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
332         MatchEntries entry19 = entries.get(19);\r
333         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry19.getOxmClass());\r
334         Assert.assertEquals("Wrong entry field", Icmpv4Type.class, entry19.getOxmMatchField());\r
335         Assert.assertEquals("Wrong entry hasMask", false, entry19.isHasMask());\r
336         Assert.assertEquals("Wrong entry value", 5,\r
337                 entry19.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type().intValue());\r
338         MatchEntries entry20 = entries.get(20);\r
339         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry20.getOxmClass());\r
340         Assert.assertEquals("Wrong entry field", Icmpv4Code.class, entry20.getOxmMatchField());\r
341         Assert.assertEquals("Wrong entry hasMask", false, entry20.isHasMask());\r
342         Assert.assertEquals("Wrong entry value", 7,\r
343                 entry20.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code().intValue());\r
344         MatchEntries entry21 = entries.get(21);\r
345         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry21.getOxmClass());\r
346         Assert.assertEquals("Wrong entry field", ArpOp.class, entry21.getOxmMatchField());\r
347         Assert.assertEquals("Wrong entry hasMask", false, entry21.isHasMask());\r
348         Assert.assertEquals("Wrong entry value", 16,\r
349                 entry21.getAugmentation(OpCodeMatchEntry.class).getOpCode().intValue());\r
350         MatchEntries entry22 = entries.get(22);\r
351         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry22.getOxmClass());\r
352         Assert.assertEquals("Wrong entry field", ArpSpa.class, entry22.getOxmMatchField());\r
353         Assert.assertEquals("Wrong entry hasMask", true, entry22.isHasMask());\r
354         Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.9"),\r
355                 entry22.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
356         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), \r
357                 entry22.getAugmentation(MaskMatchEntry.class).getMask());\r
358         MatchEntries entry23 = entries.get(23);\r
359         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry23.getOxmClass());\r
360         Assert.assertEquals("Wrong entry field", ArpTpa.class, entry23.getOxmMatchField());\r
361         Assert.assertEquals("Wrong entry hasMask", true, entry23.isHasMask());\r
362         Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.10"),\r
363                 entry23.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
364         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), \r
365                 entry23.getAugmentation(MaskMatchEntry.class).getMask());\r
366         MatchEntries entry24 = entries.get(24);\r
367         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry24.getOxmClass());\r
368         Assert.assertEquals("Wrong entry field", ArpSha.class, entry24.getOxmMatchField());\r
369         Assert.assertEquals("Wrong entry hasMask", true, entry24.isHasMask());\r
370         Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:01"), \r
371                 entry24.getAugmentation(MacAddressMatchEntry.class).getMacAddress());\r
372         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 03"), \r
373                 entry24.getAugmentation(MaskMatchEntry.class).getMask());\r
374         MatchEntries entry25 = entries.get(25);\r
375         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry25.getOxmClass());\r
376         Assert.assertEquals("Wrong entry field", ArpTha.class, entry25.getOxmMatchField());\r
377         Assert.assertEquals("Wrong entry hasMask", true, entry25.isHasMask());\r
378         Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:02"), \r
379                 entry25.getAugmentation(MacAddressMatchEntry.class).getMacAddress());\r
380         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 04"), \r
381                 entry25.getAugmentation(MaskMatchEntry.class).getMask());\r
382         MatchEntries entry26 = entries.get(26);\r
383         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry26.getOxmClass());\r
384         Assert.assertEquals("Wrong entry field", Ipv6Src.class, entry26.getOxmMatchField());\r
385         Assert.assertEquals("Wrong entry hasMask", true, entry26.isHasMask());\r
386         Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0015"), \r
387                 entry26.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());\r
388         Assert.assertArrayEquals("Wrong entry mask",\r
389                 ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16"), \r
390                 entry26.getAugmentation(MaskMatchEntry.class).getMask());\r
391         MatchEntries entry27 = entries.get(27);\r
392         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry27.getOxmClass());\r
393         Assert.assertEquals("Wrong entry field", Ipv6Dst.class, entry27.getOxmMatchField());\r
394         Assert.assertEquals("Wrong entry hasMask", true, entry27.isHasMask());\r
395         Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0017"), \r
396                 entry27.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());\r
397         Assert.assertArrayEquals("Wrong entry mask",\r
398                 ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18"), \r
399                 entry27.getAugmentation(MaskMatchEntry.class).getMask());\r
400         MatchEntries entry28 = entries.get(28);\r
401         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry28.getOxmClass());\r
402         Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry28.getOxmMatchField());\r
403         Assert.assertEquals("Wrong entry hasMask", true, entry28.isHasMask());\r
404         Assert.assertEquals("Wrong entry value", 2, \r
405                 entry28.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue());\r
406         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 03"),\r
407                 entry28.getAugmentation(MaskMatchEntry.class).getMask());\r
408         MatchEntries entry29 = entries.get(29);\r
409         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry29.getOxmClass());\r
410         Assert.assertEquals("Wrong entry field", Icmpv6Type.class, entry29.getOxmMatchField());\r
411         Assert.assertEquals("Wrong entry hasMask", false, entry29.isHasMask());\r
412         Assert.assertEquals("Wrong entry value", 21, \r
413                 entry29.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type().intValue());\r
414         MatchEntries entry30 = entries.get(30);\r
415         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry30.getOxmClass());\r
416         Assert.assertEquals("Wrong entry field", Icmpv6Code.class, entry30.getOxmMatchField());\r
417         Assert.assertEquals("Wrong entry hasMask", false, entry30.isHasMask());\r
418         Assert.assertEquals("Wrong entry value", 23, \r
419                 entry30.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code().intValue());\r
420         MatchEntries entry31 = entries.get(31);\r
421         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry31.getOxmClass());\r
422         Assert.assertEquals("Wrong entry field", Ipv6NdTarget.class, entry31.getOxmMatchField());\r
423         Assert.assertEquals("Wrong entry hasMask", false, entry31.isHasMask());\r
424         Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0020"), \r
425                 entry31.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());\r
426         MatchEntries entry32 = entries.get(32);\r
427         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry32.getOxmClass());\r
428         Assert.assertEquals("Wrong entry field", Ipv6NdSll.class, entry32.getOxmMatchField());\r
429         Assert.assertEquals("Wrong entry hasMask", false, entry32.isHasMask());\r
430         Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:01"), \r
431                 entry32.getAugmentation(MacAddressMatchEntry.class).getMacAddress());\r
432         MatchEntries entry33 = entries.get(33);\r
433         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry33.getOxmClass());\r
434         Assert.assertEquals("Wrong entry field", Ipv6NdTll.class, entry33.getOxmMatchField());\r
435         Assert.assertEquals("Wrong entry hasMask", false, entry33.isHasMask());\r
436         Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:02"),\r
437                 entry33.getAugmentation(MacAddressMatchEntry.class).getMacAddress());\r
438         MatchEntries entry34 = entries.get(34);\r
439         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry34.getOxmClass());\r
440         Assert.assertEquals("Wrong entry field", MplsLabel.class, entry34.getOxmMatchField());\r
441         Assert.assertEquals("Wrong entry hasMask", false, entry34.isHasMask());\r
442         Assert.assertEquals("Wrong entry value", 515,\r
443                 entry34.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue());\r
444         MatchEntries entry35 = entries.get(35);\r
445         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry35.getOxmClass());\r
446         Assert.assertEquals("Wrong entry field", MplsTc.class, entry35.getOxmMatchField());\r
447         Assert.assertEquals("Wrong entry hasMask", false, entry35.isHasMask());\r
448         Assert.assertEquals("Wrong entry value", 3,\r
449                 entry35.getAugmentation(TcMatchEntry.class).getTc().intValue());\r
450         MatchEntries entry36 = entries.get(36);\r
451         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry36.getOxmClass());\r
452         Assert.assertEquals("Wrong entry field", MplsBos.class, entry36.getOxmMatchField());\r
453         Assert.assertEquals("Wrong entry hasMask", false, entry36.isHasMask());\r
454         Assert.assertEquals("Wrong entry value", true,\r
455                 entry36.getAugmentation(BosMatchEntry.class).isBos());\r
456         MatchEntries entry37 = entries.get(37);\r
457         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry37.getOxmClass());\r
458         Assert.assertEquals("Wrong entry field", PbbIsid.class, entry37.getOxmMatchField());\r
459         Assert.assertEquals("Wrong entry hasMask", true, entry37.isHasMask());\r
460         Assert.assertEquals("Wrong entry value", 2,\r
461                 entry37.getAugmentation(IsidMatchEntry.class).getIsid().intValue());\r
462         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 01"),\r
463                 entry37.getAugmentation(MaskMatchEntry.class).getMask());\r
464         MatchEntries entry38 = entries.get(38);\r
465         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry38.getOxmClass());\r
466         Assert.assertEquals("Wrong entry field", TunnelId.class, entry38.getOxmMatchField());\r
467         Assert.assertEquals("Wrong entry hasMask", true, entry38.isHasMask());\r
468         Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 07"),\r
469                 entry38.getAugmentation(MetadataMatchEntry.class).getMetadata());\r
470         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 FF"),\r
471                 entry38.getAugmentation(MaskMatchEntry.class).getMask());\r
472         MatchEntries entry39 = entries.get(39);\r
473         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry39.getOxmClass());\r
474         Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry39.getOxmMatchField());\r
475         Assert.assertEquals("Wrong entry hasMask", true, entry39.isHasMask());\r
476         Assert.assertEquals("Wrong entry value",\r
477                 new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true),\r
478                 entry39.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField());\r
479         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("03 04"),\r
480                 entry39.getAugmentation(MaskMatchEntry.class).getMask());\r
481         Assert.assertTrue("Unread data", buffer.readableBytes() == 0);\r
482     }\r
483 \r
484 }\r