2 * Copyright (c) 2014 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.List;
\r
14 import org.junit.Assert;
\r
15 import org.junit.Before;
\r
16 import org.junit.Test;
\r
17 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
\r
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
\r
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
\r
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
\r
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
\r
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
\r
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
\r
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
\r
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
\r
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
\r
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
\r
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
\r
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
\r
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
\r
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
\r
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
\r
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
\r
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
\r
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
\r
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
\r
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
\r
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
\r
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
\r
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
\r
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
\r
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
\r
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
\r
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
\r
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
\r
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
\r
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
\r
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
\r
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
\r
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
\r
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
\r
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
\r
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
\r
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry;
\r
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry;
\r
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry;
\r
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry;
\r
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry;
\r
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry;
\r
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry;
\r
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry;
\r
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry;
\r
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry;
\r
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry;
\r
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry;
\r
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry;
\r
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry;
\r
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry;
\r
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry;
\r
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry;
\r
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry;
\r
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry;
\r
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry;
\r
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry;
\r
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry;
\r
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry;
\r
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
\r
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;
\r
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;
\r
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;
\r
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa;
\r
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha;
\r
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa;
\r
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
\r
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
\r
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;
\r
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;
\r
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;
\r
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;
\r
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;
\r
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;
\r
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
\r
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp;
\r
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn;
\r
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto;
\r
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst;
\r
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;
\r
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst;
\r
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr;
\r
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel;
\r
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll;
\r
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget;
\r
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll;
\r
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;
\r
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
\r
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata;
\r
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;
\r
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;
\r
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;
\r
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
\r
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;
\r
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;
\r
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;
\r
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;
\r
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;
\r
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;
\r
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;
\r
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;
\r
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
\r
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
\r
123 * @author michal.polkorab
\r
126 public class MatchConvertorImpl2Test {
\r
128 MatchConvertorImpl convertor = new MatchConvertorImpl();
\r
131 * Initializes OpenflowPortsUtil
\r
134 public void startUp() {
\r
135 OpenflowPortsUtil.init();
\r
139 * Test {@link MatchConvertorImpl#convert(Match, BigInteger)
\r
142 public void testEmptyAndNullInput() {
\r
143 MatchBuilder builder = new MatchBuilder();
\r
144 Match match = builder.build();
\r
146 List<MatchEntries> entries = convertor.convert(null, new BigInteger("42"));
\r
147 Assert.assertEquals("Wrong entries size", 0, entries.size());
\r
149 entries = convertor.convert(match, new BigInteger("42"));
\r
150 Assert.assertEquals("Wrong entries size", 0, entries.size());
\r
154 * Test {@link MatchConvertorImpl#convert(Match, BigInteger)
\r
157 public void testConversion() {
\r
158 MatchBuilder builder = new MatchBuilder();
\r
159 builder.setInPort(new NodeConnectorId("openflow:42:1"));
\r
160 builder.setInPhyPort(new NodeConnectorId("openflow:42:2"));
\r
161 MetadataBuilder metadataBuilder = new MetadataBuilder();
\r
162 metadataBuilder.setMetadata(new BigInteger("3"));
\r
163 builder.setMetadata(metadataBuilder.build());
\r
164 EthernetMatchBuilder ethernetBuilder = new EthernetMatchBuilder();
\r
165 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
\r
166 ethTypeBuilder.setType(new EtherType(4L));
\r
167 ethernetBuilder.setEthernetType(ethTypeBuilder.build());
\r
168 EthernetSourceBuilder ethSrcBuilder = new EthernetSourceBuilder();
\r
169 ethSrcBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
\r
170 ethernetBuilder.setEthernetSource(ethSrcBuilder.build());
\r
171 EthernetDestinationBuilder ethDstBuilder = new EthernetDestinationBuilder();
\r
172 ethDstBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
\r
173 ethernetBuilder.setEthernetDestination(ethDstBuilder.build());
\r
174 builder.setEthernetMatch(ethernetBuilder.build());
\r
175 VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
\r
176 VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
\r
177 vlanIdBuilder.setVlanId(new VlanId(7));
\r
178 vlanIdBuilder.setVlanIdPresent(true);
\r
179 vlanBuilder.setVlanId(vlanIdBuilder.build());
\r
180 vlanBuilder.setVlanPcp(new VlanPcp((short) 7));
\r
181 builder.setVlanMatch(vlanBuilder.build());
\r
182 IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
\r
183 ipMatchBuilder.setIpDscp(new Dscp((short) 8));
\r
184 ipMatchBuilder.setIpEcn((short) 9);
\r
185 ipMatchBuilder.setIpProtocol((short) 10);
\r
186 builder.setIpMatch(ipMatchBuilder.build());
\r
187 TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
\r
188 tcpMatchBuilder.setTcpSourcePort(new PortNumber(11));
\r
189 tcpMatchBuilder.setTcpDestinationPort(new PortNumber(12));
\r
190 builder.setLayer4Match(tcpMatchBuilder.build());
\r
191 Icmpv4MatchBuilder icmpv4Builder = new Icmpv4MatchBuilder();
\r
192 icmpv4Builder.setIcmpv4Type((short) 13);
\r
193 icmpv4Builder.setIcmpv4Code((short) 14);
\r
194 builder.setIcmpv4Match(icmpv4Builder.build());
\r
195 Icmpv6MatchBuilder icmpv6Builder = new Icmpv6MatchBuilder();
\r
196 icmpv6Builder.setIcmpv6Type((short) 15);
\r
197 icmpv6Builder.setIcmpv6Code((short) 16);
\r
198 builder.setIcmpv6Match(icmpv6Builder.build());
\r
199 ProtocolMatchFieldsBuilder protoBuilder = new ProtocolMatchFieldsBuilder();
\r
200 protoBuilder.setMplsLabel(17L);
\r
201 protoBuilder.setMplsTc((short) 18);
\r
202 protoBuilder.setMplsBos((short) 19);
\r
203 PbbBuilder pbbBuilder = new PbbBuilder();
\r
204 pbbBuilder.setPbbIsid(20L);
\r
205 protoBuilder.setPbb(pbbBuilder.build());
\r
206 builder.setProtocolMatchFields(protoBuilder.build());
\r
207 TunnelBuilder tunnelBuilder = new TunnelBuilder();
\r
208 tunnelBuilder.setTunnelId(new BigInteger("21"));
\r
209 builder.setTunnel(tunnelBuilder.build());
\r
210 Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
\r
211 ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("10.0.0.1/32"));
\r
212 ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("10.0.0.2/32"));
\r
213 builder.setLayer3Match(ipv4MatchBuilder.build());
\r
214 Match match = builder.build();
\r
216 List<MatchEntries> entries = convertor.convert(match, new BigInteger("42"));
\r
217 Assert.assertEquals("Wrong entries size", 24, entries.size());
\r
218 MatchEntries entry = entries.get(0);
\r
219 checkEntryHeader(entry, InPort.class, false);
\r
220 Assert.assertEquals("Wrong in port", 1, entry.getAugmentation(PortNumberMatchEntry.class)
\r
221 .getPortNumber().getValue().intValue());
\r
222 entry = entries.get(1);
\r
223 checkEntryHeader(entry, InPhyPort.class, false);
\r
224 Assert.assertEquals("Wrong in phy port", 2, entry.getAugmentation(PortNumberMatchEntry.class)
\r
225 .getPortNumber().getValue().intValue());
\r
226 entry = entries.get(2);
\r
227 checkEntryHeader(entry, Metadata.class, false);
\r
228 Assert.assertArrayEquals("Wrong metadata", new byte[]{0, 0, 0, 0, 0, 0, 0, 3},
\r
229 entry.getAugmentation(MetadataMatchEntry.class).getMetadata());
\r
230 entry = entries.get(3);
\r
231 checkEntryHeader(entry, EthDst.class, false);
\r
232 Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:06"),
\r
233 entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress());
\r
234 entry = entries.get(4);
\r
235 checkEntryHeader(entry, EthSrc.class, false);
\r
236 Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:05"),
\r
237 entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress());
\r
238 entry = entries.get(5);
\r
239 checkEntryHeader(entry, EthType.class, false);
\r
240 Assert.assertEquals("Wrong eth type", 4, entry.getAugmentation(EthTypeMatchEntry.class)
\r
241 .getEthType().getValue().intValue());
\r
242 entry = entries.get(6);
\r
243 checkEntryHeader(entry, VlanVid.class, false);
\r
244 Assert.assertEquals("Wrong vlan id", 7, entry.getAugmentation(VlanVidMatchEntry.class)
\r
245 .getVlanVid().intValue());
\r
246 Assert.assertEquals("Wrong cfi bit", true, entry.getAugmentation(VlanVidMatchEntry.class)
\r
248 entry = entries.get(7);
\r
249 checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp.class, false);
\r
250 Assert.assertEquals("Wrong vlan pcp", 7, entry.getAugmentation(VlanPcpMatchEntry.class)
\r
251 .getVlanPcp().intValue());
\r
252 entry = entries.get(8);
\r
253 checkEntryHeader(entry, IpDscp.class, false);
\r
254 Assert.assertEquals("Wrong ip dscp", 8, entry.getAugmentation(DscpMatchEntry.class)
\r
255 .getDscp().getValue().intValue());
\r
256 entry = entries.get(9);
\r
257 checkEntryHeader(entry, IpEcn.class, false);
\r
258 Assert.assertEquals("Wrong ip ecn", 9, entry.getAugmentation(EcnMatchEntry.class)
\r
259 .getEcn().intValue());
\r
260 entry = entries.get(10);
\r
261 checkEntryHeader(entry, IpProto.class, false);
\r
262 Assert.assertEquals("Wrong ip proto", 10, entry.getAugmentation(ProtocolNumberMatchEntry.class)
\r
263 .getProtocolNumber().intValue());
\r
264 entry = entries.get(11);
\r
265 checkEntryHeader(entry, TcpSrc.class, false);
\r
266 Assert.assertEquals("Wrong tcp src", 11, entry.getAugmentation(PortMatchEntry.class)
\r
267 .getPort().getValue().intValue());
\r
268 entry = entries.get(12);
\r
269 checkEntryHeader(entry, TcpDst.class, false);
\r
270 Assert.assertEquals("Wrong tcp dst", 12, entry.getAugmentation(PortMatchEntry.class)
\r
271 .getPort().getValue().intValue());
\r
272 entry = entries.get(13);
\r
273 checkEntryHeader(entry, Icmpv4Type.class, false);
\r
274 Assert.assertEquals("Wrong icmpv4 type", 13, entry.getAugmentation(Icmpv4TypeMatchEntry.class)
\r
275 .getIcmpv4Type().intValue());
\r
276 entry = entries.get(14);
\r
277 checkEntryHeader(entry, Icmpv4Code.class, false);
\r
278 Assert.assertEquals("Wrong icmpv4 code", 14, entry.getAugmentation(Icmpv4CodeMatchEntry.class)
\r
279 .getIcmpv4Code().intValue());
\r
280 entry = entries.get(15);
\r
281 checkEntryHeader(entry, Icmpv6Type.class, false);
\r
282 Assert.assertEquals("Wrong icmpv6 type", 15, entry.getAugmentation(Icmpv6TypeMatchEntry.class)
\r
283 .getIcmpv6Type().intValue());
\r
284 entry = entries.get(16);
\r
285 checkEntryHeader(entry, Icmpv6Code.class, false);
\r
286 Assert.assertEquals("Wrong icmpv6 code", 16, entry.getAugmentation(Icmpv6CodeMatchEntry.class)
\r
287 .getIcmpv6Code().intValue());
\r
288 entry = entries.get(17);
\r
289 checkEntryHeader(entry, Ipv4Src.class, false);
\r
290 Assert.assertEquals("Wrong ipv4 src", "10.0.0.1", entry.getAugmentation(Ipv4AddressMatchEntry.class)
\r
291 .getIpv4Address().getValue());
\r
292 entry = entries.get(18);
\r
293 checkEntryHeader(entry, Ipv4Dst.class, false);
\r
294 Assert.assertEquals("Wrong ipv4 dst", "10.0.0.2", entry.getAugmentation(Ipv4AddressMatchEntry.class)
\r
295 .getIpv4Address().getValue());
\r
296 entry = entries.get(19);
\r
297 checkEntryHeader(entry, MplsLabel.class, false);
\r
298 Assert.assertEquals("Wrong mpls label", 17, entry.getAugmentation(MplsLabelMatchEntry.class)
\r
299 .getMplsLabel().intValue());
\r
300 entry = entries.get(20);
\r
301 checkEntryHeader(entry, MplsBos.class, false);
\r
302 Assert.assertEquals("Wrong mpls bos", true, entry.getAugmentation(BosMatchEntry.class).isBos());
\r
303 entry = entries.get(21);
\r
304 checkEntryHeader(entry, MplsTc.class, false);
\r
305 Assert.assertEquals("Wrong mpls tc", 18, entry.getAugmentation(TcMatchEntry.class)
\r
306 .getTc().intValue());
\r
307 entry = entries.get(22);
\r
308 checkEntryHeader(entry, PbbIsid.class, false);
\r
309 Assert.assertEquals("Wrong pbb isid", 20, entry.getAugmentation(IsidMatchEntry.class)
\r
310 .getIsid().intValue());
\r
311 entry = entries.get(23);
\r
312 checkEntryHeader(entry, TunnelId.class, false);
\r
313 Assert.assertArrayEquals("Wrong tunnel id", new byte[]{0, 0, 0, 0, 0, 0, 0, 21},
\r
314 entry.getAugmentation(MetadataMatchEntry.class).getMetadata());
\r
317 private static void checkEntryHeader(MatchEntries entry, Class<? extends MatchField> field, boolean hasMask) {
\r
318 Assert.assertEquals("Wrong oxm class", OpenflowBasicClass.class, entry.getOxmClass());
\r
319 Assert.assertEquals("Wrong oxm field", field, entry.getOxmMatchField());
\r
320 Assert.assertEquals("Wrong hasMask", hasMask, entry.isHasMask());
\r
324 * Test {@link MatchConvertorImpl#convert(Match, BigInteger)
\r
327 public void testUdpMatchConversion() {
\r
328 MatchBuilder builder = new MatchBuilder();
\r
329 UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
\r
330 udpMatchBuilder.setUdpSourcePort(new PortNumber(11));
\r
331 udpMatchBuilder.setUdpDestinationPort(new PortNumber(12));
\r
332 builder.setLayer4Match(udpMatchBuilder.build());
\r
333 Match match = builder.build();
\r
335 List<MatchEntries> entries = convertor.convert(match, new BigInteger("42"));
\r
336 Assert.assertEquals("Wrong entries size", 2, entries.size());
\r
337 MatchEntries entry = entries.get(0);
\r
338 checkEntryHeader(entry, UdpSrc.class, false);
\r
339 Assert.assertEquals("Wrong udp src", 11, entry.getAugmentation(PortMatchEntry.class)
\r
340 .getPort().getValue().intValue());
\r
341 entry = entries.get(1);
\r
342 checkEntryHeader(entry, UdpDst.class, false);
\r
343 Assert.assertEquals("Wrong udp dst", 12, entry.getAugmentation(PortMatchEntry.class)
\r
344 .getPort().getValue().intValue());
\r
348 * Test {@link MatchConvertorImpl#convert(Match, BigInteger)
\r
351 public void testSctpMatchConversion() {
\r
352 MatchBuilder builder = new MatchBuilder();
\r
353 SctpMatchBuilder sctpMatchBuilder = new SctpMatchBuilder();
\r
354 sctpMatchBuilder.setSctpSourcePort(new PortNumber(11));
\r
355 sctpMatchBuilder.setSctpDestinationPort(new PortNumber(12));
\r
356 builder.setLayer4Match(sctpMatchBuilder.build());
\r
357 Match match = builder.build();
\r
359 List<MatchEntries> entries = convertor.convert(match, new BigInteger("42"));
\r
360 Assert.assertEquals("Wrong entries size", 2, entries.size());
\r
361 MatchEntries entry = entries.get(0);
\r
362 checkEntryHeader(entry, SctpSrc.class, false);
\r
363 Assert.assertEquals("Wrong sctp src", 11, entry.getAugmentation(PortMatchEntry.class)
\r
364 .getPort().getValue().intValue());
\r
365 entry = entries.get(1);
\r
366 checkEntryHeader(entry, SctpDst.class, false);
\r
367 Assert.assertEquals("Wrong sctp dst", 12, entry.getAugmentation(PortMatchEntry.class)
\r
368 .getPort().getValue().intValue());
\r
372 * Test {@link MatchConvertorImpl#convert(Match, BigInteger)
\r
375 public void testArpMatchConversion() {
\r
376 MatchBuilder builder = new MatchBuilder();
\r
377 ArpMatchBuilder arpBuilder = new ArpMatchBuilder();
\r
378 arpBuilder.setArpOp(5);
\r
379 arpBuilder.setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.3/32"));
\r
380 arpBuilder.setArpTargetTransportAddress(new Ipv4Prefix("10.0.0.4/32"));
\r
381 ArpSourceHardwareAddressBuilder srcHwBuilder = new ArpSourceHardwareAddressBuilder();
\r
382 srcHwBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
\r
383 arpBuilder.setArpSourceHardwareAddress(srcHwBuilder.build());
\r
384 ArpTargetHardwareAddressBuilder dstHwBuilder = new ArpTargetHardwareAddressBuilder();
\r
385 dstHwBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
\r
386 arpBuilder.setArpTargetHardwareAddress(dstHwBuilder.build());
\r
387 builder.setLayer3Match(arpBuilder.build());
\r
388 Match match = builder.build();
\r
390 List<MatchEntries> entries = convertor.convert(match, new BigInteger("42"));
\r
391 Assert.assertEquals("Wrong entries size", 5, entries.size());
\r
392 MatchEntries entry = entries.get(0);
\r
393 checkEntryHeader(entry, ArpOp.class, false);
\r
394 Assert.assertEquals("Wrong arp op", 5, entry.getAugmentation(OpCodeMatchEntry.class)
\r
395 .getOpCode().intValue());
\r
396 entry = entries.get(1);
\r
397 checkEntryHeader(entry, ArpSpa.class, false);
\r
398 Assert.assertEquals("Wrong arp spa", "10.0.0.3", entry.getAugmentation(Ipv4AddressMatchEntry.class)
\r
399 .getIpv4Address().getValue());
\r
400 entry = entries.get(2);
\r
401 checkEntryHeader(entry, ArpTpa.class, false);
\r
402 Assert.assertEquals("Wrong arp tpa", "10.0.0.4", entry.getAugmentation(Ipv4AddressMatchEntry.class)
\r
403 .getIpv4Address().getValue());
\r
404 entry = entries.get(3);
\r
405 checkEntryHeader(entry, ArpSha.class, false);
\r
406 Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:05", entry.getAugmentation(MacAddressMatchEntry.class)
\r
407 .getMacAddress().getValue());
\r
408 entry = entries.get(4);
\r
409 checkEntryHeader(entry, ArpTha.class, false);
\r
410 Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:06", entry.getAugmentation(MacAddressMatchEntry.class)
\r
411 .getMacAddress().getValue());
\r
415 * Test {@link MatchConvertorImpl#convert(Match, BigInteger)
\r
418 public void testArpMatchConversionWithMasks() {
\r
419 MatchBuilder builder = new MatchBuilder();
\r
420 ArpMatchBuilder arpBuilder = new ArpMatchBuilder();
\r
421 arpBuilder.setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.3/8"));
\r
422 arpBuilder.setArpTargetTransportAddress(new Ipv4Prefix("10.0.0.4/31"));
\r
423 ArpSourceHardwareAddressBuilder srcHwBuilder = new ArpSourceHardwareAddressBuilder();
\r
424 srcHwBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
\r
425 srcHwBuilder.setMask(new MacAddress("00:00:00:00:00:08"));
\r
426 arpBuilder.setArpSourceHardwareAddress(srcHwBuilder.build());
\r
427 ArpTargetHardwareAddressBuilder dstHwBuilder = new ArpTargetHardwareAddressBuilder();
\r
428 dstHwBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
\r
429 dstHwBuilder.setMask(new MacAddress("00:00:00:00:00:09"));
\r
430 arpBuilder.setArpTargetHardwareAddress(dstHwBuilder.build());
\r
431 builder.setLayer3Match(arpBuilder.build());
\r
432 Match match = builder.build();
\r
434 List<MatchEntries> entries = convertor.convert(match, new BigInteger("42"));
\r
435 Assert.assertEquals("Wrong entries size", 4, entries.size());
\r
436 MatchEntries entry = entries.get(0);
\r
437 entry = entries.get(0);
\r
438 checkEntryHeader(entry, ArpSpa.class, true);
\r
439 Assert.assertEquals("Wrong arp spa", "10.0.0.3", entry.getAugmentation(Ipv4AddressMatchEntry.class)
\r
440 .getIpv4Address().getValue());
\r
441 Assert.assertArrayEquals("Wrong arp spa mask", new byte[]{(byte) 255, 0, 0, 0},
\r
442 entry.getAugmentation(MaskMatchEntry.class).getMask());
\r
443 entry = entries.get(1);
\r
444 checkEntryHeader(entry, ArpTpa.class, true);
\r
445 Assert.assertEquals("Wrong arp tpa", "10.0.0.4", entry.getAugmentation(Ipv4AddressMatchEntry.class)
\r
446 .getIpv4Address().getValue());
\r
447 Assert.assertArrayEquals("Wrong arp tpa mask", new byte[]{(byte) 255, (byte) 255, (byte) 255, (byte) 254},
\r
448 entry.getAugmentation(MaskMatchEntry.class).getMask());
\r
449 entry = entries.get(2);
\r
450 checkEntryHeader(entry, ArpSha.class, true);
\r
451 Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:05", entry.getAugmentation(MacAddressMatchEntry.class)
\r
452 .getMacAddress().getValue());
\r
453 Assert.assertArrayEquals("Wrong arp sha mask", new byte[]{0, 0, 0, 0, 0, 8},
\r
454 entry.getAugmentation(MaskMatchEntry.class).getMask());
\r
455 entry = entries.get(3);
\r
456 checkEntryHeader(entry, ArpTha.class, true);
\r
457 Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:06", entry.getAugmentation(MacAddressMatchEntry.class)
\r
458 .getMacAddress().getValue());
\r
459 Assert.assertArrayEquals("Wrong arp tha mask", new byte[]{0, 0, 0, 0, 0, 9},
\r
460 entry.getAugmentation(MaskMatchEntry.class).getMask());
\r
464 * Test {@link MatchConvertorImpl#convert(Match, BigInteger)
\r
467 public void testIpv6MatchConversion() {
\r
468 MatchBuilder builder = new MatchBuilder();
\r
469 Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
\r
470 ipv6Builder.setIpv6Source(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0001"));
\r
471 ipv6Builder.setIpv6Destination(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0002"));
\r
472 Ipv6LabelBuilder ipv6LabelBuilder = new Ipv6LabelBuilder();
\r
473 ipv6LabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(3L));
\r
474 ipv6Builder.setIpv6Label(ipv6LabelBuilder.build());
\r
475 ipv6Builder.setIpv6NdTarget(new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0004"));
\r
476 ipv6Builder.setIpv6NdSll(new MacAddress("00:00:00:00:00:05"));
\r
477 ipv6Builder.setIpv6NdTll(new MacAddress("00:00:00:00:00:06"));
\r
478 Ipv6ExtHeaderBuilder extHdrBuilder = new Ipv6ExtHeaderBuilder();
\r
479 extHdrBuilder.setIpv6Exthdr(153);
\r
480 ipv6Builder.setIpv6ExtHeader(extHdrBuilder.build());
\r
481 builder.setLayer3Match(ipv6Builder.build());
\r
482 Match match = builder.build();
\r
484 List<MatchEntries> entries = convertor.convert(match, new BigInteger("42"));
\r
485 Assert.assertEquals("Wrong entries size", 7, entries.size());
\r
486 MatchEntries entry = entries.get(0);
\r
487 checkEntryHeader(entry, Ipv6Src.class, false);
\r
488 Assert.assertEquals("Wrong ipv6 src", "0000:0000:0000:0000:0000:0000:0000:0001",
\r
489 entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue());
\r
490 entry = entries.get(1);
\r
491 checkEntryHeader(entry, Ipv6Dst.class, false);
\r
492 Assert.assertEquals("Wrong ipv6 dst", "0000:0000:0000:0000:0000:0000:0000:0002",
\r
493 entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue());
\r
494 entry = entries.get(2);
\r
495 checkEntryHeader(entry, Ipv6Flabel.class, false);
\r
496 Assert.assertEquals("Wrong ipv6 flabel", 3,
\r
497 entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue());
\r
498 entry = entries.get(3);
\r
499 checkEntryHeader(entry, Ipv6NdTarget.class, false);
\r
500 Assert.assertEquals("Wrong ipv6 nd target", "0000:0000:0000:0000:0000:0000:0000:0004",
\r
501 entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue());
\r
502 entry = entries.get(4);
\r
503 checkEntryHeader(entry, Ipv6NdSll.class, false);
\r
504 Assert.assertEquals("Wrong ipv6 nd sll", "00:00:00:00:00:05",
\r
505 entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress().getValue());
\r
506 entry = entries.get(5);
\r
507 checkEntryHeader(entry, Ipv6NdTll.class, false);
\r
508 Assert.assertEquals("Wrong ipv6 nd tll", "00:00:00:00:00:06",
\r
509 entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress().getValue());
\r
510 entry = entries.get(6);
\r
511 checkEntryHeader(entry, Ipv6Exthdr.class, false);
\r
512 Assert.assertEquals("Wrong ipv6 ext hdr", new Ipv6ExthdrFlags(false, true, false, true, false,
\r
513 true, false, true, false), entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField());
\r
517 * Test {@link MatchConvertorImpl#convert(Match, BigInteger)
\r
520 public void testIpv6MatchConversionWithMasks() {
\r
521 MatchBuilder builder = new MatchBuilder();
\r
522 Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
\r
523 ipv6Builder.setIpv6Source(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0001/24"));
\r
524 ipv6Builder.setIpv6Destination(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0002/64"));
\r
525 builder.setLayer3Match(ipv6Builder.build());
\r
526 Match match = builder.build();
\r
528 List<MatchEntries> entries = convertor.convert(match, new BigInteger("42"));
\r
529 Assert.assertEquals("Wrong entries size", 2, entries.size());
\r
530 MatchEntries entry = entries.get(0);
\r
531 checkEntryHeader(entry, Ipv6Src.class, true);
\r
532 Assert.assertEquals("Wrong ipv6 src", "0000:0000:0000:0000:0000:0000:0000:0001",
\r
533 entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue());
\r
534 Assert.assertArrayEquals("Wrong ipv6 src mask", new byte[]{(byte) 255, (byte) 255, (byte) 255, 0, 0, 0, 0,
\r
535 0, 0, 0, 0, 0, 0, 0, 0, 0}, entry.getAugmentation(MaskMatchEntry.class).getMask());
\r
536 entry = entries.get(1);
\r
537 checkEntryHeader(entry, Ipv6Dst.class, true);
\r
538 Assert.assertEquals("Wrong ipv6 dst", "0000:0000:0000:0000:0000:0000:0000:0002",
\r
539 entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue());
\r
540 Assert.assertArrayEquals("Wrong ipv6 src mask", new byte[]{(byte) 255, (byte) 255, (byte) 255, (byte) 255,
\r
541 (byte) 255, (byte) 255, (byte) 255, (byte) 255, 0, 0, 0, 0, 0, 0, 0, 0},
\r
542 entry.getAugmentation(MaskMatchEntry.class).getMask());
\r
546 * Test {@link MatchConvertorImpl#convert(Match, BigInteger)
\r
549 public void testIpv6ExtHeaderConversion() {
\r
550 MatchBuilder builder = new MatchBuilder();
\r
551 Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
\r
552 Ipv6ExtHeaderBuilder extHdrBuilder = new Ipv6ExtHeaderBuilder();
\r
553 extHdrBuilder.setIpv6Exthdr(358);
\r
554 extHdrBuilder.setIpv6ExthdrMask(258);
\r
555 ipv6Builder.setIpv6ExtHeader(extHdrBuilder.build());
\r
556 builder.setLayer3Match(ipv6Builder.build());
\r
557 Match match = builder.build();
\r
559 List<MatchEntries> entries = convertor.convert(match, new BigInteger("42"));
\r
560 Assert.assertEquals("Wrong entries size", 1, entries.size());
\r
561 MatchEntries entry = entries.get(0);
\r
562 checkEntryHeader(entry, Ipv6Exthdr.class, true);
\r
563 Assert.assertEquals("Wrong ipv6 ext hdr", new Ipv6ExthdrFlags(true, false, true, false, true, false,
\r
564 true, false, true), entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField());
\r
565 Assert.assertArrayEquals("Wrong ipv6 ext hdr mask", new byte[]{1, 2}, entry.getAugmentation(MaskMatchEntry.class)
\r
570 * Test {@link MatchConvertorImpl#convert(Match, BigInteger)
\r
573 public void testConversionWithMasks() {
\r
574 MatchBuilder builder = new MatchBuilder();
\r
575 MetadataBuilder metadataBuilder = new MetadataBuilder();
\r
576 metadataBuilder.setMetadata(new BigInteger("3"));
\r
577 metadataBuilder.setMetadataMask(new BigInteger("15"));
\r
578 builder.setMetadata(metadataBuilder.build());
\r
579 EthernetMatchBuilder ethernetBuilder = new EthernetMatchBuilder();
\r
580 EthernetSourceBuilder ethSrcBuilder = new EthernetSourceBuilder();
\r
581 ethSrcBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
\r
582 ethSrcBuilder.setMask(new MacAddress("00:00:00:00:00:08"));
\r
583 ethernetBuilder.setEthernetSource(ethSrcBuilder.build());
\r
584 EthernetDestinationBuilder ethDstBuilder = new EthernetDestinationBuilder();
\r
585 ethDstBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
\r
586 ethDstBuilder.setMask(new MacAddress("00:00:00:00:00:09"));
\r
587 ethernetBuilder.setEthernetDestination(ethDstBuilder.build());
\r
588 builder.setEthernetMatch(ethernetBuilder.build());
\r
589 VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
\r
590 VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
\r
591 vlanIdBuilder.setVlanId(new VlanId(0));
\r
592 vlanIdBuilder.setVlanIdPresent(true);
\r
593 vlanBuilder.setVlanId(vlanIdBuilder.build());
\r
594 builder.setVlanMatch(vlanBuilder.build());
\r
595 ProtocolMatchFieldsBuilder protoBuilder = new ProtocolMatchFieldsBuilder();
\r
596 PbbBuilder pbbBuilder = new PbbBuilder();
\r
597 pbbBuilder.setPbbIsid(20L);
\r
598 pbbBuilder.setPbbMask(8L);
\r
599 protoBuilder.setPbb(pbbBuilder.build());
\r
600 builder.setProtocolMatchFields(protoBuilder.build());
\r
601 TunnelBuilder tunnelBuilder = new TunnelBuilder();
\r
602 tunnelBuilder.setTunnelId(new BigInteger("21"));
\r
603 tunnelBuilder.setTunnelMask(new BigInteger("14"));
\r
604 builder.setTunnel(tunnelBuilder.build());
\r
605 Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
\r
606 ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("10.0.0.1/24"));
\r
607 ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("10.0.0.2/8"));
\r
608 builder.setLayer3Match(ipv4MatchBuilder.build());
\r
609 Match match = builder.build();
\r
611 List<MatchEntries> entries = convertor.convert(match, new BigInteger("42"));
\r
612 Assert.assertEquals("Wrong entries size", 8, entries.size());
\r
613 MatchEntries entry = entries.get(0);
\r
614 checkEntryHeader(entry, Metadata.class, true);
\r
615 Assert.assertArrayEquals("Wrong metadata", new byte[]{0, 0, 0, 0, 0, 0, 0, 3},
\r
616 entry.getAugmentation(MetadataMatchEntry.class).getMetadata());
\r
617 Assert.assertArrayEquals("Wrong metadata mask", new byte[]{0, 0, 0, 0, 0, 0, 0, 15},
\r
618 entry.getAugmentation(MaskMatchEntry.class).getMask());
\r
619 entry = entries.get(1);
\r
620 checkEntryHeader(entry, EthDst.class, true);
\r
621 Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:06"),
\r
622 entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress());
\r
623 Assert.assertArrayEquals("Wrong eth dst mask", new byte[]{0, 0, 0, 0, 0, 9},
\r
624 entry.getAugmentation(MaskMatchEntry.class).getMask());
\r
625 entry = entries.get(2);
\r
626 checkEntryHeader(entry, EthSrc.class, true);
\r
627 Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:05"),
\r
628 entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress());
\r
629 Assert.assertArrayEquals("Wrong eth src mask", new byte[]{0, 0, 0, 0, 0, 8},
\r
630 entry.getAugmentation(MaskMatchEntry.class).getMask());
\r
631 entry = entries.get(3);
\r
632 checkEntryHeader(entry, VlanVid.class, true);
\r
633 Assert.assertEquals("Wrong vlan id", 0, entry.getAugmentation(VlanVidMatchEntry.class)
\r
634 .getVlanVid().intValue());
\r
635 Assert.assertEquals("Wrong cfi bit", true, entry.getAugmentation(VlanVidMatchEntry.class)
\r
637 Assert.assertArrayEquals("Wrong vlanId mask", new byte[]{16, 0},
\r
638 entry.getAugmentation(MaskMatchEntry.class).getMask());
\r
639 entry = entries.get(4);
\r
640 checkEntryHeader(entry, Ipv4Src.class, true);
\r
641 Assert.assertEquals("Wrong ipv4 src", "10.0.0.1", entry.getAugmentation(Ipv4AddressMatchEntry.class)
\r
642 .getIpv4Address().getValue());
\r
643 Assert.assertArrayEquals("Wrong ipv4 src mask", new byte[]{(byte) 255, (byte) 255, (byte) 255, 0},
\r
644 entry.getAugmentation(MaskMatchEntry.class).getMask());
\r
645 entry = entries.get(5);
\r
646 checkEntryHeader(entry, Ipv4Dst.class, true);
\r
647 Assert.assertEquals("Wrong ipv4 dst", "10.0.0.2", entry.getAugmentation(Ipv4AddressMatchEntry.class)
\r
648 .getIpv4Address().getValue());
\r
649 Assert.assertArrayEquals("Wrong ipv4 dst mask", new byte[]{(byte) 255, 0, 0, 0},
\r
650 entry.getAugmentation(MaskMatchEntry.class).getMask());
\r
651 entry = entries.get(6);
\r
652 checkEntryHeader(entry, PbbIsid.class, true);
\r
653 Assert.assertEquals("Wrong pbb isid", 20, entry.getAugmentation(IsidMatchEntry.class)
\r
654 .getIsid().intValue());
\r
655 Assert.assertArrayEquals("Wrong pbb isid mask", new byte[]{0, 0, 8},
\r
656 entry.getAugmentation(MaskMatchEntry.class).getMask());
\r
657 entry = entries.get(7);
\r
658 checkEntryHeader(entry, TunnelId.class, true);
\r
659 Assert.assertArrayEquals("Wrong tunnel id", new byte[]{0, 0, 0, 0, 0, 0, 0, 21},
\r
660 entry.getAugmentation(MetadataMatchEntry.class).getMetadata());
\r
661 Assert.assertArrayEquals("Wrong tunnel id mask", new byte[]{0, 0, 0, 0, 0, 0, 0, 14},
\r
662 entry.getAugmentation(MaskMatchEntry.class).getMask());
\r