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