Merge "BUG-509: Move DataTree concepts into separate package"
[controller.git] / opendaylight / md-sal / compatibility / sal-compatibility / src / test / java / org / opendaylight / controller / sal / compatibility / test / TestFromSalConversionsUtils.java
1 /*
2  * Copyright (c) 2013 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.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13 import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.CRUDP;
14 import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.ETHERNET_ARP;
15 import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.TCP;
16 import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.UDP;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.junit.Test;
22 import org.opendaylight.controller.sal.action.Action;
23 import org.opendaylight.controller.sal.action.Flood;
24 import org.opendaylight.controller.sal.action.FloodAll;
25 import org.opendaylight.controller.sal.action.HwPath;
26 import org.opendaylight.controller.sal.action.Loopback;
27 import org.opendaylight.controller.sal.action.PopVlan;
28 import org.opendaylight.controller.sal.action.PushVlan;
29 import org.opendaylight.controller.sal.action.SetDlDst;
30 import org.opendaylight.controller.sal.action.SetDlSrc;
31 import org.opendaylight.controller.sal.action.SetDlType;
32 import org.opendaylight.controller.sal.action.SetNextHop;
33 import org.opendaylight.controller.sal.action.SetNwDst;
34 import org.opendaylight.controller.sal.action.SetNwSrc;
35 import org.opendaylight.controller.sal.action.SetNwTos;
36 import org.opendaylight.controller.sal.action.SetTpDst;
37 import org.opendaylight.controller.sal.action.SetTpSrc;
38 import org.opendaylight.controller.sal.action.SetVlanCfi;
39 import org.opendaylight.controller.sal.action.SetVlanId;
40 import org.opendaylight.controller.sal.action.SetVlanPcp;
41 import org.opendaylight.controller.sal.action.SwPath;
42 import org.opendaylight.controller.sal.compatibility.MDFlowMapping;
43 import org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils;
44 import org.opendaylight.controller.sal.flowprogrammer.Flow;
45 import org.opendaylight.controller.sal.match.Match;
46 import org.opendaylight.controller.sal.match.MatchType;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCase;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCase;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCase;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCase;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCase;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCase;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCase;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCase;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
77
78 import com.google.common.net.InetAddresses;
79
80 public class TestFromSalConversionsUtils {
81     private enum MtchType {
82         other, ipv4, ipv6, arp, sctp, tcp, udp
83     }
84
85     @Test
86     public void testFromSalConversion() {
87
88         Flow salFlow = prepareSalFlowCommon();
89         NodeFlow odNodeFlow = MDFlowMapping.flowAdded(salFlow);
90
91         checkOdFlow(odNodeFlow);
92
93         odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.other));
94         checkOdMatch(odNodeFlow.getMatch(), MtchType.other);
95
96         odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.arp));
97         checkOdMatch(odNodeFlow.getMatch(), MtchType.arp);
98
99         odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.ipv4));
100         checkOdMatch(odNodeFlow.getMatch(), MtchType.ipv4);
101
102         odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.ipv6));
103         checkOdMatch(odNodeFlow.getMatch(), MtchType.ipv6);
104
105         odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.sctp));
106         checkOdMatch(odNodeFlow.getMatch(), MtchType.sctp);
107
108         odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.tcp));
109         checkOdMatch(odNodeFlow.getMatch(), MtchType.tcp);
110
111         odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.udp));
112         checkOdMatch(odNodeFlow.getMatch(), MtchType.udp);
113     }
114
115     private void checkOdMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match match,
116             MtchType mt) {
117         switch (mt) {
118         case arp:
119             assertEquals("Ether type is incorrect.", ETHERNET_ARP, (long) match.getEthernetMatch().getEthernetType()
120                     .getType().getValue());
121             Layer3Match layer3Match = match.getLayer3Match();
122             boolean arpFound = false;
123             if (layer3Match instanceof ArpMatch) {
124                 assertEquals("Source IP address is wrong.", "192.168.100.100", ((ArpMatch) layer3Match)
125                         .getArpSourceTransportAddress().getValue());
126                 assertEquals("Destination IP address is wrong.", "192.168.100.101", ((ArpMatch) layer3Match)
127                         .getArpTargetTransportAddress().getValue());
128                 assertEquals("Source MAC address is wrong.", "ff:ee:dd:cc:bb:aa", ((ArpMatch) layer3Match)
129                         .getArpSourceHardwareAddress().getAddress().getValue());
130                 assertEquals("Destination MAC address is wrong.", "ff:ee:dd:cc:bb:aa", ((ArpMatch) layer3Match)
131                         .getArpTargetHardwareAddress().getAddress().getValue());
132                 arpFound = true;
133             }
134             assertNotNull("Arp wasn't found", arpFound);
135             break;
136         case ipv4:
137             assertEquals("Ether type is incorrect.", 0xffff, (long) match.getEthernetMatch().getEthernetType()
138                     .getType().getValue());
139             boolean ipv4Found = false;
140             layer3Match = match.getLayer3Match();
141             if (layer3Match instanceof Ipv4Match) {
142                 assertEquals("Source IP address is wrong.", "192.168.100.102", ((Ipv4Match) layer3Match)
143                         .getIpv4Source().getValue());
144                 assertEquals("Destination IP address is wrong.", "192.168.100.103", ((Ipv4Match) layer3Match)
145                         .getIpv4Destination().getValue());
146             }
147             assertNotNull("Ipv4 wasn't found", ipv4Found);
148             break;
149         case ipv6:
150             assertEquals("Ether type is incorrect.", 0xffff, (long) match.getEthernetMatch().getEthernetType()
151                     .getType().getValue());
152             boolean ipv6Found = false;
153             layer3Match = match.getLayer3Match();
154             if (layer3Match instanceof Ipv6Match) {
155                 assertEquals("Source IP address is wrong.", "2001:db8:85a3::8a2e:370:7335", ((Ipv6Match) layer3Match)
156                         .getIpv6Source().getValue());
157                 assertEquals("Destination IP address is wrong.", "2001:db8:85a3::8a2e:370:7336",
158                         ((Ipv6Match) layer3Match).getIpv6Destination().getValue());
159             }
160             assertNotNull("Ipv6 wasn't found", ipv6Found);
161             break;
162         case other:
163             assertEquals("Source MAC address is wrong.", "ff:ee:dd:cc:bb:aa", match.getEthernetMatch()
164                     .getEthernetSource().getAddress().getValue());
165             assertEquals("Destinatio MAC address is wrong.", "ff:ee:dd:cc:bb:aa", match.getEthernetMatch()
166                     .getEthernetDestination().getAddress().getValue());
167             assertEquals("Vlan ID is wrong.", (Integer) 0xfff, match.getVlanMatch().getVlanId().getVlanId().getValue());
168             assertEquals("Vlan ID priority is wrong.", (short) 0x7, (short) match.getVlanMatch().getVlanPcp()
169                     .getValue());
170             assertEquals("DCSP is wrong.", (short) 0x3f, (short) match.getIpMatch().getIpDscp().getValue());
171             break;
172         case sctp:
173             boolean sctpFound = false;
174             assertEquals("Wrong protocol", CRUDP, match.getIpMatch().getIpProtocol().byteValue());
175             Layer4Match layer4Match = match.getLayer4Match();
176             if (layer4Match instanceof SctpMatch) {
177                 assertEquals("Sctp source port is incorrect.", 0xffff, (int) ((SctpMatch) layer4Match)
178                         .getSctpSourcePort().getValue());
179                 assertEquals("Sctp dest port is incorrect.", 0xfffe, (int) ((SctpMatch) layer4Match)
180                         .getSctpDestinationPort().getValue());
181                 sctpFound = true;
182             }
183             assertNotNull("Sctp wasn't found", sctpFound);
184             break;
185         case tcp:
186             boolean tcpFound = false;
187             assertEquals("Wrong protocol", TCP, match.getIpMatch().getIpProtocol().byteValue());
188             layer4Match = match.getLayer4Match();
189             if (layer4Match instanceof TcpMatch) {
190                 assertEquals("Tcp source port is incorrect.", 0xabcd, (int) ((TcpMatch) layer4Match)
191                         .getTcpSourcePort().getValue());
192                 assertEquals("Tcp dest port is incorrect.", 0xdcba, (int) ((TcpMatch) layer4Match)
193                         .getTcpDestinationPort().getValue());
194                 sctpFound = true;
195             }
196             assertNotNull("Tcp wasn't found", tcpFound);
197             break;
198         case udp:
199             boolean udpFound = false;
200             assertEquals("Wrong protocol", UDP, match.getIpMatch().getIpProtocol().byteValue());
201             layer4Match = match.getLayer4Match();
202             if (layer4Match instanceof UdpMatch) {
203                 assertEquals("Udp source port is incorrect.", 0xcdef, (int) ((UdpMatch) layer4Match)
204                         .getUdpSourcePort().getValue());
205                 assertEquals("Udp dest port is incorrect.", 0xfedc, (int) ((UdpMatch) layer4Match)
206                         .getUdpDestinationPort().getValue());
207                 sctpFound = true;
208             }
209             assertNotNull("Udp wasn't found", udpFound);
210             break;
211         }
212
213     }
214
215     private void checkOdFlow(NodeFlow odNodeFlow) {
216         assertEquals("Cookie is incorrect.", 9223372036854775807L, odNodeFlow.getCookie().getValue().longValue());
217         assertEquals("Hard timeout is incorrect.", 32765, odNodeFlow.getHardTimeout().shortValue());
218         assertEquals("Iddle timeout is incorrect.", 32766, odNodeFlow.getIdleTimeout().shortValue());
219         assertEquals("Priority is incorrect.", 32767, odNodeFlow.getPriority().shortValue());
220
221         checkOdActions(ToSalConversionsUtils.getAction(odNodeFlow));
222     }
223
224     private void checkOdActions(
225             List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions) {
226         checkOdAction(actions, FloodActionCase.class, false);
227         checkOdAction(actions, FloodAllActionCase.class, false);
228         checkOdAction(actions, HwPathActionCase.class, false);
229         checkOdAction(actions, LoopbackActionCase.class, false);
230         checkOdAction(actions, PopVlanActionCase.class, false);
231         checkOdAction(actions, PushVlanActionCase.class, true);
232         checkOdAction(actions, SetDlDstActionCase.class, true);
233         checkOdAction(actions, SetDlSrcActionCase.class, true);
234         checkOdAction(actions, SetDlTypeActionCase.class, true);
235         checkOdAction(actions, SetNwTosActionCase.class, true);
236         checkOdAction(actions, SetNwDstActionCase.class, true);
237         checkOdAction(actions, SetNwSrcActionCase.class, true);
238         checkOdAction(actions, SetNextHopActionCase.class, true);
239         checkOdAction(actions, SetTpDstActionCase.class, true);
240         checkOdAction(actions, SetTpSrcActionCase.class, true);
241         checkOdAction(actions, SetVlanCfiActionCase.class, true);
242         checkOdAction(actions, SetVlanIdActionCase.class, true);
243         checkOdAction(actions, SetVlanPcpActionCase.class, true);
244         checkOdAction(actions, SwPathActionCase.class, false);
245     }
246
247     private void checkOdAction(
248             List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions, Class<?> cl,
249             boolean b) {
250         int numOfFoundActions = 0;
251         for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action action : actions) {
252                 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action innerAction = action
253                     .getAction();
254             if (cl.isInstance(innerAction)) {
255                 numOfFoundActions++;
256                 if (innerAction instanceof PushVlanActionCase) {
257                     assertEquals("Wrong value of cfi in PushVlanAction.", (Integer) 1, ((PushVlanActionCase) innerAction).getPushVlanAction()
258                             .getCfi().getValue());
259                     assertEquals("Wrong value of pcp in PushVlanAction.", (Integer) 7,
260                             ((PushVlanActionCase) innerAction).getPushVlanAction().getPcp());
261                     assertEquals("Wrong value of tag in PushVlanAction.", (Integer) 0x8100,
262                             ((PushVlanActionCase) innerAction).getPushVlanAction().getTag());
263                     assertEquals("Wrong value of vlad ID in PushVlanAction.", (Integer) 4095,
264                             ((PushVlanActionCase) innerAction).getPushVlanAction().getVlanId().getValue());
265                 } else if (innerAction instanceof SetDlDstActionCase) {
266                     assertEquals("Wrong MAC destination address in SetDlDstAction.", "ff:ee:dd:cc:bb:aa",
267                             ((SetDlDstActionCase) innerAction).getSetDlDstAction().getAddress().getValue());
268                 } else if (innerAction instanceof SetDlSrcActionCase) {
269                     assertEquals("Wrong MAC source address in SetDlDstAction.", "ff:ee:dd:cc:bb:aa",
270                             ((SetDlSrcActionCase) innerAction).getSetDlSrcAction().getAddress().getValue());
271                 } else if (innerAction instanceof SetDlTypeActionCase) {
272                     assertEquals("Wrong data link type in SetDlTypeAction.", 513,
273                             (long) ((SetDlTypeActionCase) innerAction).getSetDlTypeAction().getDlType().getValue());
274                 } else if (innerAction instanceof SetNextHopActionCase) {
275                     Address address = ((SetNextHopActionCase) innerAction).getSetNextHopAction().getAddress();
276                     boolean ipv4AddressFound = false;
277                     if (address instanceof Ipv4) {
278                         ipv4AddressFound = true;
279                         assertEquals("Wrong IP address type in SetNextHopAction.", "192.168.100.100", ((Ipv4) address)
280                                 .getIpv4Address().getValue());
281                     }
282                     assertTrue("Ipv4 address wasn't found.", ipv4AddressFound);
283                 } else if (innerAction instanceof SetNwTosActionCase) {
284                     assertEquals("Wrong TOS in SetNwTosAction.", (Integer) 63, ((SetNwTosActionCase) innerAction).getSetNwTosAction().getTos());
285                 } else if (innerAction instanceof SetNwDstActionCase) {
286                     Address address = ((SetNwDstActionCase) innerAction).getSetNwDstAction().getAddress();
287                     boolean ipv4AddressFound = false;
288                     if (address instanceof Ipv4) {
289                         ipv4AddressFound = true;
290                         assertEquals("Wrong IP address type in SetNwDstAction.", "192.168.100.101", ((Ipv4) address)
291                                 .getIpv4Address().getValue());
292                     }
293                     assertTrue("Ipv4 address wasn't found.", ipv4AddressFound);
294                 } else if (innerAction instanceof SetNwSrcActionCase) {
295                     Address address = ((SetNwSrcActionCase) innerAction).getSetNwSrcAction().getAddress();
296                     boolean ipv4AddressFound = false;
297                     if (address instanceof Ipv4) {
298                         ipv4AddressFound = true;
299                         assertEquals("Wrong IP address type in SetNwSrcAction.", "192.168.100.102", ((Ipv4) address)
300                                 .getIpv4Address().getValue());
301                     }
302                     assertTrue("Ipv4 address wasn't found.", ipv4AddressFound);
303                 } else if (innerAction instanceof SetTpDstActionCase) {
304                     assertEquals("Port number is incorrect in SetTpDstAction.", (Integer) 65534,
305                             ((SetTpDstActionCase) innerAction).getSetTpDstAction().getPort().getValue());
306                 } else if (innerAction instanceof SetTpSrcActionCase) {
307                     assertEquals("Port number is incorrect in SetTpSrcAction.", (Integer) 65535,
308                             ((SetTpSrcActionCase) innerAction).getSetTpSrcAction().getPort().getValue());
309                 } else if (innerAction instanceof SetVlanCfiActionCase) {
310                     assertEquals("Vlan cfi number is incorrect in SetVlanCfiAction.", (Integer) 1,
311                             ((SetVlanCfiActionCase) innerAction).getSetVlanCfiAction().getVlanCfi().getValue());
312                 } else if (innerAction instanceof SetVlanIdActionCase) {
313                     assertEquals("Vlan id number is incorrect in SetVlanIdAction.", (Integer) 4095,
314                             ((SetVlanIdActionCase) innerAction).getSetVlanIdAction().getVlanId().getValue());
315                 } else if (innerAction instanceof SetVlanPcpActionCase) {
316                     assertEquals("Vlan pcp number is incorrect in SetVlanPcpAction.", new Short((short) 7),
317                             ((SetVlanPcpActionCase) innerAction).getSetVlanPcpAction().getVlanPcp().getValue());
318                 }
319             }
320         }
321         assertEquals("Incorrrect number of action " + cl.getName() + ".", 1, numOfFoundActions);
322
323     }
324
325     private Flow prepareSalFlowCommon() {
326         Flow salFlow = new Flow();
327         salFlow.setId(9223372036854775807L);
328         salFlow.setHardTimeout((short) 32765);
329         salFlow.setIdleTimeout((short) 32766);
330         salFlow.setPriority((short) 32767);
331         salFlow.setActions(prepareSalActions());
332         salFlow.setMatch(new Match());
333
334         return salFlow;
335     }
336
337     private Flow prepareSalMatch(Flow salFlow, MtchType mt) {
338         Match salMatch = new Match();
339         switch (mt) {
340         case arp:
341             salMatch.setField(MatchType.DL_TYPE, ETHERNET_ARP);
342             salMatch.setField(MatchType.NW_SRC, InetAddresses.forString("192.168.100.100"));
343             salMatch.setField(MatchType.NW_DST, InetAddresses.forString("192.168.100.101"));
344             salMatch.setField(MatchType.DL_SRC, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa});
345             salMatch.setField(MatchType.DL_DST, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa});
346             break;
347         case ipv4:
348             salMatch.setField(MatchType.DL_TYPE, (short) 0xffff);
349             salMatch.setField(MatchType.NW_SRC, InetAddresses.forString("192.168.100.102"));
350             salMatch.setField(MatchType.NW_DST, InetAddresses.forString("192.168.100.103"));
351             break;
352         case ipv6:
353             salMatch.setField(MatchType.DL_TYPE, (short) 0xffff);
354             salMatch.setField(MatchType.NW_SRC, InetAddresses.forString("2001:0db8:85a3:0000:0000:8a2e:0370:7335"));
355             salMatch.setField(MatchType.NW_DST, InetAddresses.forString("2001:0db8:85a3:0000:0000:8a2e:0370:7336"));
356             break;
357         case other:
358             salMatch.setField(MatchType.DL_SRC, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa});
359             salMatch.setField(MatchType.DL_DST, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa});
360             salMatch.setField(MatchType.DL_VLAN, (short) 0xfff);
361             salMatch.setField(MatchType.DL_VLAN_PR, (byte) 0x7);
362             salMatch.setField(MatchType.NW_TOS, (byte) 0x3f);
363             break;
364         case sctp:
365             salMatch.setField(MatchType.NW_PROTO, CRUDP);
366             salMatch.setField(MatchType.TP_SRC, (short) 0xffff);
367             salMatch.setField(MatchType.TP_DST, (short) 0xfffe);
368             break;
369         case tcp:
370             salMatch.setField(MatchType.NW_PROTO, TCP);
371             salMatch.setField(MatchType.TP_SRC, (short) 0xabcd);
372             salMatch.setField(MatchType.TP_DST, (short) 0xdcba);
373             break;
374         case udp:
375             salMatch.setField(MatchType.NW_PROTO, UDP);
376             salMatch.setField(MatchType.TP_SRC, (short) 0xcdef);
377             salMatch.setField(MatchType.TP_DST, (short) 0xfedc);
378             break;
379         default:
380             break;
381
382         }
383
384         salFlow.setMatch(salMatch);
385         return salFlow;
386     }
387
388     private List<Action> prepareSalActions() {
389         List<Action> salActions = new ArrayList<>();
390         salActions.add(new Flood());
391         salActions.add(new FloodAll());
392         salActions.add(new HwPath());
393         salActions.add(new Loopback());
394         // salActions.add(new Output //TODO: mapping is missing
395         salActions.add(new PopVlan());
396         salActions.add(new PushVlan(0x8100, 7, 1, 4095));
397         salActions.add(new SetDlDst(new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa}));
398         salActions.add(new SetDlSrc(new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa}));
399         salActions.add(new SetDlType(513));
400         salActions.add(new SetNextHop(InetAddresses.forString("192.168.100.100")));
401         salActions.add(new SetNwDst(InetAddresses.forString("192.168.100.101")));
402         salActions.add(new SetNwSrc(InetAddresses.forString("192.168.100.102")));
403         salActions.add(new SetNwTos(63));
404         salActions.add(new SetTpDst(65534));
405         salActions.add(new SetTpSrc(65535));
406         salActions.add(new SetVlanCfi(1));
407         salActions.add(new SetVlanId(4095));
408         salActions.add(new SetVlanPcp(7));
409         salActions.add(new SwPath());
410
411         return salActions;
412     }
413
414 }