2 * Copyright (c) 2014, 2015 Ericsson, 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.openflowplugin.test;
10 import com.google.common.util.concurrent.FutureCallback;
11 import com.google.common.util.concurrent.MoreExecutors;
12 import java.util.ArrayList;
13 import java.util.List;
14 import org.eclipse.osgi.framework.console.CommandInterpreter;
15 import org.eclipse.osgi.framework.console.CommandProvider;
16 import org.opendaylight.mdsal.binding.api.DataBroker;
17 import org.opendaylight.mdsal.binding.api.NotificationService;
18 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
19 import org.opendaylight.mdsal.common.api.CommitInfo;
20 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.NodeErrorListener;
100 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
101 import org.opendaylight.yangtools.yang.binding.util.BindingMap;
102 import org.opendaylight.yangtools.yang.common.Uint16;
103 import org.opendaylight.yangtools.yang.common.Uint32;
104 import org.opendaylight.yangtools.yang.common.Uint64;
105 import org.opendaylight.yangtools.yang.common.Uint8;
106 import org.osgi.framework.BundleContext;
107 import org.slf4j.Logger;
108 import org.slf4j.LoggerFactory;
110 public class OpenflowPluginBulkTransactionProvider implements CommandProvider {
111 private static final Logger LOG = LoggerFactory.getLogger(OpenflowPluginBulkTransactionProvider.class);
113 private final DataBroker dataBroker;
114 private final BundleContext ctx;
115 private final String originalFlowName = "Foo";
116 private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl();
117 private final NotificationService notificationService;
119 public OpenflowPluginBulkTransactionProvider(final DataBroker dataBroker,
120 final NotificationService notificationService, final BundleContext ctx) {
121 this.dataBroker = dataBroker;
122 this.notificationService = notificationService;
127 notificationService.registerNotificationListener(nodeErrorListener);
128 ctx.registerService(CommandProvider.class.getName(), this, null);
129 createTestFlow(createTestNode(null), null, null);
132 private static NodeBuilder createTestNode(String nodeId) {
133 if (nodeId == null) {
134 nodeId = OpenflowpluginTestActivator.NODE_ID;
136 return new NodeBuilder().setId(new NodeId(nodeId));
140 public String getHelp() {
144 private FlowBuilder createTestFlow(final NodeBuilder nodeBuilder, final String flowTypeArg, final String tableId) {
146 FlowBuilder flow = new FlowBuilder();
149 String flowType = flowTypeArg;
150 if (flowType == null) {
157 flow.setMatch(createMatch1().build());
158 flow.setInstructions(createDecNwTtlInstructions().build());
162 flow.setMatch(createMatch2().build());
163 flow.setInstructions(createDropInstructions().build());
167 flow.setMatch(createMatch3().build());
168 flow.setInstructions(createDropInstructions().build());
172 flow.setMatch(createEthernetMatch().build());
173 flow.setInstructions(createDropInstructions().build());
177 flow.setMatch(createMatch1().build());
178 flow.setInstructions(createAppyActionInstruction().build());
182 flow.setMatch(createMatch1().build());
183 flow.setInstructions(createGotoTableInstructions().build());
187 flow.setMatch(createMatch1().build());
188 flow.setInstructions(createMeterInstructions().build());
192 flow.setMatch(createMatch1().build());
193 flow.setInstructions(createAppyActionInstruction7().build());
197 flow.setMatch(createMatch1().build());
198 flow.setInstructions(createAppyActionInstruction2().build());
202 flow.setMatch(createMatch1().build());
203 flow.setInstructions(createAppyActionInstruction3().build());
207 flow.setMatch(createMatch1().build());
208 flow.setInstructions(createAppyActionInstruction16().build());
212 flow.setMatch(createMatch1().build());
213 flow.setInstructions(createAppyActionInstruction160().build());
217 flow.setMatch(createMatch1().build());
218 flow.setInstructions(createAppyActionInstruction26().build());
222 flow.setMatch(createMatch1().build());
223 flow.setInstructions(createAppyActionInstruction27().build());
227 flow.setMatch(createMatch1().build());
228 flow.setInstructions(createAppyActionInstruction28().build());
232 flow.setMatch(createMatch1().build());
233 flow.setInstructions(createAppyActionInstruction34().build());
237 flow.setMatch(createICMPv6Match().build());
238 flow.setInstructions(createDecNwTtlInstructions().build());
242 flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
243 flow.setInstructions(createDropInstructions().build());
247 flow.setMatch(createMetadataMatch().build());
248 flow.setInstructions(createDropInstructions().build());
252 flow.setMatch(createL3IPv6Match().build());
253 flow.setInstructions(createDecNwTtlInstructions().build());
257 flow.setMatch(createLLDPMatch().build());
258 flow.setInstructions(createSentToControllerInstructions().build());
263 flow.setMatch(createMatch1().build());
264 flow.setInstructions(createDropInstructions().build());
268 flow.setMatch(createMatch2().build());
269 flow.setInstructions(createDecNwTtlInstructions().build());
273 flow.setMatch(createMatch3().build());
274 flow.setInstructions(createDecNwTtlInstructions().build());
278 flow.setMatch(createEthernetMatch().build());
279 flow.setInstructions(createMeterInstructions().build());
283 flow.setMatch(createMatch1().build());
284 flow.setInstructions(createDecNwTtlInstructions().build());
288 flow.setMatch(createMatch1().build());
289 flow.setInstructions(createAppyActionInstruction7().build());
293 flow.setMatch(createEthernetMatch().build());
294 flow.setInstructions(createAppyActionInstruction6().build());
298 flow.setMatch(createEthernetMatch().build());
299 flow.setInstructions(createAppyActionInstruction7().build());
303 flow.setMatch(createMatch1().build());
304 flow.setInstructions(createAppyActionInstruction9().build());
308 flow.setMatch(createMatch1().build());
309 flow.setInstructions(createAppyActionInstruction9().build());
313 flow.setMatch(createMatch1().build());
314 flow.setInstructions(createAppyActionInstruction6().build());
318 flow.setMatch(createMatch1().build());
319 flow.setInstructions(createDecNwTtlInstructions().build());
323 flow.setMatch(createMatch1().build());
324 flow.setInstructions(createDecNwTtlInstructions().build());
328 flow.setMatch(createMatch1().build());
329 flow.setInstructions(createDecNwTtlInstructions().build());
333 flow.setMatch(createICMPv6Match().build());
334 flow.setInstructions(createDropInstructions().build());
338 flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
339 flow.setInstructions(createMeterInstructions().build());
343 flow.setMatch(createMetadataMatch().build());
344 flow.setInstructions(createAppyActionInstruction6().build());
348 flow.setMatch(createMatch1().build());
349 flow.setInstructions(createAppyActionInstruction6().build());
353 flow.setMatch(createMatch1().build());
354 flow.setInstructions(createAppyActionInstruction7().build());
358 flow.setMatch(createMatch1().build());
359 flow.setInstructions(createAppyActionInstruction8().build());
363 flow.setMatch(createMatch3().build());
364 flow.setInstructions(createMeterInstructions().build());
368 flow.setMatch(createMatch1000().build());
369 flow.setInstructions(createAppyActionInstruction6().build());
373 flow.setMatch(createMatch1000().build());
374 flow.setInstructions(createAppyActionInstruction2().build());
378 flow.setMatch(createMatch1000().build());
379 flow.setInstructions(createAppyActionInstruction3().build());
382 LOG.warn("flow type not understood: {}", flowType);
385 if (null == flow.getBarrier()) {
386 flow.setBarrier(Boolean.FALSE);
388 // flow.setBufferId(12L);
389 flow.setCookie(new FlowCookie(Uint64.TEN));
390 flow.setCookieMask(new FlowCookie(Uint64.TEN));
391 flow.setHardTimeout(Uint16.ZERO);
392 flow.setIdleTimeout(Uint16.ZERO);
393 flow.setInstallHw(false);
394 flow.setStrict(false);
395 flow.setContainerName(null);
396 flow.setFlags(new FlowModFlags(false, false, false, false, true));
397 flow.setId(new FlowId("12"));
398 flow.setTableId(getTableId(tableId));
399 flow.setOutGroup(Uint32.MAX_VALUE);
400 // set outport to OFPP_NONE (65535) to disable remove restriction for
402 flow.setOutPort(Uint64.valueOf(4294967295L));
404 FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
406 flow.setPriority(Uint16.TWO);
407 flow.setFlowName(originalFlowName + "X" + flowType);
411 private static Uint8 getTableId(final String tableId) {
412 if (tableId != null) {
414 return Uint8.valueOf(tableId);
415 } catch (IllegalArgumentException ex) {
416 // ignore exception and continue with default value
422 @SuppressWarnings("checkstyle:MethodName")
423 public void _addFlows(final CommandInterpreter ci) {
424 NodeBuilder tn = createTestNode(ci.nextArgument());
425 String flowtype = ci.nextArgument();
426 Integer flowcnt = Integer.parseInt(flowtype);
433 tf = createTestFlow(tn, "f1", "10");
434 tf1 = createTestFlow(tn, "f2", "11");
435 tf2 = createTestFlow(tn, "f3", "12");
436 tf3 = createTestFlow(tn, "f4", "13");
439 tf = createTestFlow(tn, "f3", "3");
440 tf1 = createTestFlow(tn, "f4", "4");
441 tf2 = createTestFlow(tn, "f5", "5");
442 tf3 = createTestFlow(tn, "f6", "6");
445 tf = createTestFlow(tn, "f7", "7");
446 tf1 = createTestFlow(tn, "f8", "8");
447 tf2 = createTestFlow(tn, "f9", "9");
448 tf3 = createTestFlow(tn, "f10", "10");
452 tf = createTestFlow(tn, "f23", "3");
453 tf1 = createTestFlow(tn, "f34", "4");
454 tf2 = createTestFlow(tn, "f35", "5");
455 tf3 = createTestFlow(tn, "f36", "6");
460 tf = createTestFlow(tn, "f230", "3");
461 tf1 = createTestFlow(tn, "f34", "4");
462 tf2 = createTestFlow(tn, "f35", "5");
463 tf3 = createTestFlow(tn, "f36", "6");
467 tf = createTestFlow(tn, "f42", "42");
468 tf1 = createTestFlow(tn, "f43", "43");
469 tf2 = createTestFlow(tn, "f44", "44");
470 tf3 = createTestFlow(tn, "f45", "45");
473 writeFlow(ci, tf, tf1, tf2, tf3, tn);
476 private static InstanceIdentifier<Node> nodeBuilderToInstanceId(final NodeBuilder node) {
477 return InstanceIdentifier.create(Nodes.class).child(Node.class, node.key());
480 @SuppressWarnings("checkstyle:MethodName")
481 public void _modifyFlows(final CommandInterpreter ci) {
482 NodeBuilder tn = createTestNode(ci.nextArgument());
483 String flowtype = ci.nextArgument();
484 Integer flowcnt = Integer.parseInt(flowtype);
491 tf = createTestFlow(tn, "f82", "10");
492 tf1 = createTestFlow(tn, "f83", "11");
493 tf2 = createTestFlow(tn, "f84", "12");
494 tf3 = createTestFlow(tn, "f85", "13");
497 tf = createTestFlow(tn, "f700", "3");
498 tf1 = createTestFlow(tn, "f4", "4");
499 tf2 = createTestFlow(tn, "f900", "5");
500 tf3 = createTestFlow(tn, "f86", "6");
504 tf = createTestFlow(tn, "f91", "7");
505 tf1 = createTestFlow(tn, "f92", "8");
506 tf2 = createTestFlow(tn, "f93", "9");
507 tf3 = createTestFlow(tn, "f94", "10");
511 tf = createTestFlow(tn, "f230", "3");
512 tf1 = createTestFlow(tn, "f99", "4");
513 tf2 = createTestFlow(tn, "f100", "5");
514 tf3 = createTestFlow(tn, "f101", "6");
518 tf = createTestFlow(tn, "f23", "3");
519 tf1 = createTestFlow(tn, "f99", "4");
520 tf2 = createTestFlow(tn, "f100", "5");
521 tf3 = createTestFlow(tn, "f101", "6");
525 tf = createTestFlow(tn, "f87", "12");
526 tf1 = createTestFlow(tn, "f88", "13");
527 tf2 = createTestFlow(tn, "f89", "14");
528 tf3 = createTestFlow(tn, "f90", "15");
532 writeFlow(ci, tf, tf1, tf2, tf3, tn);
535 @SuppressWarnings("checkstyle:MethodName")
536 public void _removeFlows(final CommandInterpreter ci) {
537 ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
538 NodeBuilder tn = createTestNode(ci.nextArgument());
539 String flowtype = ci.nextArgument();
540 Integer flowcnt = Integer.parseInt(flowtype);
541 FlowBuilder tf = null;
542 FlowBuilder tf1 = null;
543 FlowBuilder tf2 = null;
544 FlowBuilder tf3 = null;
548 tf = createTestFlow(tn, "f1", "10");
549 tf1 = createTestFlow(tn, "f2", "11");
550 tf2 = createTestFlow(tn, "f3", "12");
551 tf3 = createTestFlow(tn, "f4", "13");
555 tf = createTestFlow(tn, "f82", "10");
556 tf1 = createTestFlow(tn, "f83", "11");
557 tf2 = createTestFlow(tn, "f84", "12");
558 tf3 = createTestFlow(tn, "f85", "13");
562 tf = createTestFlow(tn, "f3", "3");
563 tf1 = createTestFlow(tn, "f4", "4");
564 tf2 = createTestFlow(tn, "f5", "5");
565 tf3 = createTestFlow(tn, "f6", "6");
569 tf = createTestFlow(tn, "f700", "3");
570 tf1 = createTestFlow(tn, "f4", "4");
571 tf2 = createTestFlow(tn, "f900", "5");
572 tf3 = createTestFlow(tn, "f86", "6");
576 tf = createTestFlow(tn, "f7", "7");
577 tf1 = createTestFlow(tn, "f8", "8");
578 tf2 = createTestFlow(tn, "f9", "9");
579 tf3 = createTestFlow(tn, "f10", "10");
583 tf = createTestFlow(tn, "f91", "7");
584 tf1 = createTestFlow(tn, "f92", "8");
585 tf2 = createTestFlow(tn, "f93", "9");
586 tf3 = createTestFlow(tn, "f94", "10");
590 tf = createTestFlow(tn, "f23", "3");
591 tf1 = createTestFlow(tn, "f34", "4");
592 tf2 = createTestFlow(tn, "f35", "5");
593 tf3 = createTestFlow(tn, "f36", "6");
598 tf = createTestFlow(tn, "f23", "3");
599 tf1 = createTestFlow(tn, "f99", "4");
600 tf2 = createTestFlow(tn, "f100", "5");
601 tf3 = createTestFlow(tn, "f101", "6");
605 tf = createTestFlow(tn, "f700", "7");
606 tf1 = createTestFlow(tn, "f230", "23");
607 tf2 = createTestFlow(tn, "f900", "9");
608 tf3 = createTestFlow(tn, "f1000", "10");
611 throw new IllegalArgumentException("Invalid flowtype: " + flowtype);
614 InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.key())
615 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
616 .child(Flow.class, tf.key());
617 modification.delete(LogicalDatastoreType.OPERATIONAL, path1);
618 modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
619 modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
620 InstanceIdentifier<Flow> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.key())
621 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf1.getTableId()))
622 .child(Flow.class, tf1.key());
623 modification.delete(LogicalDatastoreType.OPERATIONAL, path2);
624 modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
625 modification.delete(LogicalDatastoreType.CONFIGURATION, path2);
627 InstanceIdentifier<Flow> path3 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.key())
628 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf2.getTableId()))
629 .child(Flow.class, tf2.key());
630 modification.delete(LogicalDatastoreType.OPERATIONAL, path3);
631 modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
632 modification.delete(LogicalDatastoreType.CONFIGURATION, path3);
633 InstanceIdentifier<Flow> path4 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.key())
634 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf3.getTableId()))
635 .child(Flow.class, tf3.key());
636 modification.delete(LogicalDatastoreType.OPERATIONAL, path4);
637 modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
638 modification.delete(LogicalDatastoreType.CONFIGURATION, path4);
639 modification.commit().addCallback(new FutureCallback<CommitInfo>() {
641 public void onSuccess(final CommitInfo notUsed) {
642 ci.println("Status of Group Data Loaded Transaction: success.");
646 public void onFailure(final Throwable throwable) {
647 LOG.error("Status of Group Data Loaded Transaction : failure.", throwable);
648 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
650 }, MoreExecutors.directExecutor());
654 private void writeFlow(final CommandInterpreter ci, final FlowBuilder flow, final FlowBuilder flow1,
655 final FlowBuilder flow2, final FlowBuilder flow3, final NodeBuilder nodeBuilder) {
656 ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
657 InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
658 .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class)
659 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.key());
660 modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder),
661 nodeBuilder.build());
662 modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path1, flow.build());
663 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder),
664 nodeBuilder.build());
665 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, flow.build());
666 InstanceIdentifier<Flow> path2 = InstanceIdentifier.create(Nodes.class)
667 .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class)
668 .child(Table.class, new TableKey(flow1.getTableId())).child(Flow.class, flow1.key());
669 modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder),
670 nodeBuilder.build());
671 modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path2, flow1.build());
672 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder),
673 nodeBuilder.build());
674 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path2, flow1.build());
676 InstanceIdentifier<Flow> path3 = InstanceIdentifier.create(Nodes.class)
677 .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class)
678 .child(Table.class, new TableKey(flow2.getTableId())).child(Flow.class, flow2.key());
679 modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder),
680 nodeBuilder.build());
681 modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path3, flow2.build());
682 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder),
683 nodeBuilder.build());
684 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path3, flow2.build());
686 InstanceIdentifier<Flow> path4 = InstanceIdentifier.create(Nodes.class)
687 .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class)
688 .child(Table.class, new TableKey(flow3.getTableId())).child(Flow.class, flow3.key());
689 modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder),
690 nodeBuilder.build());
691 modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path4, flow3.build());
692 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder),
693 nodeBuilder.build());
694 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path4, flow3.build());
695 modification.commit().addCallback(new FutureCallback<CommitInfo>() {
697 public void onSuccess(final CommitInfo notUsed) {
698 ci.println("Status of Group Data Loaded Transaction: success.");
702 public void onFailure(final Throwable throwable) {
703 LOG.error("Status of Group Data Loaded Transaction : failure.", throwable);
704 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
706 }, MoreExecutors.directExecutor());
709 private static InstructionsBuilder createDecNwTtlInstructions() {
710 return new InstructionsBuilder()
711 .setInstruction(BindingMap.of(new InstructionBuilder()
713 .setInstruction(new ApplyActionsCaseBuilder()
714 .setApplyActions(new ApplyActionsBuilder()
715 .setAction(BindingMap.of(new ActionBuilder()
716 .setAction(new DecNwTtlCaseBuilder().setDecNwTtl(new DecNwTtlBuilder().build()).build())
723 private static InstructionsBuilder createMeterInstructions() {
724 return new InstructionsBuilder()
725 .setInstruction(BindingMap.of(new InstructionBuilder()
727 .setInstruction(new MeterCaseBuilder()
728 .setMeter(new MeterBuilder().setMeterId(new MeterId(Uint32.ONE)).build())
733 private static InstructionsBuilder createGotoTableInstructions() {
734 return new InstructionsBuilder()
735 .setInstruction(BindingMap.of(new InstructionBuilder()
737 .setInstruction(new GoToTableCaseBuilder()
738 .setGoToTable(new GoToTableBuilder().setTableId(Uint8.TWO).build())
743 private static InstructionsBuilder createDropInstructions() {
744 return new InstructionsBuilder()
745 .setInstruction(BindingMap.of(new InstructionBuilder()
747 .setInstruction(new ApplyActionsCaseBuilder()
748 .setApplyActions(new ApplyActionsBuilder()
749 .setAction(BindingMap.of(new ActionBuilder()
750 .setAction(new DropActionCaseBuilder()
751 .setDropAction(new DropActionBuilder().build())
759 private static InstructionsBuilder createAppyActionInstruction() {
760 return new InstructionsBuilder()
761 .setInstruction(BindingMap.of(new InstructionBuilder()
763 .setInstruction(new ApplyActionsCaseBuilder()
764 .setApplyActions(new ApplyActionsBuilder()
765 .setAction(BindingMap.of(new ActionBuilder()
766 .setAction(new ControllerActionCaseBuilder()
767 .setControllerAction(new ControllerActionBuilder()
768 .setMaxLength(Uint16.valueOf(5))
777 private static InstructionsBuilder createSentToControllerInstructions() {
778 return new InstructionsBuilder()
779 .setInstruction(BindingMap.of(new InstructionBuilder()
781 .setInstruction(new ApplyActionsCaseBuilder()
782 .setApplyActions(new ApplyActionsBuilder()
783 .setAction(BindingMap.of(new ActionBuilder()
785 .setAction(new OutputActionCaseBuilder()
786 .setOutputAction(new OutputActionBuilder()
787 .setMaxLength(Uint16.MAX_VALUE)
788 .setOutputNodeConnector(new Uri(OutputPortValues.CONTROLLER.toString()))
797 private static InstructionsBuilder createAppyActionInstruction2() {
799 List<Action> actionList = new ArrayList<>();
800 ActionBuilder ab = new ActionBuilder();
802 PushMplsActionBuilder push = new PushMplsActionBuilder();
803 push.setEthernetType(Uint16.valueOf(0x8847));
804 ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
805 actionList.add(ab.build());
806 // Create an Apply Action
807 ApplyActionsBuilder aab = new ApplyActionsBuilder();
808 aab.setAction(actionList);
810 // Wrap our Apply Action in an Instruction
811 InstructionBuilder ib = new InstructionBuilder();
812 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
814 // Put our Instruction in a list of Instructions
815 InstructionsBuilder isb = new InstructionsBuilder();
816 List<Instruction> instructions = new ArrayList<>();
817 instructions.add(ib.build());
818 isb.setInstruction(instructions);
822 private static InstructionsBuilder createAppyActionInstruction3() {
824 List<Action> actionList = new ArrayList<>();
825 ActionBuilder ab = new ActionBuilder();
827 PushPbbActionBuilder pbb = new PushPbbActionBuilder();
828 pbb.setEthernetType(Uint16.valueOf(0x88E7));
829 ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
830 actionList.add(ab.build());
831 // Create an Apply Action
832 ApplyActionsBuilder aab = new ApplyActionsBuilder();
833 aab.setAction(actionList);
835 // Wrap our Apply Action in an Instruction
836 InstructionBuilder ib = new InstructionBuilder();
837 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
839 // Put our Instruction in a list of Instructions
840 InstructionsBuilder isb = new InstructionsBuilder();
841 List<Instruction> instructions = new ArrayList<>();
842 instructions.add(ib.build());
843 isb.setInstruction(instructions);
847 private static InstructionsBuilder createAppyActionInstruction6() {
849 List<Action> actionList = new ArrayList<>();
850 ActionBuilder ab = new ActionBuilder();
852 SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
853 src.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
854 ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(src.build()).build());
855 actionList.add(ab.build());
857 // Create an Apply Action
858 ApplyActionsBuilder aab = new ApplyActionsBuilder();
859 aab.setAction(actionList);
861 // Wrap our Apply Action in an Instruction
862 InstructionBuilder ib = new InstructionBuilder();
863 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
865 // Put our Instruction in a list of Instructions
866 InstructionsBuilder isb = new InstructionsBuilder();
867 List<Instruction> instructions = new ArrayList<>();
868 instructions.add(ib.build());
869 isb.setInstruction(instructions);
873 private static InstructionsBuilder createAppyActionInstruction7() {
875 List<Action> actionList = new ArrayList<>();
876 ActionBuilder ab = new ActionBuilder();
878 SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
879 VlanId vlanId = new VlanId(Uint16.valueOf(4012));
880 vl.setVlanId(vlanId);
881 ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
882 actionList.add(ab.build());
883 // Create an Apply Action
884 ApplyActionsBuilder aab = new ApplyActionsBuilder();
885 aab.setAction(actionList);
887 // Wrap our Apply Action in an Instruction
888 InstructionBuilder ib = new InstructionBuilder();
889 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
891 // Put our Instruction in a list of Instructions
892 InstructionsBuilder isb = new InstructionsBuilder();
893 List<Instruction> instructions = new ArrayList<>();
894 instructions.add(ib.build());
895 isb.setInstruction(instructions);
899 private static InstructionsBuilder createAppyActionInstruction8() {
901 List<Action> actionList = new ArrayList<>();
902 ActionBuilder ab = new ActionBuilder();
904 SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
905 VlanPcp pcp1 = new VlanPcp(Uint8.TWO);
906 pcp.setVlanPcp(pcp1);
907 ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
908 actionList.add(ab.build());
909 // Create an Apply Action
910 ApplyActionsBuilder aab = new ApplyActionsBuilder();
911 aab.setAction(actionList);
913 // Wrap our Apply Action in an Instruction
914 InstructionBuilder ib = new InstructionBuilder();
915 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
917 // Put our Instruction in a list of Instructions
918 InstructionsBuilder isb = new InstructionsBuilder();
919 List<Instruction> instructions = new ArrayList<>();
920 instructions.add(ib.build());
921 isb.setInstruction(instructions);
925 private static InstructionsBuilder createAppyActionInstruction9() {
927 List<Action> actionList = new ArrayList<>();
928 ActionBuilder ab = new ActionBuilder();
930 CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
931 ab.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
932 actionList.add(ab.build());
933 // Create an Apply Action
934 ApplyActionsBuilder aab = new ApplyActionsBuilder();
935 aab.setAction(actionList);
937 // Wrap our Apply Action in an Instruction
938 InstructionBuilder ib = new InstructionBuilder();
939 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
941 // Put our Instruction in a list of Instructions
942 InstructionsBuilder isb = new InstructionsBuilder();
943 List<Instruction> instructions = new ArrayList<>();
944 instructions.add(ib.build());
945 isb.setInstruction(instructions);
949 private static InstructionsBuilder createAppyActionInstruction16() {
950 ActionBuilder ab = new ActionBuilder();
952 GroupActionBuilder groupActionB = new GroupActionBuilder();
953 groupActionB.setGroupId(Uint32.ONE);
954 groupActionB.setGroup("0");
955 ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
957 List<Action> actionList = new ArrayList<>();
958 actionList.add(ab.build());
960 // Create an Apply Action
961 ApplyActionsBuilder aab = new ApplyActionsBuilder();
962 aab.setAction(actionList);
964 // Wrap our Apply Action in an Instruction
965 InstructionBuilder ib = new InstructionBuilder();
966 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
968 // Put our Instruction in a list of Instructions
969 InstructionsBuilder isb = new InstructionsBuilder();
970 List<Instruction> instructions = new ArrayList<>();
971 instructions.add(ib.build());
972 isb.setInstruction(instructions);
976 private static InstructionsBuilder createAppyActionInstruction160() {
978 List<Action> actionList = new ArrayList<>();
979 ActionBuilder ab = new ActionBuilder();
981 FloodAllActionBuilder fldall = new FloodAllActionBuilder();
982 ab.setAction(new FloodAllActionCaseBuilder().setFloodAllAction(fldall.build()).build());
983 actionList.add(ab.build());
984 // Create an Apply Action
985 ApplyActionsBuilder aab = new ApplyActionsBuilder();
986 aab.setAction(actionList);
988 // Wrap our Apply Action in an Instruction
989 InstructionBuilder ib = new InstructionBuilder();
990 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
992 // Put our Instruction in a list of Instructions
993 InstructionsBuilder isb = new InstructionsBuilder();
994 List<Instruction> instructions = new ArrayList<>();
995 instructions.add(ib.build());
996 isb.setInstruction(instructions);
1000 private static InstructionsBuilder createAppyActionInstruction26() {
1001 ActionBuilder ab = new ActionBuilder();
1003 SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
1004 Ipv4Builder ipdst = new Ipv4Builder();
1005 Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
1006 ipdst.setIpv4Address(prefixdst);
1007 setNwDstActionBuilder.setAddress(ipdst.build());
1008 ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
1010 List<Action> actionList = new ArrayList<>();
1011 actionList.add(ab.build());
1013 // Create an Apply Action
1014 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1015 aab.setAction(actionList);
1017 // Wrap our Apply Action in an Instruction
1018 InstructionBuilder ib = new InstructionBuilder();
1019 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1021 // Put our Instruction in a list of Instructions
1022 InstructionsBuilder isb = new InstructionsBuilder();
1023 List<Instruction> instructions = new ArrayList<>();
1024 instructions.add(ib.build());
1025 isb.setInstruction(instructions);
1029 private static InstructionsBuilder createAppyActionInstruction27() {
1030 ActionBuilder ab = new ActionBuilder();
1032 SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
1033 Ipv4Builder ipsrc = new Ipv4Builder();
1034 Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
1035 ipsrc.setIpv4Address(prefixsrc);
1036 setNwsrcActionBuilder.setAddress(ipsrc.build());
1037 ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
1039 List<Action> actionList = new ArrayList<>();
1040 actionList.add(ab.build());
1042 // Create an Apply Action
1043 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1044 aab.setAction(actionList);
1046 // Wrap our Apply Action in an Instruction
1047 InstructionBuilder ib = new InstructionBuilder();
1048 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1050 // Put our Instruction in a list of Instructions
1051 InstructionsBuilder isb = new InstructionsBuilder();
1052 List<Instruction> instructions = new ArrayList<>();
1053 instructions.add(ib.build());
1054 isb.setInstruction(instructions);
1058 private static InstructionsBuilder createAppyActionInstruction28() {
1060 List<Action> actionList = new ArrayList<>();
1061 ActionBuilder ab = new ActionBuilder();
1063 SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
1064 setNwTosActionBuilder.setTos(8);
1065 ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.build()).build());
1066 actionList.add(ab.build());
1067 // Create an Apply Action
1068 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1069 aab.setAction(actionList);
1071 // Wrap our Apply Action in an Instruction
1072 InstructionBuilder ib = new InstructionBuilder();
1073 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1075 // Put our Instruction in a list of Instructions
1076 InstructionsBuilder isb = new InstructionsBuilder();
1077 List<Instruction> instructions = new ArrayList<>();
1078 instructions.add(ib.build());
1079 isb.setInstruction(instructions);
1083 private static InstructionsBuilder createAppyActionInstruction34() {
1085 List<Action> actionList = new ArrayList<>();
1086 ActionBuilder ab = new ActionBuilder();
1088 SwPathActionBuilder swPathAction = new SwPathActionBuilder();
1089 ab.setAction(new SwPathActionCaseBuilder().setSwPathAction(swPathAction.build()).build());
1090 actionList.add(ab.build());
1092 // Create an Apply Action
1093 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1094 aab.setAction(actionList);
1096 // Wrap our Apply Action in an Instruction
1097 InstructionBuilder ib = new InstructionBuilder();
1098 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1100 // Put our Instruction in a list of Instructions
1101 InstructionsBuilder isb = new InstructionsBuilder();
1102 List<Instruction> instructions = new ArrayList<>();
1103 instructions.add(ib.build());
1104 isb.setInstruction(instructions);
1108 private static MatchBuilder createLLDPMatch() {
1109 return new MatchBuilder()
1110 .setEthernetMatch(new EthernetMatchBuilder()
1111 .setEthernetType(new EthernetTypeBuilder().setType(new EtherType(Uint32.valueOf(0x88cc))).build())
1115 private static MatchBuilder createMatch1() {
1116 return new MatchBuilder()
1117 .setLayer3Match(new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix("10.0.0.1/24")).build())
1118 .setEthernetMatch(new EthernetMatchBuilder()
1119 .setEthernetType(new EthernetTypeBuilder().setType(new EtherType(Uint32.valueOf(0x0800))).build())
1123 private static MatchBuilder createMatch1000() {
1124 return new MatchBuilder()
1125 .setLayer3Match(new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix("10.1.1.1/24")).build())
1126 .setEthernetMatch(new EthernetMatchBuilder()
1127 .setEthernetType(new EthernetTypeBuilder().setType(new EtherType(Uint32.valueOf(0x0800))).build())
1131 private static MatchBuilder createMatch2() {
1132 return new MatchBuilder()
1133 .setLayer3Match(new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix("10.0.0.1")).build())
1134 .setEthernetMatch(new EthernetMatchBuilder()
1135 .setEthernetType(new EthernetTypeBuilder().setType(new EtherType(Uint32.valueOf(0x0800))).build())
1139 private static MatchBuilder createMatch3() {
1140 return new MatchBuilder()
1141 .setEthernetMatch(new EthernetMatchBuilder()
1142 .setEthernetSource(new EthernetSourceBuilder().setAddress(new MacAddress("00:00:00:00:00:01")).build())
1146 private static MatchBuilder createInphyportMatch(final NodeId nodeId) {
1147 return new MatchBuilder()
1148 .setInPort(new NodeConnectorId(nodeId + ":202"))
1149 .setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
1152 private static MatchBuilder createEthernetMatch() {
1153 return new MatchBuilder()
1154 .setEthernetMatch(new EthernetMatchBuilder()
1155 .setEthernetType(new EthernetTypeBuilder().setType(new EtherType(Uint32.valueOf(0x0800))).build())
1156 .setEthernetDestination(new EthernetDestinationBuilder()
1157 .setAddress(new MacAddress("ff:ff:ff:ff:ff:ff"))
1160 .setEthernetSource(new EthernetSourceBuilder()
1161 .setAddress(new MacAddress("00:00:00:00:23:ae"))
1167 private static MatchBuilder createL3IPv6Match() {
1168 return new MatchBuilder()
1169 .setEthernetMatch(new EthernetMatchBuilder()
1170 .setEthernetType(new EthernetTypeBuilder().setType(new EtherType(Uint32.valueOf(0x86dd))).build())
1173 .setIcmpv6Match(new Icmpv6MatchBuilder()
1174 .setIcmpv6Type(Uint8.valueOf(135))
1175 .setIcmpv6Code(Uint8.ZERO)
1177 .setLayer3Match(new Ipv6MatchBuilder()
1178 // .setIpv6Source(srcip6)
1179 // .setIpv6Destination(dstip6)
1180 // .setIpv6ExtHeader(nextheader.build())
1181 .setIpv6NdSll(new MacAddress("c2:00:54:f5:00:00"))
1182 .setIpv6NdTll(new MacAddress("00:0c:29:0e:4c:67"))
1183 // .setIpv6NdTarget(ndtarget)
1184 .setIpv6Label(new Ipv6LabelBuilder()
1185 .setIpv6Flabel(new Ipv6FlowLabel(Uint32.valueOf(10028)))
1186 // .setFlabelMask(new byte[] { 0, 1, -1, -1 })
1191 private static MatchBuilder createICMPv6Match() {
1192 return new MatchBuilder()
1193 .setEthernetMatch(new EthernetMatchBuilder()
1194 .setEthernetType(new EthernetTypeBuilder().setType(new EtherType(Uint32.valueOf(0x86dd))).build())
1197 .setIpMatch(new IpMatchBuilder().setIpProtocol(Uint8.valueOf(58)).build())
1199 .setIcmpv6Match(new Icmpv6MatchBuilder()
1200 .setIcmpv6Type(Uint8.valueOf(135))
1201 .setIcmpv6Code(Uint8.ONE)
1205 private static MatchBuilder createMetadataMatch() {
1206 return new MatchBuilder()
1207 .setMetadata(new MetadataBuilder()
1208 .setMetadata(Uint64.valueOf(500))
1209 // .setMetadataMask(metamask)