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

©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.