45341fb734f26f7b1586d6984326f71e1a380a83
[controller.git] / opendaylight / md-sal / compatibility / sal-compatibility / src / test / java / org / opendaylight / controller / sal / compatibility / test / TestToSalConversionsUtils.java
1 /*
2  * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.sal.compatibility.test;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
12 import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.CRUDP;
13 import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.ETHERNET_ARP;
14 import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.TCP;
15 import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.UDP;
16
17 import java.math.BigInteger;
18 import java.net.Inet4Address;
19 import java.net.Inet6Address;
20 import java.net.InetAddress;
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.List;
24
25 import junit.framework.Assert;
26
27 import org.junit.Test;
28 import org.opendaylight.controller.sal.action.Flood;
29 import org.opendaylight.controller.sal.action.FloodAll;
30 import org.opendaylight.controller.sal.action.HwPath;
31 import org.opendaylight.controller.sal.action.Loopback;
32 import org.opendaylight.controller.sal.action.Output;
33 import org.opendaylight.controller.sal.action.PopVlan;
34 import org.opendaylight.controller.sal.action.PushVlan;
35 import org.opendaylight.controller.sal.action.SetDlDst;
36 import org.opendaylight.controller.sal.action.SetDlSrc;
37 import org.opendaylight.controller.sal.action.SetDlType;
38 import org.opendaylight.controller.sal.action.SetNextHop;
39 import org.opendaylight.controller.sal.action.SetNwDst;
40 import org.opendaylight.controller.sal.action.SetNwSrc;
41 import org.opendaylight.controller.sal.action.SetNwTos;
42 import org.opendaylight.controller.sal.action.SetTpDst;
43 import org.opendaylight.controller.sal.action.SetTpSrc;
44 import org.opendaylight.controller.sal.action.SetVlanCfi;
45 import org.opendaylight.controller.sal.action.SetVlanId;
46 import org.opendaylight.controller.sal.action.SetVlanPcp;
47 import org.opendaylight.controller.sal.action.SwPath;
48 import org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils;
49 import org.opendaylight.controller.sal.core.ConstructionException;
50 import org.opendaylight.controller.sal.core.Node;
51 import org.opendaylight.controller.sal.core.Node.NodeIDType;
52 import org.opendaylight.controller.sal.core.NodeConnector;
53 import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
54 import org.opendaylight.controller.sal.flowprogrammer.Flow;
55 import org.opendaylight.controller.sal.match.MatchType;
56 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
57 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
58 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
59 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
60 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
61 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCaseBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCaseBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCaseBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCaseBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCaseBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.type.action._case.SetDlTypeActionBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.next.hop.action._case.SetNextHopActionBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.cfi.action._case.SetVlanCfiActionBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetType;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
149
150 import com.google.common.net.InetAddresses;
151
152 public class TestToSalConversionsUtils {
153     // prefix:
154     // od|Od = Open Daylight
155     private enum MtchType {
156         other, untagged, ipv4, ipv6, arp, sctp, tcp, udp
157     }
158
159     @Test
160     public void testToSalConversion() throws ConstructionException {
161         FlowAddedBuilder odNodeFlowBuilder = new FlowAddedBuilder();
162         odNodeFlowBuilder = prepareOdFlowCommon();
163
164         Node node = new Node(NodeIDType.OPENFLOW,(long)1);
165
166         Flow salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.other), node);
167         checkSalMatch(salFlow.getMatch(), MtchType.other);
168
169         salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.untagged), node);
170         checkSalMatch(salFlow.getMatch(), MtchType.untagged);
171
172         salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.ipv4), node);
173         checkSalMatch(salFlow.getMatch(), MtchType.ipv4);
174
175         salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.ipv6), node);
176         checkSalMatch(salFlow.getMatch(), MtchType.ipv6);
177
178         salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.arp), node);
179         checkSalMatch(salFlow.getMatch(), MtchType.arp);
180
181         salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.sctp), node);
182         checkSalMatch(salFlow.getMatch(), MtchType.sctp);
183
184         salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.tcp), node);
185         checkSalMatch(salFlow.getMatch(), MtchType.tcp);
186
187         salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.udp), node);
188         checkSalMatch(salFlow.getMatch(), MtchType.udp);
189
190         checkSalFlow(salFlow);
191     }
192
193     /**
194      * test of {@link ToSalConversionsUtils#fromNodeConnectorRef(Uri, Node)}
195      * @throws ConstructionException
196      */
197     @Test
198     public void testFromNodeConnectorRef() throws ConstructionException {
199         Node node = new Node(NodeIDType.OPENFLOW, 42L);
200         NodeConnector nodeConnector = ToSalConversionsUtils.fromNodeConnectorRef(new Uri("1"), node);
201         Assert.assertEquals("OF|1@OF|00:00:00:00:00:00:00:2a", nodeConnector.toString());
202     }
203
204     private void checkSalMatch(org.opendaylight.controller.sal.match.Match match, MtchType mt) throws ConstructionException {
205         switch (mt) {
206         case other:
207             /*assertNotNull("DL_DST isn't equal.", "3C:A9:F4:00:E0:C8",
208                     new String((byte[]) match.getField(MatchType.DL_DST).getValue()));
209             assertEquals("DL_SRC isn't equal.", "24:77:03:7C:C5:F1",
210                     new String((byte[]) match.getField(MatchType.DL_SRC).getValue()));
211             */
212             Node node = new Node(NodeIDType.OPENFLOW, 12L);
213             NodeConnector port = new NodeConnector(NodeConnectorIDType.OPENFLOW, Short.valueOf((short)345), node);
214             assertEquals("IN_PORT isn't equal.", port, match.getField(MatchType.IN_PORT).getValue());
215             assertEquals("DL_TYPE isn't equal.", (short) 0xffff, (short) match.getField(MatchType.DL_TYPE).getValue());
216             assertEquals("NW_TOS isn't equal.", (byte) 0x33, (byte) match.getField(MatchType.NW_TOS).getValue());
217             assertEquals("NW_PROTO isn't equal.", (byte) 0x3f, (byte) match.getField(MatchType.NW_PROTO).getValue());
218             assertEquals("DL_VLAN isn't equal.", (short) 0xfff, (short) match.getField(MatchType.DL_VLAN).getValue());
219             assertEquals("DL_VLAN_PR isn't equal.", (byte) 0x7, (byte) match.getField(MatchType.DL_VLAN_PR).getValue());
220             break;
221         case untagged:
222             assertEquals("DL_TYPE isn't equal.", (short) 0xffff, (short) match.getField(MatchType.DL_TYPE).getValue());
223             assertEquals("NW_TOS isn't equal.", (byte) 0x33, (byte) match.getField(MatchType.NW_TOS).getValue());
224             assertEquals("NW_PROTO isn't equal.", (byte) 0x3f, (byte) match.getField(MatchType.NW_PROTO).getValue());
225             assertEquals("DL_VLAN isn't equal.", MatchType.DL_VLAN_NONE, (short) match.getField(MatchType.DL_VLAN).getValue());
226             break;
227         case arp:
228             /*
229             assertEquals("DL_SRC isn't equal.", "22:44:66:88:AA:CC",
230                     new String((byte[]) match.getField(MatchType.DL_SRC).getValue()));
231             assertEquals("DL_DST isn't equal.", "11:33:55:77:BB:DD",
232                     new String((byte[]) match.getField(MatchType.DL_DST).getValue()));
233             */
234             assertEquals("NW_SRC isn't equal.", "192.168.1.101",
235                     InetAddresses.toAddrString((InetAddress) match.getField(MatchType.NW_SRC).getValue()));
236             assertEquals("NW_DST isn't equal.", "192.168.1.102",
237                     InetAddresses.toAddrString((InetAddress) match.getField(MatchType.NW_DST).getValue()));
238             assertEquals("DL_TYPE isn't equal.", ETHERNET_ARP, match.getField(MatchType.DL_TYPE).getValue());
239             break;
240         case ipv4:
241             assertEquals("NW_SRC isn't equal.", "192.168.1.104",
242                     InetAddresses.toAddrString((InetAddress) match.getField(MatchType.NW_SRC).getValue()));
243             assertEquals("NW_DST isn't equal.", "192.168.1.105",
244                     InetAddresses.toAddrString((InetAddress) match.getField(MatchType.NW_DST).getValue()));
245             break;
246         case ipv6:
247             assertEquals("NW_SRC isn't equal.", "3001:db8:85a3::8a2e:370:7334",
248                     InetAddresses.toAddrString((InetAddress) match.getField(MatchType.NW_SRC).getValue()));
249             assertEquals("NW_DST isn't equal.", "3001:db8:85a3::8a2e:370:7335",
250                     InetAddresses.toAddrString((InetAddress) match.getField(MatchType.NW_DST).getValue()));
251             break;
252         case sctp:
253             assertEquals("TP_SRC isn't equal.", 31, (short) match.getField(MatchType.TP_SRC).getValue());
254             assertEquals("TP_DST isn't equal.", 32, (short) match.getField(MatchType.TP_DST).getValue());
255             assertEquals("NW_PROTO isn't equal.", CRUDP, (byte) match.getField(MatchType.NW_PROTO).getValue());
256             break;
257         case tcp:
258             assertEquals("TP_SRC isn't equal.", 21, (short) match.getField(MatchType.TP_SRC).getValue());
259             assertEquals("TP_DST isn't equal.", 22, (short) match.getField(MatchType.TP_DST).getValue());
260             assertEquals("NW_PROTO isn't equal.", TCP, (byte) match.getField(MatchType.NW_PROTO).getValue());
261             break;
262         case udp:
263             assertEquals("TP_SRC isn't equal.", 11, (short) match.getField(MatchType.TP_SRC).getValue());
264             assertEquals("TP_DST isn't equal.", 12, (short) match.getField(MatchType.TP_DST).getValue());
265             assertEquals("NW_PROTO isn't equal.", UDP, (byte) match.getField(MatchType.NW_PROTO).getValue());
266             break;
267         default:
268             break;
269
270         }
271
272     }
273
274     private void checkSalFlow(Flow salFlow) {
275         assertTrue("Id value is incorrect.", salFlow.getId() == 9223372036854775807L);
276         assertTrue("Hard timeout is incorrect.", salFlow.getHardTimeout() == 32767);
277         assertTrue("Iddle timeout is incorrect.", salFlow.getIdleTimeout() == 32767);
278         assertTrue("Priority value is incorrect.", salFlow.getPriority() == 32767);
279
280         checkSalActions(salFlow.getActions());
281     }
282
283     private void checkSalActions(List<org.opendaylight.controller.sal.action.Action> actions) {
284         checkSalAction(actions, Flood.class, 1);
285         checkSalAction(actions, FloodAll.class, 1);
286         checkSalAction(actions, HwPath.class, 1);
287         checkSalAction(actions, Loopback.class, 1);
288         checkSalAction(actions, Output.class, 1, true);
289         checkSalAction(actions, PopVlan.class, 1);
290         checkSalAction(actions, PushVlan.class, 1, true);
291         checkSalAction(actions, SetDlDst.class, 1, true);
292         checkSalAction(actions, SetDlSrc.class, 1, true);
293         checkSalAction(actions, SetDlType.class, 1, true);
294         checkSalAction(actions, SetNextHop.class, 2, true);
295         checkSalAction(actions, SetNwDst.class, 2, true);
296         checkSalAction(actions, SetNwSrc.class, 2, true);
297         checkSalAction(actions, SetNwTos.class, 1, true);
298         checkSalAction(actions, SetTpDst.class, 1, true);
299         checkSalAction(actions, SetTpSrc.class, 1, true);
300         checkSalAction(actions, SetVlanCfi.class, 1, true);
301         checkSalAction(actions, SetVlanId.class, 1, true);
302         checkSalAction(actions, SetVlanPcp.class, 1, true);
303         checkSalAction(actions, SwPath.class, 1);
304     }
305
306     private void checkSalAction(List<org.opendaylight.controller.sal.action.Action> actions, Class<?> cls,
307             int numOfActions) {
308         checkSalAction(actions, cls, numOfActions, false);
309     }
310
311     private void checkSalAction(List<org.opendaylight.controller.sal.action.Action> actions, Class<?> cls,
312             int numOfActions, boolean additionalCheck) {
313         int numOfEqualClass = 0;
314         for (org.opendaylight.controller.sal.action.Action action : actions) {
315             if (action.getClass().equals(cls)) {
316                 if (additionalCheck) {
317                     additionalActionCheck(action);
318                 }
319                 numOfEqualClass++;
320             }
321         }
322         assertEquals("Incorrect number of actions of type " + cls.getName() + " was found.", numOfActions,
323                 numOfEqualClass);
324     }
325
326     // implement special checks
327     private void additionalActionCheck(org.opendaylight.controller.sal.action.Action action) {
328         if (action instanceof Output) {
329             // ((Output)action).getPort() //TODO finish check when mapping will
330             // be defined
331         } else if (action instanceof PushVlan) {
332             assertEquals("Wrong value for action PushVlan for tag.", 0x8100, ((PushVlan) action).getTag());
333         } else if (action instanceof SetDlDst) {
334             //assertEquals("Wrong value for action SetDlDst for MAC address.", "3C:A9:F4:00:E0:C8", new String(
335             //        ((SetDlDst) action).getDlAddress()));
336         } else if (action instanceof SetDlSrc) {
337             //assertEquals("Wrong value for action SetDlSrc for MAC address.", "24:77:03:7C:C5:F1", new String(
338             //      ((SetDlSrc) action).getDlAddress()));
339         } else if (action instanceof SetDlType) {
340             assertEquals("Wrong value for action SetDlType for.", 513L, ((SetDlType) action).getDlType());
341         } else if (action instanceof SetNextHop) {
342             InetAddress inetAddress = ((SetNextHop) action).getAddress();
343             checkIpAddresses(inetAddress, "192.168.100.100", "2001:db8:85a3::8a2e:370:7334");
344         } else if (action instanceof SetNwDst) {
345             InetAddress inetAddress = ((SetNwDst) action).getAddress();
346             checkIpAddresses(inetAddress, "192.168.100.101", "2001:db8:85a3::8a2e:370:7335");
347         } else if (action instanceof SetNwSrc) {
348             InetAddress inetAddress = ((SetNwSrc) action).getAddress();
349             checkIpAddresses(inetAddress, "192.168.100.102", "2001:db8:85a3::8a2e:370:7336");
350         } else if (action instanceof SetNwTos) {
351             assertEquals("Wrong value for action SetNwTos for tos.", 63, ((SetNwTos) action).getNwTos());
352         } else if (action instanceof SetTpDst) {
353             assertEquals("Wrong value for action SetTpDst for port.", 65535, ((SetTpDst) action).getPort());
354         } else if (action instanceof SetTpSrc) {
355             assertEquals("Wrong value for action SetTpSrc for port.", 65535, ((SetTpSrc) action).getPort());
356         } else if (action instanceof SetVlanCfi) {
357             assertEquals("Wrong value for action SetVlanCfi for port.", 1, ((SetVlanCfi) action).getCfi());
358         } else if (action instanceof SetVlanId) {
359             assertEquals("Wrong value for action SetVlanId for vlan ID.", 4095, ((SetVlanId) action).getVlanId());
360         } else if (action instanceof SetVlanPcp) {
361             assertEquals("Wrong value for action SetVlanPcp for vlan ID.", 7, ((SetVlanPcp) action).getPcp());
362         }
363     }
364
365     private void checkIpAddresses(InetAddress inetAddress, String ipv4, String ipv6) {
366         if (inetAddress instanceof Inet4Address) {
367             assertEquals("Wrong value for IP address.", ipv4, InetAddresses.toAddrString(inetAddress));
368         } else if (inetAddress instanceof Inet6Address) {
369             assertEquals("Wrong value for IP address.", ipv6, InetAddresses.toAddrString(inetAddress));
370         }
371     }
372
373     private FlowAddedBuilder prepareOdFlowCommon() {
374         FlowAddedBuilder odNodeFlowBuilder = new FlowAddedBuilder();
375
376         odNodeFlowBuilder.setCookie(new FlowCookie(new BigInteger("9223372036854775807")));
377         odNodeFlowBuilder.setHardTimeout(32767);
378         odNodeFlowBuilder.setIdleTimeout(32767);
379         odNodeFlowBuilder.setPriority(32767);
380         odNodeFlowBuilder.setInstructions(prepareOdActions());
381         return odNodeFlowBuilder;
382     }
383
384     private NodeFlow prepareOdFlow(FlowAddedBuilder odNodeFlowBuilder, MtchType mt) {
385         odNodeFlowBuilder.setMatch(prepOdMatch(mt));
386         return odNodeFlowBuilder.build();
387     }
388
389     private Instructions prepareOdActions() {
390         List<Action> odActions = new ArrayList<>();
391
392         ControllerActionCaseBuilder controllerActionBuilder = new ControllerActionCaseBuilder();
393         DropActionCaseBuilder dropActionBuilder = new DropActionCaseBuilder();
394         FloodActionCaseBuilder floodActionBuilder = new FloodActionCaseBuilder();
395         FloodAllActionCaseBuilder floodAllActionBuilder = new FloodAllActionCaseBuilder();
396         HwPathActionCaseBuilder hwPathActionBuilder = new HwPathActionCaseBuilder();
397         LoopbackActionCaseBuilder loopbackActionBuilder = new LoopbackActionCaseBuilder();
398         OutputActionCaseBuilder outputActionBuilder = new OutputActionCaseBuilder();
399         PopMplsActionCaseBuilder popMplsActionBuilder = new PopMplsActionCaseBuilder();
400         PopVlanActionCaseBuilder popVlanActionBuilder = new PopVlanActionCaseBuilder();
401         PushMplsActionCaseBuilder pushMplsActionBuilder = new PushMplsActionCaseBuilder();
402         PushPbbActionCaseBuilder pushPbbActionBuilder = new PushPbbActionCaseBuilder();
403         PushVlanActionCaseBuilder pushVlanActionBuilder = new PushVlanActionCaseBuilder();
404         SetDlDstActionCaseBuilder setDlDstActionBuilder = new SetDlDstActionCaseBuilder();
405         SetDlSrcActionCaseBuilder setDlSrcActionBuilder = new SetDlSrcActionCaseBuilder();
406         SetDlTypeActionCaseBuilder setDlTypeActionBuilder = new SetDlTypeActionCaseBuilder();
407         SetMplsTtlActionCaseBuilder setMplsTtlActionBuilder = new SetMplsTtlActionCaseBuilder();
408         SetNwTosActionCaseBuilder setNwTosActionBuilder = new SetNwTosActionCaseBuilder();
409         SetNwTtlActionCaseBuilder setNwTtlActionBuilder = new SetNwTtlActionCaseBuilder();
410         SetQueueActionCaseBuilder setQueueActionBuilder = new SetQueueActionCaseBuilder();
411         SetTpDstActionCaseBuilder setTpDstActionBuilder = new SetTpDstActionCaseBuilder();
412         SetTpSrcActionCaseBuilder setTpSrcActionBuilder = new SetTpSrcActionCaseBuilder();
413         SetVlanCfiActionCaseBuilder setVlanCfiActionBuilder = new SetVlanCfiActionCaseBuilder();
414         SetVlanIdActionCaseBuilder setVlanIdActionBuilder = new SetVlanIdActionCaseBuilder();
415         SetVlanPcpActionCaseBuilder setVlanPcpActionBuilder = new SetVlanPcpActionCaseBuilder();
416         SwPathActionCaseBuilder swPathActionBuilder = new SwPathActionCaseBuilder();
417
418         prepareActionOutput(outputActionBuilder);
419         prepareActionPushVlan(pushVlanActionBuilder);
420         prepareActionSetDlDst(setDlDstActionBuilder);
421         prepareActionSetDlSrc(setDlSrcActionBuilder);
422         prepareActionSetDlType(setDlTypeActionBuilder);
423         prepareActionNextHop(odActions);
424         prepareActionSetNwDst(odActions);
425         prepareActionSetNwSrc(odActions);
426         prepareActionSetNwTos(setNwTosActionBuilder);
427         prepareActionSetTpDst(setTpDstActionBuilder);
428         prepareActionSetTpSrc(setTpSrcActionBuilder);
429         prepareActionSetVlanCfi(setVlanCfiActionBuilder);
430         prepareActionSetVladId(setVlanIdActionBuilder);
431         prepareActionSetVlanPcp(setVlanPcpActionBuilder);
432
433         odActions.add(new ActionBuilder().setAction(controllerActionBuilder.build()).build());
434         odActions.add(new ActionBuilder().setAction(dropActionBuilder.build()).build());
435         odActions.add(new ActionBuilder().setAction(floodActionBuilder.build()).build());
436         odActions.add(new ActionBuilder().setAction(floodAllActionBuilder.build()).build());
437         odActions.add(new ActionBuilder().setAction(hwPathActionBuilder.build()).build());
438         odActions.add(new ActionBuilder().setAction(loopbackActionBuilder.build()).build());
439         odActions.add(new ActionBuilder().setAction(outputActionBuilder.build()).build());
440         odActions.add(new ActionBuilder().setAction(popMplsActionBuilder.build()).build());
441         odActions.add(new ActionBuilder().setAction(popVlanActionBuilder.build()).build());
442         odActions.add(new ActionBuilder().setAction(pushMplsActionBuilder.build()).build());
443         odActions.add(new ActionBuilder().setAction(pushPbbActionBuilder.build()).build());
444         odActions.add(new ActionBuilder().setAction(pushVlanActionBuilder.build()).build());
445         odActions.add(new ActionBuilder().setAction(setDlDstActionBuilder.build()).build());
446         odActions.add(new ActionBuilder().setAction(setDlSrcActionBuilder.build()).build());
447         odActions.add(new ActionBuilder().setAction(setDlTypeActionBuilder.build()).build());
448         odActions.add(new ActionBuilder().setAction(setMplsTtlActionBuilder.build()).build());
449         odActions.add(new ActionBuilder().setAction(setNwTosActionBuilder.build()).build());
450         odActions.add(new ActionBuilder().setAction(setNwTtlActionBuilder.build()).build());
451         odActions.add(new ActionBuilder().setAction(setQueueActionBuilder.build()).build());
452         odActions.add(new ActionBuilder().setAction(setTpDstActionBuilder.build()).build());
453         odActions.add(new ActionBuilder().setAction(setTpSrcActionBuilder.build()).build());
454         odActions.add(new ActionBuilder().setAction(setVlanCfiActionBuilder.build()).build());
455         odActions.add(new ActionBuilder().setAction(setVlanIdActionBuilder.build()).build());
456         odActions.add(new ActionBuilder().setAction(setVlanPcpActionBuilder.build()).build());
457         odActions.add(new ActionBuilder().setAction(swPathActionBuilder.build()).build());
458
459
460         ApplyActionsCase innerInst = new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(odActions).build()).build();
461         Instruction applyActions = new InstructionBuilder().setInstruction(innerInst).build();
462         List<Instruction> instructions = Collections.singletonList(applyActions );
463         InstructionsBuilder instBuilder = new InstructionsBuilder();
464
465         instBuilder.setInstruction(instructions);
466
467         return instBuilder.build();
468     }
469
470     private void prepareActionSetVlanPcp(SetVlanPcpActionCaseBuilder wrapper) {
471         SetVlanPcpActionBuilder setVlanPcpActionBuilder = new SetVlanPcpActionBuilder();
472         setVlanPcpActionBuilder.setVlanPcp(new VlanPcp((short) 7));
473         wrapper.setSetVlanPcpAction(setVlanPcpActionBuilder.build());
474     }
475
476     private void prepareActionSetVladId(SetVlanIdActionCaseBuilder wrapper) {
477         SetVlanIdActionBuilder setVlanIdActionBuilder = new SetVlanIdActionBuilder();
478         setVlanIdActionBuilder.setVlanId(new VlanId(4095));
479         wrapper.setSetVlanIdAction(setVlanIdActionBuilder.build());
480     }
481
482     private void prepareActionSetVlanCfi(SetVlanCfiActionCaseBuilder wrapper) {
483         SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
484         setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(1));
485         wrapper.setSetVlanCfiAction(setVlanCfiActionBuilder.build());
486     }
487
488     private void prepareActionSetTpDst(SetTpDstActionCaseBuilder wrapper) {
489         SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
490         setTpDstActionBuilder.setPort(new PortNumber(65535));
491         wrapper.setSetTpDstAction(setTpDstActionBuilder.build());
492     }
493
494     private void prepareActionSetTpSrc(SetTpSrcActionCaseBuilder wrapper) {
495         SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
496         setTpSrcActionBuilder.setPort(new PortNumber(65535));
497         wrapper.setSetTpSrcAction(setTpSrcActionBuilder.build());
498     }
499
500     private void prepareActionSetNwTos(SetNwTosActionCaseBuilder wrapper) {
501         SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
502         setNwTosActionBuilder.setTos(252);
503         wrapper.setSetNwTosAction(setNwTosActionBuilder.build());
504     }
505
506     private void prepareActionSetNwSrc(List<Action> odActions) {
507         // test case for IPv4
508         SetNwSrcActionBuilder setNwSrcActionBuilderIpv4 = new SetNwSrcActionBuilder();
509         setNwSrcActionBuilderIpv4.setAddress(prapareIpv4Address("192.168.100.102"));
510         odActions.add(new ActionBuilder().setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwSrcActionBuilderIpv4.build()).build()).build());
511
512         // test case for IPv6
513         SetNwSrcActionBuilder setNwSrcActionBuilderIpv6 = new SetNwSrcActionBuilder();
514         setNwSrcActionBuilderIpv6.setAddress(prapareIpv6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7336"));
515         odActions.add(new ActionBuilder().setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwSrcActionBuilderIpv6.build()).build()).build());
516     }
517
518     private void prepareActionSetNwDst(List<Action> odActions) {
519         // test case for IPv4
520
521         SetNwDstActionBuilder setNwDstActionBuilderIpv4 = new SetNwDstActionBuilder();
522         setNwDstActionBuilderIpv4.setAddress(prapareIpv4Address("192.168.100.101"));
523         odActions.add(new ActionBuilder().setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilderIpv4.build()).build()).build());
524
525         // test case for IPv6
526         SetNwDstActionBuilder setNwDstActionBuilderIpv6 = new SetNwDstActionBuilder();
527         setNwDstActionBuilderIpv6.setAddress(prapareIpv6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7335"));
528         odActions.add(new ActionBuilder().setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilderIpv6.build()).build()).build());
529     }
530
531     private void prepareActionNextHop(List<Action> odActions) {
532         // test case for IPv4
533         SetNextHopActionBuilder setNextHopActionBuilderIpv4 = new SetNextHopActionBuilder();
534         setNextHopActionBuilderIpv4.setAddress(prapareIpv4Address("192.168.100.100"));
535         odActions.add(new ActionBuilder().setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilderIpv4.build()).build()).build());
536
537         // test case for IPv6
538         SetNextHopActionBuilder setNextHopActionBuilderIpv6 = new SetNextHopActionBuilder();
539         setNextHopActionBuilderIpv6.setAddress(prapareIpv6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7334"));
540         odActions.add(new ActionBuilder().setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilderIpv6.build()).build()).build());
541     }
542
543     private Address prapareIpv4Address(String ipv4Address) {
544         Ipv4Builder ipv4Builder = new Ipv4Builder();
545         ipv4Builder.setIpv4Address(new Ipv4Prefix(ipv4Address + "/32"));
546         return ipv4Builder.build();
547     }
548
549     private Address prapareIpv6Address(String ipv6Address) {
550         Ipv6Builder ipv6Builder = new Ipv6Builder();
551         ipv6Builder.setIpv6Address(new Ipv6Prefix(ipv6Address));
552         return ipv6Builder.build();
553     }
554
555     private void prepareActionSetDlType(SetDlTypeActionCaseBuilder wrapper) {
556         SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
557         setDlTypeActionBuilder.setDlType(new EtherType(513L));
558         wrapper.setSetDlTypeAction(setDlTypeActionBuilder.build());
559     }
560
561     private void prepareActionSetDlSrc(SetDlSrcActionCaseBuilder wrapper) {
562         SetDlSrcActionBuilder setDlSrcActionBuilder = new SetDlSrcActionBuilder();
563         setDlSrcActionBuilder.setAddress(new MacAddress("24:77:03:7C:C5:F1"));
564         wrapper.setSetDlSrcAction(setDlSrcActionBuilder.build());
565     }
566
567     private void prepareActionSetDlDst(SetDlDstActionCaseBuilder wrapper) {
568         SetDlDstActionBuilder setDlDstActionBuilder = new SetDlDstActionBuilder();
569         setDlDstActionBuilder.setAddress(new MacAddress("3C:A9:F4:00:E0:C8"));
570         wrapper.setSetDlDstAction(setDlDstActionBuilder.build());
571     }
572
573     private void prepareActionPushVlan(PushVlanActionCaseBuilder wrapper) {
574         PushVlanActionBuilder pushVlanActionBuilder = new PushVlanActionBuilder();
575         pushVlanActionBuilder.setTag(0x8100); // 12 bit
576         wrapper.setPushVlanAction(pushVlanActionBuilder.build());
577     }
578
579     private void prepareActionOutput(OutputActionCaseBuilder wrapper) {
580         OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
581         outputActionBuilder.setOutputNodeConnector(new Uri("1"));
582         wrapper.setOutputAction(outputActionBuilder.build());
583     }
584
585     private Match prepOdMatch(MtchType mt) {
586         MatchBuilder odMatchBuilder = new MatchBuilder();
587         switch (mt) {
588         case other:
589             odMatchBuilder.setInPort(new NodeConnectorId("openflow:12:345"));
590             odMatchBuilder.setEthernetMatch(prepEthernetMatch());
591             odMatchBuilder.setIpMatch(prepIpMatch());
592             odMatchBuilder.setVlanMatch(prepVlanMatch());
593             break;
594         case untagged:
595             odMatchBuilder.setEthernetMatch(prepEthernetMatch());
596             odMatchBuilder.setIpMatch(prepIpMatch());
597             odMatchBuilder.setVlanMatch(prepVlanNoneMatch());
598             break;
599         case ipv4:
600             odMatchBuilder.setLayer3Match(prepLayer3MatchIpv4());
601             break;
602         case ipv6:
603             odMatchBuilder.setLayer3Match(prepLayer3MatchIpv6());
604             break;
605         case arp:
606             odMatchBuilder.setLayer3Match(prepLayer3MatchArp());
607             break;
608         case sctp:
609             odMatchBuilder.setLayer4Match(prepLayer4MatchSctp());
610             break;
611         case tcp:
612             odMatchBuilder.setLayer4Match(prepLayer4MatchTcp());
613             break;
614         case udp:
615             odMatchBuilder.setLayer4Match(prepLayer4MatchUdp());
616             break;
617         }
618         return odMatchBuilder.build();
619     }
620
621     private Layer4Match prepLayer4MatchUdp() {
622         UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
623
624         udpMatchBuilder.setUdpSourcePort(new PortNumber(11));
625         udpMatchBuilder.setUdpDestinationPort(new PortNumber(12));
626
627         return udpMatchBuilder.build();
628     }
629
630     private Layer4Match prepLayer4MatchTcp() {
631         TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
632
633         tcpMatchBuilder.setTcpSourcePort(new PortNumber(21));
634         tcpMatchBuilder.setTcpDestinationPort(new PortNumber(22));
635
636         return tcpMatchBuilder.build();
637     }
638
639     private Layer4Match prepLayer4MatchSctp() {
640         SctpMatchBuilder sctpMatchBuilder = new SctpMatchBuilder();
641
642         sctpMatchBuilder.setSctpSourcePort(new PortNumber(31));
643         sctpMatchBuilder.setSctpDestinationPort(new PortNumber(32));
644
645         return sctpMatchBuilder.build();
646     }
647
648     private Layer3Match prepLayer3MatchIpv4() {
649         Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
650         ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("192.168.1.104/32"));
651         ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("192.168.1.105/32"));
652         return ipv4MatchBuilder.build();
653     }
654
655     private Layer3Match prepLayer3MatchIpv6() {
656         Ipv6MatchBuilder ipv6MatchBuilder = new Ipv6MatchBuilder();
657         ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix("3001:0db8:85a3:0000:0000:8a2e:0370:7334"));
658         ipv6MatchBuilder.setIpv6Destination(new Ipv6Prefix("3001:0db8:85a3:0000:0000:8a2e:0370:7335"));
659         return ipv6MatchBuilder.build();
660     }
661
662     private Layer3Match prepLayer3MatchArp() {
663         ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
664         arpMatchBuilder.setArpSourceTransportAddress(new Ipv4Prefix("192.168.1.101/32"));
665         arpMatchBuilder.setArpTargetTransportAddress(new Ipv4Prefix("192.168.1.102/32"));
666
667         ArpSourceHardwareAddressBuilder arpSourAddressBuild = new ArpSourceHardwareAddressBuilder();
668         arpSourAddressBuild.setAddress(new MacAddress("22:44:66:88:AA:CC"));
669         arpMatchBuilder.setArpSourceHardwareAddress(arpSourAddressBuild.build());
670
671         ArpTargetHardwareAddressBuilder arpTarAddressBuild = new ArpTargetHardwareAddressBuilder();
672         arpTarAddressBuild.setAddress(new MacAddress("11:33:55:77:BB:DD"));
673         arpMatchBuilder.setArpTargetHardwareAddress(arpTarAddressBuild.build());
674         return arpMatchBuilder.build();
675     }
676
677     private VlanMatch prepVlanMatch() {
678         VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
679
680         VlanIdBuilder vlanIdBuilder = new VlanIdBuilder().setVlanId(new VlanId(0xfff));
681         vlanMatchBuilder.setVlanId(vlanIdBuilder.setVlanIdPresent(true).build());
682         vlanMatchBuilder.setVlanPcp(new VlanPcp((short) 0x7));
683
684         return vlanMatchBuilder.build();
685     }
686
687     private VlanMatch prepVlanNoneMatch() {
688         VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
689
690         VlanIdBuilder vlanIdBuilder = new VlanIdBuilder().
691             setVlanIdPresent(false);
692         vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
693
694         return vlanMatchBuilder.build();
695     }
696
697     private IpMatch prepIpMatch() {
698         IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
699         ipMatchBuilder.setIpDscp(new Dscp((short) 0x33));
700         ipMatchBuilder.setIpProtocol((short) 0x3f);
701         return ipMatchBuilder.build();
702     }
703
704     private EthernetMatch prepEthernetMatch() {
705         EthernetMatchBuilder odEthernetMatchBuilder = new EthernetMatchBuilder();
706         odEthernetMatchBuilder.setEthernetDestination(prepEthDest());
707         odEthernetMatchBuilder.setEthernetSource(prepEthSour());
708         odEthernetMatchBuilder.setEthernetType(prepEthType());
709         return odEthernetMatchBuilder.build();
710     }
711
712     private EthernetType prepEthType() {
713         EthernetTypeBuilder ethTypeBuild = new EthernetTypeBuilder();
714         ethTypeBuild.setType(new EtherType(0xffffL));
715         return ethTypeBuild.build();
716     }
717
718     private EthernetSource prepEthSour() {
719         EthernetSourceBuilder ethSourBuild = new EthernetSourceBuilder();
720         ethSourBuild.setAddress(new MacAddress("24:77:03:7C:C5:F1"));
721         return ethSourBuild.build();
722     }
723
724     private EthernetDestination prepEthDest() {
725         EthernetDestinationBuilder ethDestBuild = new EthernetDestinationBuilder();
726         ethDestBuild.setAddress(new MacAddress("3C:A9:F4:00:E0:C8"));
727         return ethDestBuild.build();
728     }
729 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.