2 * Copyright (c) 2014, 2015 Pantheon Technologies s.r.o. and others. All rights reserved.
\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
9 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
\r
11 import java.math.BigInteger;
\r
12 import java.util.Optional;
\r
13 import org.junit.Assert;
\r
14 import org.junit.Before;
\r
15 import org.junit.Test;
\r
16 import org.opendaylight.openflowplugin.api.OFConstants;
\r
17 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
\r
18 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
\r
19 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
\r
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
\r
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
\r
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
\r
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
\r
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
\r
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;
\r
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
\r
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
\r
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
\r
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
\r
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
\r
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;
\r
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder;
\r
35 * @author michal.polkorab
\r
38 public class MatchV10ResponseConvertorTest {
\r
41 * Initializes OpenflowPortsUtil
\r
44 public void startUp() {
\r
45 OpenflowPortsUtil.init();
\r
49 * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}
\r
52 public void test() {
\r
53 MatchV10Builder builder = new MatchV10Builder();
\r
54 builder.setWildcards(new FlowWildcardsV10(false, false, false, false,
\r
55 false, false, false, false, false, false));
\r
56 builder.setNwSrcMask((short) 24);
\r
57 builder.setNwDstMask((short) 16);
\r
58 builder.setInPort(6653);
\r
59 builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
\r
60 builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
\r
61 builder.setDlVlan(128);
\r
62 builder.setDlVlanPcp((short) 2);
\r
63 builder.setDlType(15);
\r
64 builder.setNwTos((short) 16);
\r
65 builder.setNwProto((short) 6);
\r
66 builder.setNwSrc(new Ipv4Address("1.1.1.2"));
\r
67 builder.setNwDst(new Ipv4Address("32.16.8.1"));
\r
68 builder.setTpSrc(2048);
\r
69 builder.setTpDst(4096);
\r
70 MatchV10 match = builder.build();
\r
72 final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
\r
73 datapathIdConvertorData.setDatapathId(new BigInteger("42"));
\r
75 final Match salMatch = convert(match, datapathIdConvertorData).build();
\r
77 Assert.assertEquals("Wrong in port", "openflow:42:6653", salMatch.getInPort().getValue());
\r
78 Assert.assertEquals("Wrong dl src", new MacAddress("01:01:01:01:01:01"), salMatch.getEthernetMatch()
\r
79 .getEthernetSource().getAddress());
\r
80 Assert.assertEquals("Wrong dl dst", new MacAddress("02:02:02:02:02:02"), salMatch.getEthernetMatch()
\r
81 .getEthernetDestination().getAddress());
\r
82 Assert.assertEquals("Wrong dl type", 15, salMatch.getEthernetMatch().getEthernetType().getType().getValue().intValue());
\r
83 Assert.assertEquals("Wrong dl vlan", 128, salMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());
\r
84 Assert.assertEquals("Wrong dl vlan pcp", 2, salMatch.getVlanMatch().getVlanPcp().getValue().intValue());
\r
85 Ipv4Match ipv4Match = (Ipv4Match) salMatch.getLayer3Match();
\r
86 Assert.assertEquals("Wrong nw src address", "1.1.1.2/24", ipv4Match.getIpv4Source().getValue());
\r
87 Assert.assertEquals("Wrong nw dst address", "32.16.8.1/16", ipv4Match.getIpv4Destination().getValue());
\r
88 Assert.assertEquals("Wrong ip protocol", 6, salMatch.getIpMatch().getIpProtocol().intValue());
\r
89 Assert.assertEquals("Wrong ip proto", null, salMatch.getIpMatch().getIpProto());
\r
90 Assert.assertEquals("Wrong ip ecn", null, salMatch.getIpMatch().getIpEcn());
\r
91 Assert.assertEquals("Wrong ip dscp", 4, salMatch.getIpMatch().getIpDscp().getValue().intValue());
\r
92 TcpMatch tcpMatch = (TcpMatch) salMatch.getLayer4Match();
\r
93 Assert.assertEquals("Wrong tp dst", 4096, tcpMatch.getTcpDestinationPort().getValue().intValue());
\r
94 Assert.assertEquals("Wrong tp src", 2048, tcpMatch.getTcpSourcePort().getValue().intValue());
\r
95 Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
\r
99 * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}
\r
102 public void testWildcardedMatch() {
\r
103 MatchV10Builder builder = new MatchV10Builder();
\r
104 builder.setWildcards(new FlowWildcardsV10(true, true, true, true,
\r
105 true, true, true, true, true, true));
\r
106 builder.setNwSrcMask((short) 24);
\r
107 builder.setNwDstMask((short) 16);
\r
108 builder.setInPort(6653);
\r
109 builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
\r
110 builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
\r
111 builder.setDlVlan(128);
\r
112 builder.setDlVlanPcp((short) 2);
\r
113 builder.setDlType(15);
\r
114 builder.setNwTos((short) 14);
\r
115 builder.setNwProto((short) 6);
\r
116 builder.setNwSrc(new Ipv4Address("1.1.1.2"));
\r
117 builder.setNwDst(new Ipv4Address("32.16.8.1"));
\r
118 builder.setTpSrc(2048);
\r
119 builder.setTpDst(4096);
\r
120 MatchV10 match = builder.build();
\r
122 final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
\r
123 datapathIdConvertorData.setDatapathId(new BigInteger("42"));
\r
125 final Match salMatch = convert(match, datapathIdConvertorData).build();
\r
127 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
128 Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());
\r
129 Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());
\r
130 Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());
\r
131 Assert.assertEquals("Wrong layer 4 match", null, salMatch.getLayer4Match());
\r
132 Assert.assertEquals("Wrong ip match", null, salMatch.getIpMatch());
\r
133 Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
\r
137 * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}
\r
140 public void testWildcardedMatchWithNoValuesSet() {
\r
141 MatchV10Builder builder = new MatchV10Builder();
\r
142 builder.setWildcards(new FlowWildcardsV10(true, true, true, true,
\r
143 true, true, true, true, true, true));
\r
144 MatchV10 match = builder.build();
\r
146 final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
\r
147 datapathIdConvertorData.setDatapathId(new BigInteger("42"));
\r
149 final Match salMatch = convert(match, datapathIdConvertorData).build();
\r
151 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
152 Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());
\r
153 Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());
\r
154 Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());
\r
155 Assert.assertEquals("Wrong layer 4 match", null, salMatch.getLayer4Match());
\r
156 Assert.assertEquals("Wrong ip match", null, salMatch.getIpMatch());
\r
157 Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
\r
161 * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}
\r
164 public void testMatchWithValuesUnset() {
\r
165 MatchV10Builder builder = new MatchV10Builder();
\r
166 builder.setWildcards(new FlowWildcardsV10(false, false, false, false,
\r
167 false, false, false, false, false, false));
\r
168 builder.setNwProto((short) 17);
\r
169 builder.setTpSrc(2048);
\r
170 builder.setTpDst(4096);
\r
171 MatchV10 match = builder.build();
\r
173 final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
\r
174 datapathIdConvertorData.setDatapathId(new BigInteger("42"));
\r
176 final Match salMatch = convert(match, datapathIdConvertorData).build();
\r
178 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
179 Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());
\r
180 Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());
\r
181 Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());
\r
182 UdpMatch udpMatch = (UdpMatch) salMatch.getLayer4Match();
\r
183 Assert.assertEquals("Wrong udp dst", 4096, udpMatch.getUdpDestinationPort().getValue().intValue());
\r
184 Assert.assertEquals("Wrong udp src", 2048, udpMatch.getUdpSourcePort().getValue().intValue());
\r
185 Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
\r
189 * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}
\r
191 @Test(expected=NullPointerException.class)
\r
192 public void testEmptyMatch() {
\r
193 MatchV10Builder builder = new MatchV10Builder();
\r
194 MatchV10 match = builder.build();
\r
196 final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
\r
197 datapathIdConvertorData.setDatapathId(new BigInteger("42"));
\r
199 final Match salMatch = convert(match, datapathIdConvertorData).build();
\r
203 * ICMPv4 match test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}
\r
206 public void testIcmpv4Match() {
\r
207 // NW_PROTO, TP_SRC, TP_DST are wildcarded.
\r
208 Long dlType = 0x800L;
\r
209 FlowWildcardsV10 wc = new FlowWildcardsV10(
\r
210 true, true, false, true, true, true, true, true, true, true);
\r
211 MatchV10Builder builder = new MatchV10Builder().
\r
213 setDlType(dlType.intValue());
\r
214 MatchV10 match = builder.build();
\r
216 BigInteger dpid = BigInteger.valueOf(12345L);
\r
217 final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
\r
218 datapathIdConvertorData.setDatapathId(dpid);
\r
220 Match salMatch = convert(match, datapathIdConvertorData).build();
\r
222 EthernetMatch etherMatch = salMatch.getEthernetMatch();
\r
223 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
224 Assert.assertEquals("Wrong dl src",
\r
225 null, etherMatch.getEthernetSource());
\r
226 Assert.assertEquals("Wrong dl dst",
\r
227 null, etherMatch.getEthernetDestination());
\r
228 Assert.assertEquals("Wrong dl type", dlType,
\r
229 etherMatch.getEthernetType().getType().getValue());
\r
230 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
231 Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
\r
232 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
233 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
234 Assert.assertEquals("Wrong ICMPv4 match",
\r
235 null, salMatch.getIcmpv4Match());
\r
237 // NW_PROTO is not wildcarded but null.
\r
238 wc = new FlowWildcardsV10(
\r
239 true, true, false, true, true, true, false, true, true, true);
\r
240 match = builder.setWildcards(wc).build();
\r
242 salMatch = convert(match, datapathIdConvertorData).build();
\r
243 etherMatch = salMatch.getEthernetMatch();
\r
244 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
245 Assert.assertEquals("Wrong dl src",
\r
246 null, etherMatch.getEthernetSource());
\r
247 Assert.assertEquals("Wrong dl dst",
\r
248 null, etherMatch.getEthernetDestination());
\r
249 Assert.assertEquals("Wrong dl type", dlType,
\r
250 etherMatch.getEthernetType().getType().getValue());
\r
251 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
252 Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
\r
253 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
254 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
255 Assert.assertEquals("Wrong ICMPv4 match",
\r
256 null, salMatch.getIcmpv4Match());
\r
258 // Specify ICMPv4 protocol.
\r
260 match = builder.setNwProto(ipProto).build();
\r
261 salMatch = convert(match, datapathIdConvertorData).build();
\r
262 etherMatch = salMatch.getEthernetMatch();
\r
263 IpMatch ipMatch = salMatch.getIpMatch();
\r
264 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
265 Assert.assertEquals("Wrong dl src",
\r
266 null, etherMatch.getEthernetSource());
\r
267 Assert.assertEquals("Wrong dl dst",
\r
268 null, etherMatch.getEthernetDestination());
\r
269 Assert.assertEquals("Wrong dl type", dlType,
\r
270 etherMatch.getEthernetType().getType().getValue());
\r
271 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
272 Assert.assertEquals("Wrong ip protocol",
\r
273 ipProto, ipMatch.getIpProtocol());
\r
274 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
275 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
276 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
277 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
278 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
279 Assert.assertEquals("Wrong ICMPv4 match",
\r
280 null, salMatch.getIcmpv4Match());
\r
282 // TP_SRC is not wildcarded but null.
\r
283 wc = new FlowWildcardsV10(
\r
284 true, true, false, true, true, true, false, true, true, false);
\r
285 match = builder.setWildcards(wc).build();
\r
286 salMatch = convert(match, datapathIdConvertorData).build();
\r
287 etherMatch = salMatch.getEthernetMatch();
\r
288 ipMatch = salMatch.getIpMatch();
\r
289 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
290 Assert.assertEquals("Wrong dl src",
\r
291 null, etherMatch.getEthernetSource());
\r
292 Assert.assertEquals("Wrong dl dst",
\r
293 null, etherMatch.getEthernetDestination());
\r
294 Assert.assertEquals("Wrong dl type", dlType,
\r
295 etherMatch.getEthernetType().getType().getValue());
\r
296 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
297 Assert.assertEquals("Wrong ip protocol",
\r
298 ipProto, ipMatch.getIpProtocol());
\r
299 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
300 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
301 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
302 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
303 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
304 Assert.assertEquals("Wrong ICMPv4 match",
\r
305 null, salMatch.getIcmpv4Match());
\r
307 // Specify ICMPv4 type.
\r
308 Short icmpType = 10;
\r
309 match = builder.setTpSrc(icmpType.intValue()).build();
\r
310 salMatch = convert(match, datapathIdConvertorData).build();
\r
311 etherMatch = salMatch.getEthernetMatch();
\r
312 ipMatch = salMatch.getIpMatch();
\r
313 Icmpv4Match icmpv4Match = salMatch.getIcmpv4Match();
\r
314 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
315 Assert.assertEquals("Wrong dl src",
\r
316 null, etherMatch.getEthernetSource());
\r
317 Assert.assertEquals("Wrong dl dst",
\r
318 null, etherMatch.getEthernetDestination());
\r
319 Assert.assertEquals("Wrong dl type", dlType,
\r
320 etherMatch.getEthernetType().getType().getValue());
\r
321 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
322 Assert.assertEquals("Wrong ip protocol",
\r
323 ipProto, ipMatch.getIpProtocol());
\r
324 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
325 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
326 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
327 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
328 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
329 Assert.assertEquals("Wrong ICMPv4 type",
\r
330 icmpType, icmpv4Match.getIcmpv4Type());
\r
331 Assert.assertEquals("Wrong ICMPv4 code",
\r
332 null, icmpv4Match.getIcmpv4Code());
\r
334 // TP_DST is not wildcarded but null.
\r
335 wc = new FlowWildcardsV10(
\r
336 true, true, false, true, true, true, false, true, false, false);
\r
337 match = builder.setWildcards(wc).build();
\r
338 salMatch = convert(match, datapathIdConvertorData).build();
\r
339 etherMatch = salMatch.getEthernetMatch();
\r
340 ipMatch = salMatch.getIpMatch();
\r
341 icmpv4Match = salMatch.getIcmpv4Match();
\r
342 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
343 Assert.assertEquals("Wrong dl src",
\r
344 null, etherMatch.getEthernetSource());
\r
345 Assert.assertEquals("Wrong dl dst",
\r
346 null, etherMatch.getEthernetDestination());
\r
347 Assert.assertEquals("Wrong dl type", dlType,
\r
348 etherMatch.getEthernetType().getType().getValue());
\r
349 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
350 Assert.assertEquals("Wrong ip protocol",
\r
351 ipProto, ipMatch.getIpProtocol());
\r
352 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
353 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
354 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
355 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
356 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
357 Assert.assertEquals("Wrong ICMPv4 type",
\r
358 icmpType, icmpv4Match.getIcmpv4Type());
\r
359 Assert.assertEquals("Wrong ICMPv4 code",
\r
360 null, icmpv4Match.getIcmpv4Code());
\r
362 // Specify ICMPv4 code only.
\r
363 Short icmpCode = 33;
\r
364 match = builder.setTpSrc(null).setTpDst(icmpCode.intValue()).build();
\r
365 salMatch = convert(match, datapathIdConvertorData).build();
\r
366 etherMatch = salMatch.getEthernetMatch();
\r
367 ipMatch = salMatch.getIpMatch();
\r
368 icmpv4Match = salMatch.getIcmpv4Match();
\r
369 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
370 Assert.assertEquals("Wrong dl src",
\r
371 null, etherMatch.getEthernetSource());
\r
372 Assert.assertEquals("Wrong dl dst",
\r
373 null, etherMatch.getEthernetDestination());
\r
374 Assert.assertEquals("Wrong dl type", dlType,
\r
375 etherMatch.getEthernetType().getType().getValue());
\r
376 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
377 Assert.assertEquals("Wrong ip protocol",
\r
378 ipProto, ipMatch.getIpProtocol());
\r
379 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
380 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
381 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
382 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
383 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
384 Assert.assertEquals("Wrong ICMPv4 type",
\r
385 null, icmpv4Match.getIcmpv4Type());
\r
386 Assert.assertEquals("Wrong ICMPv4 code",
\r
387 icmpCode, icmpv4Match.getIcmpv4Code());
\r
389 // Specify both ICMPv4 type and code.
\r
392 match = builder.setTpSrc(icmpType.intValue()).
\r
393 setTpDst(icmpCode.intValue()).build();
\r
394 salMatch = convert(match, datapathIdConvertorData).build();
\r
395 etherMatch = salMatch.getEthernetMatch();
\r
396 ipMatch = salMatch.getIpMatch();
\r
397 icmpv4Match = salMatch.getIcmpv4Match();
\r
398 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
399 Assert.assertEquals("Wrong dl src",
\r
400 null, etherMatch.getEthernetSource());
\r
401 Assert.assertEquals("Wrong dl dst",
\r
402 null, etherMatch.getEthernetDestination());
\r
403 Assert.assertEquals("Wrong dl type", dlType,
\r
404 etherMatch.getEthernetType().getType().getValue());
\r
405 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
406 Assert.assertEquals("Wrong ip protocol",
\r
407 ipProto, ipMatch.getIpProtocol());
\r
408 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
409 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
410 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
411 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
412 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
413 Assert.assertEquals("Wrong ICMPv4 type",
\r
414 icmpType, icmpv4Match.getIcmpv4Type());
\r
415 Assert.assertEquals("Wrong ICMPv4 code",
\r
416 icmpCode, icmpv4Match.getIcmpv4Code());
\r
420 * TCP match test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}
\r
423 public void testTcpMatch() {
\r
424 // TP_SRC, TP_DST are wildcarded.
\r
425 // NW_PROTO is not wildcarded but null.
\r
426 Long dlType = 0x800L;
\r
427 FlowWildcardsV10 wc = new FlowWildcardsV10(
\r
428 true, true, false, true, true, true, false, true, true, true);
\r
429 MatchV10Builder builder = new MatchV10Builder().
\r
431 setDlType(dlType.intValue());
\r
432 MatchV10 match = builder.build();
\r
434 BigInteger dpid = BigInteger.valueOf(12345L);
\r
435 final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
\r
436 datapathIdConvertorData.setDatapathId(dpid);
\r
438 Match salMatch = convert(match, datapathIdConvertorData).build();
\r
439 EthernetMatch etherMatch = salMatch.getEthernetMatch();
\r
440 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
441 Assert.assertEquals("Wrong dl src",
\r
442 null, etherMatch.getEthernetSource());
\r
443 Assert.assertEquals("Wrong dl dst",
\r
444 null, etherMatch.getEthernetDestination());
\r
445 Assert.assertEquals("Wrong dl type", dlType,
\r
446 etherMatch.getEthernetType().getType().getValue());
\r
447 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
448 Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
\r
449 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
450 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
451 Assert.assertEquals("Wrong ICMPv4 match",
\r
452 null, salMatch.getIcmpv4Match());
\r
454 // Specify TCP protocol.
\r
456 match = builder.setNwProto(ipProto).build();
\r
457 salMatch = convert(match, datapathIdConvertorData).build();
\r
458 etherMatch = salMatch.getEthernetMatch();
\r
459 IpMatch ipMatch = salMatch.getIpMatch();
\r
460 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
461 Assert.assertEquals("Wrong dl src",
\r
462 null, etherMatch.getEthernetSource());
\r
463 Assert.assertEquals("Wrong dl dst",
\r
464 null, etherMatch.getEthernetDestination());
\r
465 Assert.assertEquals("Wrong dl type", dlType,
\r
466 etherMatch.getEthernetType().getType().getValue());
\r
467 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
468 Assert.assertEquals("Wrong ip protocol",
\r
469 ipProto, ipMatch.getIpProtocol());
\r
470 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
471 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
472 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
473 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
474 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
475 Assert.assertEquals("Wrong ICMPv4 match",
\r
476 null, salMatch.getIcmpv4Match());
\r
478 // TP_SRC is not wildcarded but null.
\r
479 wc = new FlowWildcardsV10(
\r
480 true, true, false, true, true, true, false, true, true, false);
\r
481 match = builder.setWildcards(wc).build();
\r
482 salMatch = convert(match, datapathIdConvertorData).build();
\r
483 etherMatch = salMatch.getEthernetMatch();
\r
484 ipMatch = salMatch.getIpMatch();
\r
485 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
486 Assert.assertEquals("Wrong dl src",
\r
487 null, etherMatch.getEthernetSource());
\r
488 Assert.assertEquals("Wrong dl dst",
\r
489 null, etherMatch.getEthernetDestination());
\r
490 Assert.assertEquals("Wrong dl type", dlType,
\r
491 etherMatch.getEthernetType().getType().getValue());
\r
492 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
493 Assert.assertEquals("Wrong ip protocol",
\r
494 ipProto, ipMatch.getIpProtocol());
\r
495 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
496 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
497 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
498 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
499 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
500 Assert.assertEquals("Wrong ICMPv4 match",
\r
501 null, salMatch.getIcmpv4Match());
\r
503 // Specify TCP source port.
\r
504 Integer srcPort = 60000;
\r
505 match = builder.setTpSrc(srcPort).build();
\r
506 salMatch = convert(match, datapathIdConvertorData).build();
\r
507 etherMatch = salMatch.getEthernetMatch();
\r
508 ipMatch = salMatch.getIpMatch();
\r
509 TcpMatch tcpMatch = (TcpMatch)salMatch.getLayer4Match();
\r
510 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
511 Assert.assertEquals("Wrong dl src",
\r
512 null, etherMatch.getEthernetSource());
\r
513 Assert.assertEquals("Wrong dl dst",
\r
514 null, etherMatch.getEthernetDestination());
\r
515 Assert.assertEquals("Wrong dl type", dlType,
\r
516 etherMatch.getEthernetType().getType().getValue());
\r
517 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
518 Assert.assertEquals("Wrong ip protocol",
\r
519 ipProto, ipMatch.getIpProtocol());
\r
520 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
521 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
522 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
523 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
524 Assert.assertEquals("Wrong TCP src", srcPort,
\r
525 tcpMatch.getTcpSourcePort().getValue());
\r
526 Assert.assertEquals("Wrong TCP dst", null,
\r
527 tcpMatch.getTcpDestinationPort());
\r
528 Assert.assertEquals("Wrong ICMPv4 match",
\r
529 null, salMatch.getIcmpv4Match());
\r
531 // TP_DST is not wildcarded but null.
\r
532 wc = new FlowWildcardsV10(
\r
533 true, true, false, true, true, true, false, true, false, false);
\r
534 match = builder.setWildcards(wc).build();
\r
535 salMatch = convert(match, datapathIdConvertorData).build();
\r
536 etherMatch = salMatch.getEthernetMatch();
\r
537 ipMatch = salMatch.getIpMatch();
\r
538 tcpMatch = (TcpMatch)salMatch.getLayer4Match();
\r
539 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
540 Assert.assertEquals("Wrong dl src",
\r
541 null, etherMatch.getEthernetSource());
\r
542 Assert.assertEquals("Wrong dl dst",
\r
543 null, etherMatch.getEthernetDestination());
\r
544 Assert.assertEquals("Wrong dl type", dlType,
\r
545 etherMatch.getEthernetType().getType().getValue());
\r
546 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
547 Assert.assertEquals("Wrong ip protocol",
\r
548 ipProto, ipMatch.getIpProtocol());
\r
549 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
550 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
551 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
552 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
553 Assert.assertEquals("Wrong TCP src", srcPort,
\r
554 tcpMatch.getTcpSourcePort().getValue());
\r
555 Assert.assertEquals("Wrong TCP dst", null,
\r
556 tcpMatch.getTcpDestinationPort());
\r
557 Assert.assertEquals("Wrong ICMPv4 match",
\r
558 null, salMatch.getIcmpv4Match());
\r
560 // Specify TCP destination port only.
\r
561 Integer dstPort = 6653;
\r
562 match = builder.setTpSrc(null).setTpDst(dstPort).build();
\r
563 salMatch = convert(match, datapathIdConvertorData).build();
\r
564 etherMatch = salMatch.getEthernetMatch();
\r
565 ipMatch = salMatch.getIpMatch();
\r
566 tcpMatch = (TcpMatch)salMatch.getLayer4Match();
\r
567 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
568 Assert.assertEquals("Wrong dl src",
\r
569 null, etherMatch.getEthernetSource());
\r
570 Assert.assertEquals("Wrong dl dst",
\r
571 null, etherMatch.getEthernetDestination());
\r
572 Assert.assertEquals("Wrong dl type", dlType,
\r
573 etherMatch.getEthernetType().getType().getValue());
\r
574 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
575 Assert.assertEquals("Wrong ip protocol",
\r
576 ipProto, ipMatch.getIpProtocol());
\r
577 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
578 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
579 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
580 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
581 Assert.assertEquals("Wrong TCP src", null,
\r
582 tcpMatch.getTcpSourcePort());
\r
583 Assert.assertEquals("Wrong TCP dst", dstPort,
\r
584 tcpMatch.getTcpDestinationPort().getValue());
\r
585 Assert.assertEquals("Wrong ICMPv4 match",
\r
586 null, salMatch.getIcmpv4Match());
\r
588 // Specify both source and destination port.
\r
591 match = builder.setTpSrc(srcPort).setTpDst(dstPort).build();
\r
592 salMatch = convert(match, datapathIdConvertorData).build();
\r
593 etherMatch = salMatch.getEthernetMatch();
\r
594 ipMatch = salMatch.getIpMatch();
\r
595 tcpMatch = (TcpMatch)salMatch.getLayer4Match();
\r
596 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
597 Assert.assertEquals("Wrong dl src",
\r
598 null, etherMatch.getEthernetSource());
\r
599 Assert.assertEquals("Wrong dl dst",
\r
600 null, etherMatch.getEthernetDestination());
\r
601 Assert.assertEquals("Wrong dl type", dlType,
\r
602 etherMatch.getEthernetType().getType().getValue());
\r
603 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
604 Assert.assertEquals("Wrong ip protocol",
\r
605 ipProto, ipMatch.getIpProtocol());
\r
606 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
607 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
608 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
609 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
610 Assert.assertEquals("Wrong TCP src", srcPort,
\r
611 tcpMatch.getTcpSourcePort().getValue());
\r
612 Assert.assertEquals("Wrong TCP dst", dstPort,
\r
613 tcpMatch.getTcpDestinationPort().getValue());
\r
614 Assert.assertEquals("Wrong ICMPv4 match",
\r
615 null, salMatch.getIcmpv4Match());
\r
619 * UDP match test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}
\r
622 public void testUdpMatch() {
\r
623 // TP_SRC, TP_DST are wildcarded.
\r
624 // NW_PROTO is not wildcarded but null.
\r
625 Long dlType = 0x800L;
\r
626 FlowWildcardsV10 wc = new FlowWildcardsV10(
\r
627 true, true, false, true, true, true, false, true, true, true);
\r
628 MatchV10Builder builder = new MatchV10Builder().
\r
630 setDlType(dlType.intValue());
\r
631 MatchV10 match = builder.build();
\r
633 BigInteger dpid = BigInteger.valueOf(12345L);
\r
634 final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
\r
635 datapathIdConvertorData.setDatapathId(dpid);
\r
637 Match salMatch = convert(match, datapathIdConvertorData).build();
\r
638 EthernetMatch etherMatch = salMatch.getEthernetMatch();
\r
639 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
640 Assert.assertEquals("Wrong dl src",
\r
641 null, etherMatch.getEthernetSource());
\r
642 Assert.assertEquals("Wrong dl dst",
\r
643 null, etherMatch.getEthernetDestination());
\r
644 Assert.assertEquals("Wrong dl type", dlType,
\r
645 etherMatch.getEthernetType().getType().getValue());
\r
646 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
647 Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
\r
648 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
649 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
650 Assert.assertEquals("Wrong ICMPv4 match",
\r
651 null, salMatch.getIcmpv4Match());
\r
653 // Specify UDP protocol.
\r
654 Short ipProto = 17;
\r
655 match = builder.setNwProto(ipProto).build();
\r
656 salMatch = convert(match, datapathIdConvertorData).build();
\r
657 etherMatch = salMatch.getEthernetMatch();
\r
658 IpMatch ipMatch = salMatch.getIpMatch();
\r
659 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
660 Assert.assertEquals("Wrong dl src",
\r
661 null, etherMatch.getEthernetSource());
\r
662 Assert.assertEquals("Wrong dl dst",
\r
663 null, etherMatch.getEthernetDestination());
\r
664 Assert.assertEquals("Wrong dl type", dlType,
\r
665 etherMatch.getEthernetType().getType().getValue());
\r
666 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
667 Assert.assertEquals("Wrong ip protocol",
\r
668 ipProto, ipMatch.getIpProtocol());
\r
669 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
670 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
671 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
672 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
673 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
674 Assert.assertEquals("Wrong ICMPv4 match",
\r
675 null, salMatch.getIcmpv4Match());
\r
677 // TP_SRC is not wildcarded but null.
\r
678 wc = new FlowWildcardsV10(
\r
679 true, true, false, true, true, true, false, true, true, false);
\r
680 match = builder.setWildcards(wc).build();
\r
681 salMatch = convert(match, datapathIdConvertorData).build();
\r
682 etherMatch = salMatch.getEthernetMatch();
\r
683 ipMatch = salMatch.getIpMatch();
\r
684 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
685 Assert.assertEquals("Wrong dl src",
\r
686 null, etherMatch.getEthernetSource());
\r
687 Assert.assertEquals("Wrong dl dst",
\r
688 null, etherMatch.getEthernetDestination());
\r
689 Assert.assertEquals("Wrong dl type", dlType,
\r
690 etherMatch.getEthernetType().getType().getValue());
\r
691 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
692 Assert.assertEquals("Wrong ip protocol",
\r
693 ipProto, ipMatch.getIpProtocol());
\r
694 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
695 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
696 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
697 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
698 Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
\r
699 Assert.assertEquals("Wrong ICMPv4 match",
\r
700 null, salMatch.getIcmpv4Match());
\r
702 // Specify UDP source port.
\r
703 Integer srcPort = 60000;
\r
704 match = builder.setTpSrc(srcPort).build();
\r
705 salMatch = convert(match, datapathIdConvertorData).build();
\r
706 etherMatch = salMatch.getEthernetMatch();
\r
707 ipMatch = salMatch.getIpMatch();
\r
708 UdpMatch udpMatch = (UdpMatch)salMatch.getLayer4Match();
\r
709 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
710 Assert.assertEquals("Wrong dl src",
\r
711 null, etherMatch.getEthernetSource());
\r
712 Assert.assertEquals("Wrong dl dst",
\r
713 null, etherMatch.getEthernetDestination());
\r
714 Assert.assertEquals("Wrong dl type", dlType,
\r
715 etherMatch.getEthernetType().getType().getValue());
\r
716 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
717 Assert.assertEquals("Wrong ip protocol",
\r
718 ipProto, ipMatch.getIpProtocol());
\r
719 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
720 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
721 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
722 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
723 Assert.assertEquals("Wrong UDP src", srcPort,
\r
724 udpMatch.getUdpSourcePort().getValue());
\r
725 Assert.assertEquals("Wrong UDP dst", null,
\r
726 udpMatch.getUdpDestinationPort());
\r
727 Assert.assertEquals("Wrong ICMPv4 match",
\r
728 null, salMatch.getIcmpv4Match());
\r
730 // TP_DST is not wildcarded but null.
\r
731 wc = new FlowWildcardsV10(
\r
732 true, true, false, true, true, true, false, true, false, false);
\r
733 match = builder.setWildcards(wc).build();
\r
734 salMatch = convert(match, datapathIdConvertorData).build();
\r
735 etherMatch = salMatch.getEthernetMatch();
\r
736 ipMatch = salMatch.getIpMatch();
\r
737 udpMatch = (UdpMatch)salMatch.getLayer4Match();
\r
738 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
739 Assert.assertEquals("Wrong dl src",
\r
740 null, etherMatch.getEthernetSource());
\r
741 Assert.assertEquals("Wrong dl dst",
\r
742 null, etherMatch.getEthernetDestination());
\r
743 Assert.assertEquals("Wrong dl type", dlType,
\r
744 etherMatch.getEthernetType().getType().getValue());
\r
745 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
746 Assert.assertEquals("Wrong ip protocol",
\r
747 ipProto, ipMatch.getIpProtocol());
\r
748 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
749 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
750 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
751 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
752 Assert.assertEquals("Wrong UDP src", srcPort,
\r
753 udpMatch.getUdpSourcePort().getValue());
\r
754 Assert.assertEquals("Wrong UDP dst", null,
\r
755 udpMatch.getUdpDestinationPort());
\r
756 Assert.assertEquals("Wrong ICMPv4 match",
\r
757 null, salMatch.getIcmpv4Match());
\r
759 // Specify UDP destination port only.
\r
760 Integer dstPort = 6653;
\r
761 match = builder.setTpSrc(null).setTpDst(dstPort).build();
\r
762 salMatch = convert(match, datapathIdConvertorData).build();
\r
763 etherMatch = salMatch.getEthernetMatch();
\r
764 ipMatch = salMatch.getIpMatch();
\r
765 udpMatch = (UdpMatch)salMatch.getLayer4Match();
\r
766 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
767 Assert.assertEquals("Wrong dl src",
\r
768 null, etherMatch.getEthernetSource());
\r
769 Assert.assertEquals("Wrong dl dst",
\r
770 null, etherMatch.getEthernetDestination());
\r
771 Assert.assertEquals("Wrong dl type", dlType,
\r
772 etherMatch.getEthernetType().getType().getValue());
\r
773 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
774 Assert.assertEquals("Wrong ip protocol",
\r
775 ipProto, ipMatch.getIpProtocol());
\r
776 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
777 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
778 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
779 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
780 Assert.assertEquals("Wrong UDP src", null,
\r
781 udpMatch.getUdpSourcePort());
\r
782 Assert.assertEquals("Wrong UDP dst", dstPort,
\r
783 udpMatch.getUdpDestinationPort().getValue());
\r
784 Assert.assertEquals("Wrong ICMPv4 match",
\r
785 null, salMatch.getIcmpv4Match());
\r
787 // Specify both source and destination port.
\r
790 match = builder.setTpSrc(srcPort).setTpDst(dstPort).build();
\r
791 salMatch = convert(match, datapathIdConvertorData).build();
\r
792 etherMatch = salMatch.getEthernetMatch();
\r
793 ipMatch = salMatch.getIpMatch();
\r
794 udpMatch = (UdpMatch)salMatch.getLayer4Match();
\r
795 Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
\r
796 Assert.assertEquals("Wrong dl src",
\r
797 null, etherMatch.getEthernetSource());
\r
798 Assert.assertEquals("Wrong dl dst",
\r
799 null, etherMatch.getEthernetDestination());
\r
800 Assert.assertEquals("Wrong dl type", dlType,
\r
801 etherMatch.getEthernetType().getType().getValue());
\r
802 Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
\r
803 Assert.assertEquals("Wrong ip protocol",
\r
804 ipProto, ipMatch.getIpProtocol());
\r
805 Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
\r
806 Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
\r
807 Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
\r
808 Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
\r
809 Assert.assertEquals("Wrong UDP src", srcPort,
\r
810 udpMatch.getUdpSourcePort().getValue());
\r
811 Assert.assertEquals("Wrong UDP dst", dstPort,
\r
812 udpMatch.getUdpDestinationPort().getValue());
\r
813 Assert.assertEquals("Wrong ICMPv4 match",
\r
814 null, salMatch.getIcmpv4Match());
\r
817 private MatchBuilder convert(MatchV10 match, VersionDatapathIdConvertorData data) {
\r
818 final Optional<MatchBuilder> salMatchOptional = ConvertorManager.getInstance().convert(match, data);
\r
820 return salMatchOptional.orElse(new MatchBuilder());
\r