2 * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.sal.compatibility.test;
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;
18 import java.util.ArrayList;
19 import java.util.List;
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.core.ConstructionException;
45 import org.opendaylight.controller.sal.core.Node;
46 import org.opendaylight.controller.sal.core.Node.NodeIDType;
47 import org.opendaylight.controller.sal.core.NodeConnector;
48 import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
49 import org.opendaylight.controller.sal.flowprogrammer.Flow;
50 import org.opendaylight.controller.sal.match.Match;
51 import org.opendaylight.controller.sal.match.MatchType;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCase;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCase;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCase;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCase;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCase;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCase;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCase;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCase;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeFlow;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
83 import com.google.common.net.InetAddresses;
85 public class TestFromSalConversionsUtils {
86 private enum MtchType {
87 other, untagged, ipv4, ipv6, arp, sctp, tcp, udp
91 public void testFromSalConversion() throws ConstructionException {
93 Flow salFlow = prepareSalFlowCommon();
94 NodeFlow odNodeFlow = MDFlowMapping.flowAdded(salFlow);
96 checkOdFlow(odNodeFlow);
98 odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.other));
99 checkOdMatch(odNodeFlow.getMatch(), MtchType.other);
101 odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.untagged));
102 checkOdMatch(odNodeFlow.getMatch(), MtchType.untagged);
104 odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.arp));
105 checkOdMatch(odNodeFlow.getMatch(), MtchType.arp);
107 odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.ipv4));
108 checkOdMatch(odNodeFlow.getMatch(), MtchType.ipv4);
110 odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.ipv6));
111 checkOdMatch(odNodeFlow.getMatch(), MtchType.ipv6);
113 odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.sctp));
114 checkOdMatch(odNodeFlow.getMatch(), MtchType.sctp);
116 odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.tcp));
117 checkOdMatch(odNodeFlow.getMatch(), MtchType.tcp);
119 odNodeFlow = MDFlowMapping.flowAdded(prepareSalMatch(salFlow, MtchType.udp));
120 checkOdMatch(odNodeFlow.getMatch(), MtchType.udp);
123 private void checkOdMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match match,
127 assertEquals("Ether type is incorrect.", ETHERNET_ARP, (long) match.getEthernetMatch().getEthernetType()
128 .getType().getValue());
129 Layer3Match layer3Match = match.getLayer3Match();
130 boolean arpFound = false;
131 if (layer3Match instanceof ArpMatch) {
132 assertEquals("Source IP address is wrong.", "192.168.100.100", ((ArpMatch) layer3Match)
133 .getArpSourceTransportAddress().getValue());
134 assertEquals("Destination IP address is wrong.", "192.168.100.101", ((ArpMatch) layer3Match)
135 .getArpTargetTransportAddress().getValue());
136 assertEquals("Source MAC address is wrong.", "ff:ee:dd:cc:bb:aa", ((ArpMatch) layer3Match)
137 .getArpSourceHardwareAddress().getAddress().getValue());
138 assertEquals("Destination MAC address is wrong.", "ff:ee:dd:cc:bb:aa", ((ArpMatch) layer3Match)
139 .getArpTargetHardwareAddress().getAddress().getValue());
142 assertNotNull("Arp wasn't found", arpFound);
145 assertEquals("Ether type is incorrect.", 0xffff, (long) match.getEthernetMatch().getEthernetType()
146 .getType().getValue());
147 boolean ipv4Found = false;
148 layer3Match = match.getLayer3Match();
149 if (layer3Match instanceof Ipv4Match) {
150 assertEquals("Source IP address is wrong.", "192.168.100.102", ((Ipv4Match) layer3Match)
151 .getIpv4Source().getValue());
152 assertEquals("Destination IP address is wrong.", "192.168.100.103", ((Ipv4Match) layer3Match)
153 .getIpv4Destination().getValue());
155 assertNotNull("Ipv4 wasn't found", ipv4Found);
158 assertEquals("Ether type is incorrect.", 0xffff, (long) match.getEthernetMatch().getEthernetType()
159 .getType().getValue());
160 boolean ipv6Found = false;
161 layer3Match = match.getLayer3Match();
162 if (layer3Match instanceof Ipv6Match) {
163 assertEquals("Source IP address is wrong.", "2001:db8:85a3::8a2e:370:7335", ((Ipv6Match) layer3Match)
164 .getIpv6Source().getValue());
165 assertEquals("Destination IP address is wrong.", "2001:db8:85a3::8a2e:370:7336",
166 ((Ipv6Match) layer3Match).getIpv6Destination().getValue());
168 assertNotNull("Ipv6 wasn't found", ipv6Found);
171 assertEquals("Incoming port is wrong.", "openflow:12345:10", match.getInPort().getValue());
172 assertEquals("Source MAC address is wrong.", "ff:ee:dd:cc:bb:aa", match.getEthernetMatch()
173 .getEthernetSource().getAddress().getValue());
174 assertEquals("Destinatio MAC address is wrong.", "ff:ee:dd:cc:bb:aa", match.getEthernetMatch()
175 .getEthernetDestination().getAddress().getValue());
176 assertEquals("Vlan ID is not present.", Boolean.TRUE, match.getVlanMatch().getVlanId().isVlanIdPresent());
177 assertEquals("Vlan ID is wrong.", (Integer) 0xfff, match.getVlanMatch().getVlanId().getVlanId().getValue());
178 assertEquals("Vlan ID priority is wrong.", (short) 0x7, (short) match.getVlanMatch().getVlanPcp()
180 assertEquals("DCSP is wrong.", (short) 0x3f, (short) match.getIpMatch().getIpDscp().getValue());
183 assertEquals("Source MAC address is wrong.", "ff:ee:dd:cc:bb:aa", match.getEthernetMatch()
184 .getEthernetSource().getAddress().getValue());
185 assertEquals("Destinatio MAC address is wrong.", "ff:ee:dd:cc:bb:aa", match.getEthernetMatch()
186 .getEthernetDestination().getAddress().getValue());
187 assertEquals("Vlan ID is present.", Boolean.FALSE, match.getVlanMatch().getVlanId().isVlanIdPresent());
188 assertEquals("Vlan ID is wrong.", Integer.valueOf(0), match.getVlanMatch().getVlanId().getVlanId().getValue());
189 assertEquals("DCSP is wrong.", (short) 0x3f, (short) match.getIpMatch().getIpDscp().getValue());
192 boolean sctpFound = false;
193 assertEquals("Wrong protocol", CRUDP, match.getIpMatch().getIpProtocol().byteValue());
194 Layer4Match layer4Match = match.getLayer4Match();
195 if (layer4Match instanceof SctpMatch) {
196 assertEquals("Sctp source port is incorrect.", 0xffff, (int) ((SctpMatch) layer4Match)
197 .getSctpSourcePort().getValue());
198 assertEquals("Sctp dest port is incorrect.", 0xfffe, (int) ((SctpMatch) layer4Match)
199 .getSctpDestinationPort().getValue());
202 assertNotNull("Sctp wasn't found", sctpFound);
205 boolean tcpFound = false;
206 assertEquals("Wrong protocol", TCP, match.getIpMatch().getIpProtocol().byteValue());
207 layer4Match = match.getLayer4Match();
208 if (layer4Match instanceof TcpMatch) {
209 assertEquals("Tcp source port is incorrect.", 0xabcd, (int) ((TcpMatch) layer4Match)
210 .getTcpSourcePort().getValue());
211 assertEquals("Tcp dest port is incorrect.", 0xdcba, (int) ((TcpMatch) layer4Match)
212 .getTcpDestinationPort().getValue());
215 assertNotNull("Tcp wasn't found", tcpFound);
218 boolean udpFound = false;
219 assertEquals("Wrong protocol", UDP, match.getIpMatch().getIpProtocol().byteValue());
220 layer4Match = match.getLayer4Match();
221 if (layer4Match instanceof UdpMatch) {
222 assertEquals("Udp source port is incorrect.", 0xcdef, (int) ((UdpMatch) layer4Match)
223 .getUdpSourcePort().getValue());
224 assertEquals("Udp dest port is incorrect.", 0xfedc, (int) ((UdpMatch) layer4Match)
225 .getUdpDestinationPort().getValue());
228 assertNotNull("Udp wasn't found", udpFound);
234 private void checkOdFlow(NodeFlow odNodeFlow) {
235 assertEquals("Cookie is incorrect.", 9223372036854775807L, odNodeFlow.getCookie().getValue().longValue());
236 assertEquals("Hard timeout is incorrect.", 32765, odNodeFlow.getHardTimeout().shortValue());
237 assertEquals("Iddle timeout is incorrect.", 32766, odNodeFlow.getIdleTimeout().shortValue());
238 assertEquals("Priority is incorrect.", 32767, odNodeFlow.getPriority().shortValue());
240 checkOdActions(ToSalConversionsUtils.getAction(odNodeFlow));
243 private void checkOdActions(
244 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions) {
245 checkOdAction(actions, FloodActionCase.class, false);
246 checkOdAction(actions, FloodAllActionCase.class, false);
247 checkOdAction(actions, HwPathActionCase.class, false);
248 checkOdAction(actions, LoopbackActionCase.class, false);
249 checkOdAction(actions, PopVlanActionCase.class, false);
250 checkOdAction(actions, PushVlanActionCase.class, true);
251 checkOdAction(actions, SetDlDstActionCase.class, true);
252 checkOdAction(actions, SetDlSrcActionCase.class, true);
253 checkOdAction(actions, SetDlTypeActionCase.class, true);
254 checkOdAction(actions, SetNwTosActionCase.class, true);
255 checkOdAction(actions, SetNwDstActionCase.class, true);
256 checkOdAction(actions, SetNwSrcActionCase.class, true);
257 checkOdAction(actions, SetNextHopActionCase.class, true);
258 checkOdAction(actions, SetTpDstActionCase.class, true);
259 checkOdAction(actions, SetTpSrcActionCase.class, true);
260 checkOdAction(actions, SetVlanCfiActionCase.class, true);
261 checkOdAction(actions, SetVlanIdActionCase.class, true);
262 checkOdAction(actions, SetVlanPcpActionCase.class, true);
263 checkOdAction(actions, SwPathActionCase.class, false);
266 private void checkOdAction(
267 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions, Class<?> cl,
269 int numOfFoundActions = 0;
270 for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action action : actions) {
271 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action innerAction = action
273 if (cl.isInstance(innerAction)) {
275 if (innerAction instanceof PushVlanActionCase) {
276 assertEquals("Wrong value of cfi in PushVlanAction.", (Integer) 1, ((PushVlanActionCase) innerAction).getPushVlanAction()
277 .getCfi().getValue());
278 assertEquals("Wrong value of pcp in PushVlanAction.", (Integer) 7,
279 ((PushVlanActionCase) innerAction).getPushVlanAction().getPcp());
280 assertEquals("Wrong value of tag in PushVlanAction.", (Integer) 0x8100,
281 ((PushVlanActionCase) innerAction).getPushVlanAction().getTag());
282 assertEquals("Wrong value of vlad ID in PushVlanAction.", (Integer) 4095,
283 ((PushVlanActionCase) innerAction).getPushVlanAction().getVlanId().getValue());
284 } else if (innerAction instanceof SetDlDstActionCase) {
285 assertEquals("Wrong MAC destination address in SetDlDstAction.", "ff:ee:dd:cc:bb:aa",
286 ((SetDlDstActionCase) innerAction).getSetDlDstAction().getAddress().getValue());
287 } else if (innerAction instanceof SetDlSrcActionCase) {
288 assertEquals("Wrong MAC source address in SetDlDstAction.", "ff:ee:dd:cc:bb:aa",
289 ((SetDlSrcActionCase) innerAction).getSetDlSrcAction().getAddress().getValue());
290 } else if (innerAction instanceof SetDlTypeActionCase) {
291 assertEquals("Wrong data link type in SetDlTypeAction.", 513,
292 (long) ((SetDlTypeActionCase) innerAction).getSetDlTypeAction().getDlType().getValue());
293 } else if (innerAction instanceof SetNextHopActionCase) {
294 Address address = ((SetNextHopActionCase) innerAction).getSetNextHopAction().getAddress();
295 boolean ipv4AddressFound = false;
296 if (address instanceof Ipv4) {
297 ipv4AddressFound = true;
298 assertEquals("Wrong IP address type in SetNextHopAction.", "192.168.100.100", ((Ipv4) address)
299 .getIpv4Address().getValue());
301 assertTrue("Ipv4 address wasn't found.", ipv4AddressFound);
302 } else if (innerAction instanceof SetNwTosActionCase) {
303 assertEquals("Wrong TOS in SetNwTosAction.", (Integer) 63, ((SetNwTosActionCase) innerAction).getSetNwTosAction().getTos());
304 } else if (innerAction instanceof SetNwDstActionCase) {
305 Address address = ((SetNwDstActionCase) innerAction).getSetNwDstAction().getAddress();
306 boolean ipv4AddressFound = false;
307 if (address instanceof Ipv4) {
308 ipv4AddressFound = true;
309 assertEquals("Wrong IP address type in SetNwDstAction.", "192.168.100.101", ((Ipv4) address)
310 .getIpv4Address().getValue());
312 assertTrue("Ipv4 address wasn't found.", ipv4AddressFound);
313 } else if (innerAction instanceof SetNwSrcActionCase) {
314 Address address = ((SetNwSrcActionCase) innerAction).getSetNwSrcAction().getAddress();
315 boolean ipv4AddressFound = false;
316 if (address instanceof Ipv4) {
317 ipv4AddressFound = true;
318 assertEquals("Wrong IP address type in SetNwSrcAction.", "192.168.100.102", ((Ipv4) address)
319 .getIpv4Address().getValue());
321 assertTrue("Ipv4 address wasn't found.", ipv4AddressFound);
322 } else if (innerAction instanceof SetTpDstActionCase) {
323 assertEquals("Port number is incorrect in SetTpDstAction.", (Integer) 65534,
324 ((SetTpDstActionCase) innerAction).getSetTpDstAction().getPort().getValue());
325 } else if (innerAction instanceof SetTpSrcActionCase) {
326 assertEquals("Port number is incorrect in SetTpSrcAction.", (Integer) 65535,
327 ((SetTpSrcActionCase) innerAction).getSetTpSrcAction().getPort().getValue());
328 } else if (innerAction instanceof SetVlanCfiActionCase) {
329 assertEquals("Vlan cfi number is incorrect in SetVlanCfiAction.", (Integer) 1,
330 ((SetVlanCfiActionCase) innerAction).getSetVlanCfiAction().getVlanCfi().getValue());
331 } else if (innerAction instanceof SetVlanIdActionCase) {
332 assertEquals("Vlan id number is incorrect in SetVlanIdAction.", (Integer) 4095,
333 ((SetVlanIdActionCase) innerAction).getSetVlanIdAction().getVlanId().getValue());
334 } else if (innerAction instanceof SetVlanPcpActionCase) {
335 assertEquals("Vlan pcp number is incorrect in SetVlanPcpAction.", new Short((short) 7),
336 ((SetVlanPcpActionCase) innerAction).getSetVlanPcpAction().getVlanPcp().getValue());
340 assertEquals("Incorrrect number of action " + cl.getName() + ".", 1, numOfFoundActions);
344 private Flow prepareSalFlowCommon() {
345 Flow salFlow = new Flow();
346 salFlow.setId(9223372036854775807L);
347 salFlow.setHardTimeout((short) 32765);
348 salFlow.setIdleTimeout((short) 32766);
349 salFlow.setPriority((short) 32767);
350 salFlow.setActions(prepareSalActions());
351 salFlow.setMatch(new Match());
356 private Flow prepareSalMatch(Flow salFlow, MtchType mt) throws ConstructionException {
357 Match salMatch = new Match();
360 salMatch.setField(MatchType.DL_TYPE, ETHERNET_ARP);
361 salMatch.setField(MatchType.NW_SRC, InetAddresses.forString("192.168.100.100"));
362 salMatch.setField(MatchType.NW_DST, InetAddresses.forString("192.168.100.101"));
363 salMatch.setField(MatchType.DL_SRC, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa});
364 salMatch.setField(MatchType.DL_DST, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa});
367 salMatch.setField(MatchType.DL_TYPE, (short) 0xffff);
368 salMatch.setField(MatchType.NW_SRC, InetAddresses.forString("192.168.100.102"));
369 salMatch.setField(MatchType.NW_DST, InetAddresses.forString("192.168.100.103"));
372 salMatch.setField(MatchType.DL_TYPE, (short) 0xffff);
373 salMatch.setField(MatchType.NW_SRC, InetAddresses.forString("2001:0db8:85a3:0000:0000:8a2e:0370:7335"));
374 salMatch.setField(MatchType.NW_DST, InetAddresses.forString("2001:0db8:85a3:0000:0000:8a2e:0370:7336"));
377 Node node = new Node(NodeIDType.OPENFLOW, 12345L);
378 NodeConnector port = new NodeConnector(NodeConnectorIDType.OPENFLOW, Short.valueOf((short)10), node);
379 salMatch.setField(MatchType.IN_PORT, port);
380 salMatch.setField(MatchType.DL_SRC, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa});
381 salMatch.setField(MatchType.DL_DST, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa});
382 salMatch.setField(MatchType.DL_VLAN, (short) 0xfff);
383 salMatch.setField(MatchType.DL_VLAN_PR, (byte) 0x7);
384 salMatch.setField(MatchType.NW_TOS, (byte) 0x3f);
387 salMatch.setField(MatchType.DL_SRC, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa});
388 salMatch.setField(MatchType.DL_DST, new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa});
389 salMatch.setField(MatchType.DL_VLAN, MatchType.DL_VLAN_NONE);
390 salMatch.setField(MatchType.NW_TOS, (byte) 0x3f);
393 salMatch.setField(MatchType.NW_PROTO, CRUDP);
394 salMatch.setField(MatchType.TP_SRC, (short) 0xffff);
395 salMatch.setField(MatchType.TP_DST, (short) 0xfffe);
398 salMatch.setField(MatchType.NW_PROTO, TCP);
399 salMatch.setField(MatchType.TP_SRC, (short) 0xabcd);
400 salMatch.setField(MatchType.TP_DST, (short) 0xdcba);
403 salMatch.setField(MatchType.NW_PROTO, UDP);
404 salMatch.setField(MatchType.TP_SRC, (short) 0xcdef);
405 salMatch.setField(MatchType.TP_DST, (short) 0xfedc);
412 salFlow.setMatch(salMatch);
416 private List<Action> prepareSalActions() {
417 List<Action> salActions = new ArrayList<>();
418 salActions.add(new Flood());
419 salActions.add(new FloodAll());
420 salActions.add(new HwPath());
421 salActions.add(new Loopback());
422 // salActions.add(new Output //TODO: mapping is missing
423 salActions.add(new PopVlan());
424 salActions.add(new PushVlan(0x8100, 7, 1, 4095));
425 salActions.add(new SetDlDst(new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa}));
426 salActions.add(new SetDlSrc(new byte[]{(byte )0xff,(byte )0xee,(byte )0xdd,(byte )0xcc,(byte )0xbb,(byte )0xaa}));
427 salActions.add(new SetDlType(513));
428 salActions.add(new SetNextHop(InetAddresses.forString("192.168.100.100")));
429 salActions.add(new SetNwDst(InetAddresses.forString("192.168.100.101")));
430 salActions.add(new SetNwSrc(InetAddresses.forString("192.168.100.102")));
431 salActions.add(new SetNwTos(63));
432 salActions.add(new SetTpDst(65534));
433 salActions.add(new SetTpSrc(65535));
434 salActions.add(new SetVlanCfi(1));
435 salActions.add(new SetVlanId(4095));
436 salActions.add(new SetVlanPcp(7));
437 salActions.add(new SwPath());