422113fafad848ad76b5347534db11f0c7244da0
[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.EnhancedMessageCodeKey;\r
19 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
20 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\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         OFDeserializer<MatchEntries> entryDeserializer = registry.getDeserializer(\r
126                 new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 12, MatchEntries.class));\r
127         MatchEntries entry = entryDeserializer.deserialize(buffer);\r
128         Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"),\r
129                 entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
130     }\r
131     \r
132     /**\r
133      * Testing Ipv6 address deserialization\r
134      */\r
135     @Test\r
136     public void testIpv6Address() {\r
137         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
138         \r
139         OFDeserializer<MatchEntries> entryDeserializer = registry.getDeserializer(\r
140                 new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 26, MatchEntries.class));\r
141         MatchEntries entry = entryDeserializer.deserialize(buffer);\r
142         Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"),\r
143                 entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());\r
144     }\r
145     \r
146     /**\r
147      * Testing match deserialization\r
148      */\r
149     @Test\r
150     public void testMatch() {\r
151         ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 01 AC "\r
152                 + "80 00 00 04 00 00 00 01 "\r
153                 + "80 00 02 04 00 00 00 02 "\r
154                 + "80 00 05 10 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 04 "\r
155                 + "80 00 07 0C 00 00 00 00 00 05 00 00 00 00 00 06 "\r
156                 + "80 00 09 0C 00 00 00 00 00 07 00 00 00 00 00 08 "\r
157                 + "80 00 0A 02 00 09 "\r
158                 + "80 00 0D 04 00 0A 00 0B "\r
159                 + "80 00 0E 01 0C "\r
160                 + "80 00 10 01 0D "\r
161                 + "80 00 12 01 0E "\r
162                 + "80 00 14 01 0F "\r
163                 + "80 00 17 08 0A 00 00 01 00 00 FF 00 "\r
164                 + "80 00 19 08 0A 00 00 02 00 00 00 FF "\r
165                 + "80 00 1A 02 00 03 "\r
166                 + "80 00 1C 02 00 04 "\r
167                 + "80 00 1E 02 00 05 "\r
168                 + "80 00 20 02 00 06 "\r
169                 + "80 00 22 02 00 07 "\r
170                 + "80 00 24 02 00 08 "\r
171                 + "80 00 26 01 05 "\r
172                 + "80 00 28 01 07 "\r
173                 + "80 00 2A 02 00 10 "\r
174                 + "80 00 2D 08 0A 00 00 09 00 00 FF 00 "\r
175                 + "80 00 2F 08 0A 00 00 0A 00 00 00 FF "\r
176                 + "80 00 31 0C 00 00 00 00 00 01 00 00 00 00 00 03 "\r
177                 + "80 00 33 0C 00 00 00 00 00 02 00 00 00 00 00 04 "\r
178                 + "80 00 35 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 "\r
179                 +             "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 "\r
180                 + "80 00 37 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 "\r
181                 +             "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 "\r
182                 + "80 00 39 08 00 00 00 02 00 00 00 03 "\r
183                 + "80 00 3A 01 15 "\r
184                 + "80 00 3C 01 17 "\r
185                 + "80 00 3E 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 " //ipv6ndtarget\r
186                 + "80 00 40 06 00 05 00 00 00 01 "\r
187                 + "80 00 42 06 00 05 00 00 00 02 "\r
188                 + "80 00 44 04 00 00 02 03 "\r
189                 + "80 00 46 01 03 "\r
190                 + "80 00 48 01 01 "\r
191                 + "80 00 4B 06 00 00 02 00 00 01 "\r
192                 + "80 00 4D 10 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 FF "\r
193                 + "80 00 4F 04 01 66 03 04 "\r
194                 + "00 00 00 00");\r
195 \r
196         Match match = matchDeserializer.deserialize(buffer);\r
197         Assert.assertEquals("Wrong match type", OxmMatchType.class, match.getType());\r
198         Assert.assertEquals("Wrong match entries size", 40, match.getMatchEntries().size());\r
199         List<MatchEntries> entries = match.getMatchEntries();\r
200         MatchEntries entry0 = entries.get(0);\r
201         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry0.getOxmClass());\r
202         Assert.assertEquals("Wrong entry field", InPort.class, entry0.getOxmMatchField());\r
203         Assert.assertEquals("Wrong entry hasMask", false, entry0.isHasMask());\r
204         Assert.assertEquals("Wrong entry value", 1,\r
205                 entry0.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());\r
206         MatchEntries entry1 = entries.get(1);\r
207         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry1.getOxmClass());\r
208         Assert.assertEquals("Wrong entry field", InPhyPort.class, entry1.getOxmMatchField());\r
209         Assert.assertEquals("Wrong entry hasMask", false, entry1.isHasMask());\r
210         Assert.assertEquals("Wrong entry value", 2,\r
211                 entry1.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue());\r
212         MatchEntries entry2 = entries.get(2);\r
213         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry2.getOxmClass());\r
214         Assert.assertEquals("Wrong entry field", Metadata.class, entry2.getOxmMatchField());\r
215         Assert.assertEquals("Wrong entry hasMask", true, entry2.isHasMask());\r
216         Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), \r
217                 entry2.getAugmentation(MetadataMatchEntry.class).getMetadata());\r
218         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 04"), \r
219                 entry2.getAugmentation(MaskMatchEntry.class).getMask());\r
220         MatchEntries entry3 = entries.get(3);\r
221         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry3.getOxmClass());\r
222         Assert.assertEquals("Wrong entry field", EthDst.class, entry3.getOxmMatchField());\r
223         Assert.assertEquals("Wrong entry hasMask", true, entry3.isHasMask());\r
224         Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:05"), \r
225                 entry3.getAugmentation(MacAddressMatchEntry.class).getMacAddress());\r
226         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 06"), \r
227                 entry3.getAugmentation(MaskMatchEntry.class).getMask());\r
228         MatchEntries entry4 = entries.get(4);\r
229         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry4.getOxmClass());\r
230         Assert.assertEquals("Wrong entry field", EthSrc.class, entry4.getOxmMatchField());\r
231         Assert.assertEquals("Wrong entry hasMask", true, entry4.isHasMask());\r
232         Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:07"), \r
233                 entry4.getAugmentation(MacAddressMatchEntry.class).getMacAddress());\r
234         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 08"), \r
235                 entry4.getAugmentation(MaskMatchEntry.class).getMask());\r
236         MatchEntries entry5 = entries.get(5);\r
237         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry5.getOxmClass());\r
238         Assert.assertEquals("Wrong entry field", EthType.class, entry5.getOxmMatchField());\r
239         Assert.assertEquals("Wrong entry hasMask", false, entry5.isHasMask());\r
240         Assert.assertEquals("Wrong entry value", 9,\r
241                 entry5.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().intValue());\r
242         MatchEntries entry6 = entries.get(6);\r
243         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry6.getOxmClass());\r
244         Assert.assertEquals("Wrong entry field", VlanVid.class, entry6.getOxmMatchField());\r
245         Assert.assertEquals("Wrong entry hasMask", true, entry6.isHasMask());\r
246         Assert.assertEquals("Wrong entry value", 10,\r
247                 entry6.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue());\r
248         Assert.assertEquals("Wrong entry value", false, \r
249                 entry6.getAugmentation(VlanVidMatchEntry.class).isCfiBit());\r
250         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 0B"), \r
251                 entry6.getAugmentation(MaskMatchEntry.class).getMask());\r
252         MatchEntries entry7 = entries.get(7);\r
253         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry7.getOxmClass());\r
254         Assert.assertEquals("Wrong entry field", VlanPcp.class, entry7.getOxmMatchField());\r
255         Assert.assertEquals("Wrong entry hasMask", false, entry7.isHasMask());\r
256         Assert.assertEquals("Wrong entry value", 12,\r
257                 entry7.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().intValue());\r
258         MatchEntries entry8 = entries.get(8);\r
259         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry8.getOxmClass());\r
260         Assert.assertEquals("Wrong entry field", IpDscp.class, entry8.getOxmMatchField());\r
261         Assert.assertEquals("Wrong entry hasMask", false, entry8.isHasMask());\r
262         Assert.assertEquals("Wrong entry value", 13,\r
263                 entry8.getAugmentation(DscpMatchEntry.class).getDscp().getValue().intValue());\r
264         MatchEntries entry9 = entries.get(9);\r
265         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry9.getOxmClass());\r
266         Assert.assertEquals("Wrong entry field", IpEcn.class, entry9.getOxmMatchField());\r
267         Assert.assertEquals("Wrong entry hasMask", false, entry9.isHasMask());\r
268         Assert.assertEquals("Wrong entry value", 14,\r
269                 entry9.getAugmentation(EcnMatchEntry.class).getEcn().intValue());\r
270         MatchEntries entry10 = entries.get(10);\r
271         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry10.getOxmClass());\r
272         Assert.assertEquals("Wrong entry field", IpProto.class, entry10.getOxmMatchField());\r
273         Assert.assertEquals("Wrong entry hasMask", false, entry10.isHasMask());\r
274         Assert.assertEquals("Wrong entry value", 15,\r
275                 entry10.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber().intValue());\r
276         MatchEntries entry11 = entries.get(11);\r
277         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry11.getOxmClass());\r
278         Assert.assertEquals("Wrong entry field", Ipv4Src.class, entry11.getOxmMatchField());\r
279         Assert.assertEquals("Wrong entry hasMask", true, entry11.isHasMask());\r
280         Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.1"),\r
281                 entry11.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
282         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), \r
283                 entry11.getAugmentation(MaskMatchEntry.class).getMask());\r
284         MatchEntries entry12 = entries.get(12);\r
285         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry12.getOxmClass());\r
286         Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry12.getOxmMatchField());\r
287         Assert.assertEquals("Wrong entry hasMask", true, entry12.isHasMask());\r
288         Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.2"),\r
289                 entry12.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
290         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), \r
291                 entry12.getAugmentation(MaskMatchEntry.class).getMask());\r
292         MatchEntries entry13 = entries.get(13);\r
293         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry13.getOxmClass());\r
294         Assert.assertEquals("Wrong entry field", TcpSrc.class, entry13.getOxmMatchField());\r
295         Assert.assertEquals("Wrong entry hasMask", false, entry13.isHasMask());\r
296         Assert.assertEquals("Wrong entry value", 3,\r
297                 entry13.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
298         MatchEntries entry14 = entries.get(14);\r
299         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry14.getOxmClass());\r
300         Assert.assertEquals("Wrong entry field", TcpDst.class, entry14.getOxmMatchField());\r
301         Assert.assertEquals("Wrong entry hasMask", false, entry14.isHasMask());\r
302         Assert.assertEquals("Wrong entry value", 4,\r
303                 entry14.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
304         MatchEntries entry15 = entries.get(15);\r
305         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry15.getOxmClass());\r
306         Assert.assertEquals("Wrong entry field", UdpSrc.class, entry15.getOxmMatchField());\r
307         Assert.assertEquals("Wrong entry hasMask", false, entry15.isHasMask());\r
308         Assert.assertEquals("Wrong entry value", 5,\r
309                 entry15.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
310         MatchEntries entry16 = entries.get(16);\r
311         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry16.getOxmClass());\r
312         Assert.assertEquals("Wrong entry field", UdpDst.class, entry16.getOxmMatchField());\r
313         Assert.assertEquals("Wrong entry hasMask", false, entry16.isHasMask());\r
314         Assert.assertEquals("Wrong entry value", 6,\r
315                 entry16.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
316         MatchEntries entry17 = entries.get(17);\r
317         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry17.getOxmClass());\r
318         Assert.assertEquals("Wrong entry field", SctpSrc.class, entry17.getOxmMatchField());\r
319         Assert.assertEquals("Wrong entry hasMask", false, entry17.isHasMask());\r
320         Assert.assertEquals("Wrong entry value", 7,\r
321                 entry17.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
322         MatchEntries entry18 = entries.get(18);\r
323         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry18.getOxmClass());\r
324         Assert.assertEquals("Wrong entry field", SctpDst.class, entry18.getOxmMatchField());\r
325         Assert.assertEquals("Wrong entry hasMask", false, entry18.isHasMask());\r
326         Assert.assertEquals("Wrong entry value", 8,\r
327                 entry18.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue());\r
328         MatchEntries entry19 = entries.get(19);\r
329         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry19.getOxmClass());\r
330         Assert.assertEquals("Wrong entry field", Icmpv4Type.class, entry19.getOxmMatchField());\r
331         Assert.assertEquals("Wrong entry hasMask", false, entry19.isHasMask());\r
332         Assert.assertEquals("Wrong entry value", 5,\r
333                 entry19.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type().intValue());\r
334         MatchEntries entry20 = entries.get(20);\r
335         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry20.getOxmClass());\r
336         Assert.assertEquals("Wrong entry field", Icmpv4Code.class, entry20.getOxmMatchField());\r
337         Assert.assertEquals("Wrong entry hasMask", false, entry20.isHasMask());\r
338         Assert.assertEquals("Wrong entry value", 7,\r
339                 entry20.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code().intValue());\r
340         MatchEntries entry21 = entries.get(21);\r
341         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry21.getOxmClass());\r
342         Assert.assertEquals("Wrong entry field", ArpOp.class, entry21.getOxmMatchField());\r
343         Assert.assertEquals("Wrong entry hasMask", false, entry21.isHasMask());\r
344         Assert.assertEquals("Wrong entry value", 16,\r
345                 entry21.getAugmentation(OpCodeMatchEntry.class).getOpCode().intValue());\r
346         MatchEntries entry22 = entries.get(22);\r
347         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry22.getOxmClass());\r
348         Assert.assertEquals("Wrong entry field", ArpSpa.class, entry22.getOxmMatchField());\r
349         Assert.assertEquals("Wrong entry hasMask", true, entry22.isHasMask());\r
350         Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.9"),\r
351                 entry22.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
352         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), \r
353                 entry22.getAugmentation(MaskMatchEntry.class).getMask());\r
354         MatchEntries entry23 = entries.get(23);\r
355         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry23.getOxmClass());\r
356         Assert.assertEquals("Wrong entry field", ArpTpa.class, entry23.getOxmMatchField());\r
357         Assert.assertEquals("Wrong entry hasMask", true, entry23.isHasMask());\r
358         Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.10"),\r
359                 entry23.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address());\r
360         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), \r
361                 entry23.getAugmentation(MaskMatchEntry.class).getMask());\r
362         MatchEntries entry24 = entries.get(24);\r
363         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry24.getOxmClass());\r
364         Assert.assertEquals("Wrong entry field", ArpSha.class, entry24.getOxmMatchField());\r
365         Assert.assertEquals("Wrong entry hasMask", true, entry24.isHasMask());\r
366         Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:01"), \r
367                 entry24.getAugmentation(MacAddressMatchEntry.class).getMacAddress());\r
368         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 03"), \r
369                 entry24.getAugmentation(MaskMatchEntry.class).getMask());\r
370         MatchEntries entry25 = entries.get(25);\r
371         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry25.getOxmClass());\r
372         Assert.assertEquals("Wrong entry field", ArpTha.class, entry25.getOxmMatchField());\r
373         Assert.assertEquals("Wrong entry hasMask", true, entry25.isHasMask());\r
374         Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:02"), \r
375                 entry25.getAugmentation(MacAddressMatchEntry.class).getMacAddress());\r
376         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 04"), \r
377                 entry25.getAugmentation(MaskMatchEntry.class).getMask());\r
378         MatchEntries entry26 = entries.get(26);\r
379         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry26.getOxmClass());\r
380         Assert.assertEquals("Wrong entry field", Ipv6Src.class, entry26.getOxmMatchField());\r
381         Assert.assertEquals("Wrong entry hasMask", true, entry26.isHasMask());\r
382         Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0015"), \r
383                 entry26.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());\r
384         Assert.assertArrayEquals("Wrong entry mask",\r
385                 ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16"), \r
386                 entry26.getAugmentation(MaskMatchEntry.class).getMask());\r
387         MatchEntries entry27 = entries.get(27);\r
388         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry27.getOxmClass());\r
389         Assert.assertEquals("Wrong entry field", Ipv6Dst.class, entry27.getOxmMatchField());\r
390         Assert.assertEquals("Wrong entry hasMask", true, entry27.isHasMask());\r
391         Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0017"), \r
392                 entry27.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());\r
393         Assert.assertArrayEquals("Wrong entry mask",\r
394                 ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18"), \r
395                 entry27.getAugmentation(MaskMatchEntry.class).getMask());\r
396         MatchEntries entry28 = entries.get(28);\r
397         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry28.getOxmClass());\r
398         Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry28.getOxmMatchField());\r
399         Assert.assertEquals("Wrong entry hasMask", true, entry28.isHasMask());\r
400         Assert.assertEquals("Wrong entry value", 2, \r
401                 entry28.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue());\r
402         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 03"),\r
403                 entry28.getAugmentation(MaskMatchEntry.class).getMask());\r
404         MatchEntries entry29 = entries.get(29);\r
405         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry29.getOxmClass());\r
406         Assert.assertEquals("Wrong entry field", Icmpv6Type.class, entry29.getOxmMatchField());\r
407         Assert.assertEquals("Wrong entry hasMask", false, entry29.isHasMask());\r
408         Assert.assertEquals("Wrong entry value", 21, \r
409                 entry29.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type().intValue());\r
410         MatchEntries entry30 = entries.get(30);\r
411         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry30.getOxmClass());\r
412         Assert.assertEquals("Wrong entry field", Icmpv6Code.class, entry30.getOxmMatchField());\r
413         Assert.assertEquals("Wrong entry hasMask", false, entry30.isHasMask());\r
414         Assert.assertEquals("Wrong entry value", 23, \r
415                 entry30.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code().intValue());\r
416         MatchEntries entry31 = entries.get(31);\r
417         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry31.getOxmClass());\r
418         Assert.assertEquals("Wrong entry field", Ipv6NdTarget.class, entry31.getOxmMatchField());\r
419         Assert.assertEquals("Wrong entry hasMask", false, entry31.isHasMask());\r
420         Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0020"), \r
421                 entry31.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address());\r
422         MatchEntries entry32 = entries.get(32);\r
423         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry32.getOxmClass());\r
424         Assert.assertEquals("Wrong entry field", Ipv6NdSll.class, entry32.getOxmMatchField());\r
425         Assert.assertEquals("Wrong entry hasMask", false, entry32.isHasMask());\r
426         Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:01"), \r
427                 entry32.getAugmentation(MacAddressMatchEntry.class).getMacAddress());\r
428         MatchEntries entry33 = entries.get(33);\r
429         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry33.getOxmClass());\r
430         Assert.assertEquals("Wrong entry field", Ipv6NdTll.class, entry33.getOxmMatchField());\r
431         Assert.assertEquals("Wrong entry hasMask", false, entry33.isHasMask());\r
432         Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:02"),\r
433                 entry33.getAugmentation(MacAddressMatchEntry.class).getMacAddress());\r
434         MatchEntries entry34 = entries.get(34);\r
435         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry34.getOxmClass());\r
436         Assert.assertEquals("Wrong entry field", MplsLabel.class, entry34.getOxmMatchField());\r
437         Assert.assertEquals("Wrong entry hasMask", false, entry34.isHasMask());\r
438         Assert.assertEquals("Wrong entry value", 515,\r
439                 entry34.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue());\r
440         MatchEntries entry35 = entries.get(35);\r
441         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry35.getOxmClass());\r
442         Assert.assertEquals("Wrong entry field", MplsTc.class, entry35.getOxmMatchField());\r
443         Assert.assertEquals("Wrong entry hasMask", false, entry35.isHasMask());\r
444         Assert.assertEquals("Wrong entry value", 3,\r
445                 entry35.getAugmentation(TcMatchEntry.class).getTc().intValue());\r
446         MatchEntries entry36 = entries.get(36);\r
447         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry36.getOxmClass());\r
448         Assert.assertEquals("Wrong entry field", MplsBos.class, entry36.getOxmMatchField());\r
449         Assert.assertEquals("Wrong entry hasMask", false, entry36.isHasMask());\r
450         Assert.assertEquals("Wrong entry value", true,\r
451                 entry36.getAugmentation(BosMatchEntry.class).isBos());\r
452         MatchEntries entry37 = entries.get(37);\r
453         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry37.getOxmClass());\r
454         Assert.assertEquals("Wrong entry field", PbbIsid.class, entry37.getOxmMatchField());\r
455         Assert.assertEquals("Wrong entry hasMask", true, entry37.isHasMask());\r
456         Assert.assertEquals("Wrong entry value", 2,\r
457                 entry37.getAugmentation(IsidMatchEntry.class).getIsid().intValue());\r
458         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 01"),\r
459                 entry37.getAugmentation(MaskMatchEntry.class).getMask());\r
460         MatchEntries entry38 = entries.get(38);\r
461         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry38.getOxmClass());\r
462         Assert.assertEquals("Wrong entry field", TunnelId.class, entry38.getOxmMatchField());\r
463         Assert.assertEquals("Wrong entry hasMask", true, entry38.isHasMask());\r
464         Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 07"),\r
465                 entry38.getAugmentation(MetadataMatchEntry.class).getMetadata());\r
466         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 FF"),\r
467                 entry38.getAugmentation(MaskMatchEntry.class).getMask());\r
468         MatchEntries entry39 = entries.get(39);\r
469         Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry39.getOxmClass());\r
470         Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry39.getOxmMatchField());\r
471         Assert.assertEquals("Wrong entry hasMask", true, entry39.isHasMask());\r
472         Assert.assertEquals("Wrong entry value",\r
473                 new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true),\r
474                 entry39.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField());\r
475         Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("03 04"),\r
476                 entry39.getAugmentation(MaskMatchEntry.class).getMask());\r
477         Assert.assertTrue("Unread data", buffer.readableBytes() == 0);\r
478     }\r
479 \r
480 }\r