2 * Copyright (c) 2013, 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
9 package org.opendaylight.openflowplugin.test;
11 import com.google.common.util.concurrent.CheckedFuture;
12 import com.google.common.util.concurrent.FutureCallback;
13 import com.google.common.util.concurrent.Futures;
14 import java.math.BigInteger;
15 import java.util.ArrayList;
16 import java.util.Collection;
17 import java.util.List;
18 import java.util.concurrent.ExecutorService;
19 import java.util.concurrent.Executors;
20 import java.util.concurrent.TimeUnit;
21 import org.eclipse.osgi.framework.console.CommandInterpreter;
22 import org.eclipse.osgi.framework.console.CommandProvider;
23 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
24 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
25 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
26 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
27 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
28 import org.opendaylight.controller.sal.binding.api.NotificationService;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCaseBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCaseBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCaseBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCaseBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCaseBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.action._case.FloodActionBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.hw.path.action._case.HwPathActionBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.loopback.action._case.LoopbackActionBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.type.action._case.SetDlTypeActionBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.next.hop.action._case.SetNextHopActionBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.cfi.action._case.SetVlanCfiActionBuilder;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
162 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
163 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
164 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagMatchBuilder;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
167 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
168 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
169 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
170 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
171 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder;
172 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
173 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
174 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
175 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
176 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
177 import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.NodeErrorListener;
178 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
179 import org.osgi.framework.BundleContext;
180 import org.slf4j.Logger;
181 import org.slf4j.LoggerFactory;
183 public class OpenflowpluginTestCommandProvider implements CommandProvider {
185 private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
187 private DataBroker dataBroker;
188 private final BundleContext ctx;
189 private FlowBuilder testFlow;
190 private static final String ORIGINAL_FLOW_NAME = "Foo";
191 private static final String UPDATED_FLOW_NAME = "Bar";
192 private static final String IPV4_PREFIX = "10.0.0.1/24";
193 private static final String DEST_MAC_ADDRESS = "ff:ff:ff:ff:ff:ff";
194 private static final String SRC_MAC_ADDRESS = "00:00:00:00:23:ae";
195 private final SalFlowListener flowEventListener = new FlowEventListenerLoggingImpl();
196 private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl();
197 private static NotificationService notificationService;
199 public OpenflowpluginTestCommandProvider(final BundleContext ctx) {
203 public void onSessionInitiated(final ProviderContext session) {
204 notificationService = session.getSALService(NotificationService.class);
206 notificationService.registerNotificationListener(flowEventListener);
207 notificationService.registerNotificationListener(nodeErrorListener);
208 dataBroker = session.getSALService(DataBroker.class);
209 ctx.registerService(CommandProvider.class.getName(), this, null);
210 createTestFlow(createTestNode(null), null, null);
213 private NodeBuilder createTestNode(final String nodeId) {
216 if (nodeId == null) {
217 localNodeId = OpenflowpluginTestActivator.NODE_ID;
219 localNodeId = nodeId;
222 final NodeBuilder builder = new NodeBuilder();
223 builder.setId(new NodeId(localNodeId));
224 builder.setKey(new NodeKey(builder.getId()));
228 private InstanceIdentifier<Node> nodeBuilderToInstanceId(final NodeBuilder node) {
229 return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
232 private FlowBuilder createTestFlow(final NodeBuilder nodeBuilder, final String flowTypeArg, final String tableId) {
233 final long TEST_ID = 123;
235 final FlowBuilder flow = new FlowBuilder();
238 String flowType = flowTypeArg;
239 if (flowType == null) {
248 flow.setMatch(createMatch1().build());
249 flow.setInstructions(createDecNwTtlInstructions().build());
253 flow.setMatch(createMatch2().build());
254 flow.setInstructions(createDropInstructions().build());
258 flow.setMatch(createMatch3().build());
259 flow.setInstructions(createDropInstructions().build());
263 flow.setMatch(createEthernetMatch().build());
264 flow.setInstructions(createDropInstructions().build());
268 flow.setMatch(createMatch1().build());
269 flow.setInstructions(createAppyActionInstruction().build());
273 flow.setMatch(createMatch1().build());
274 flow.setInstructions(createGotoTableInstructions().build());
278 flow.setMatch(createMatch1().build());
279 flow.setInstructions(createMeterInstructions().build());
283 flow.setMatch(createMatch1().build());
284 flow.setInstructions(createAppyActionInstruction1().build());
288 flow.setMatch(createMatch1().build());
289 flow.setInstructions(createAppyActionInstruction2().build());
293 flow.setMatch(createMatch1().build());
294 flow.setInstructions(createAppyActionInstruction3().build());
298 flow.setMatch(createMatch1().build());
299 flow.setInstructions(createAppyActionInstruction4().build());
303 flow.setMatch(createMatch1().build());
304 flow.setInstructions(createAppyActionInstruction5().build());
308 flow.setMatch(createMatch1().build());
309 flow.setInstructions(createAppyActionInstruction6().build());
313 flow.setMatch(createMatch1().build());
314 flow.setInstructions(createAppyActionInstruction7().build());
318 flow.setMatch(createMatch1().build());
319 flow.setInstructions(createAppyActionInstruction8().build());
323 flow.setMatch(createMatch1().build());
324 flow.setInstructions(createAppyActionInstruction9().build());
328 flow.setMatch(createMatch1().build());
329 flow.setInstructions(createAppyActionInstruction10().build());
333 flow.setMatch(createMatch1().build());
334 flow.setInstructions(createAppyActionInstruction11().build());
338 flow.setMatch(createMatch1().build());
339 flow.setInstructions(createAppyActionInstruction12().build());
343 flow.setMatch(createMatch1().build());
344 flow.setInstructions(createAppyActionInstruction13().build());
348 flow.setMatch(createMatch1().build());
349 flow.setInstructions(createAppyActionInstruction14().build());
353 flow.setMatch(createMatch1().build());
354 flow.setInstructions(createAppyActionInstruction15().build());
358 // f23 can be used as test-case for generating error notification
359 // if the particular group is not configured - tested
360 flow.setMatch(createMatch1().build());
361 flow.setInstructions(createAppyActionInstruction16().build());
365 flow.setMatch(createMatch1().build());
366 flow.setInstructions(createAppyActionInstruction17().build());
370 flow.setMatch(createMatch1().build());
371 flow.setInstructions(createAppyActionInstruction18().build());
375 flow.setMatch(createMatch1().build());
376 flow.setInstructions(createAppyActionInstruction19().build());
380 flow.setMatch(createMatch1().build());
381 flow.setInstructions(createMetadataInstructions().build());
385 flow.setMatch(createMatch1().build());
386 flow.setInstructions(createAppyActionInstruction20().build());
390 flow.setMatch(createMatch1().build());
391 flow.setInstructions(createAppyActionInstruction21().build());
395 flow.setMatch(createMatch1().build());
396 flow.setInstructions(createAppyActionInstruction22().build());
400 flow.setMatch(createMatch1().build());
401 flow.setInstructions(createAppyActionInstruction23(nodeBuilder.getId()).build());
405 flow.setMatch(createMatch1().build());
406 flow.setInstructions(createAppyActionInstruction24().build());
410 flow.setMatch(createMatch1().build());
411 flow.setInstructions(createAppyActionInstruction25().build());
415 flow.setMatch(createMatch1().build());
416 flow.setInstructions(createAppyActionInstruction26().build());
420 flow.setMatch(createMatch1().build());
421 flow.setInstructions(createAppyActionInstruction27().build());
425 flow.setMatch(createMatch1().build());
426 flow.setInstructions(createAppyActionInstruction28().build());
430 flow.setMatch(createMatch1().build());
431 flow.setInstructions(createAppyActionInstruction29().build());
435 flow.setMatch(createMatch1().build());
436 flow.setInstructions(createAppyActionInstruction30().build());
440 flow.setMatch(createMatch1().build());
441 flow.setInstructions(createAppyActionInstruction31().build());
445 flow.setMatch(createMatch1().build());
446 flow.setInstructions(createAppyActionInstruction32().build());
450 flow.setMatch(createMatch1().build());
451 flow.setInstructions(createAppyActionInstruction33().build());
455 flow.setMatch(createMatch1().build());
456 flow.setInstructions(createAppyActionInstruction34().build());
460 flow.setMatch(createICMPv6Match().build());
461 flow.setInstructions(createDecNwTtlInstructions().build());
465 flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
466 flow.setInstructions(createDropInstructions().build());
470 flow.setMatch(createMetadataMatch().build());
471 flow.setInstructions(createDropInstructions().build());
475 flow.setMatch(createL3IPv6Match().build());
476 flow.setInstructions(createDecNwTtlInstructions().build());
480 flow.setMatch(createL4SCTPMatch().build());
481 flow.setInstructions(createAppyActionInstruction().build());
485 flow.setMatch(createTunnelIDMatch().build());
486 flow.setInstructions(createGotoTableInstructions().build());
490 flow.setMatch(createVlanMatch().build());
491 flow.setInstructions(createMeterInstructions().build());
495 flow.setMatch(createPbbMatch().build());
496 flow.setInstructions(createMeterInstructions().build());
500 flow.setMatch(createVlanMatch().build());
501 flow.setInstructions(createDropInstructions().build());
505 flow.setMatch(createL4TCPMatch().build());
506 flow.setInstructions(createDropInstructions().build());
511 flow.setMatch(createL4UDPMatch().build());
512 flow.setInstructions(createDropInstructions().build());
516 flow.setMatch(new MatchBuilder().build());
517 flow.setInstructions(createSentToControllerInstructions().build());
522 flow.setMatch(createToSMatch().build());
523 flow.setInstructions(createDropInstructions().build());
527 flow.setMatch(createToSMatch().build());
528 flow.setInstructions(createOutputInstructions("INPORT", 10).build());
532 flow.setMatch(createToSMatch().build());
533 flow.setInstructions(createOutputInstructions("FLOOD", 20).build());
537 flow.setMatch(createToSMatch().build());
538 flow.setInstructions(createOutputInstructions("ALL", 30).build());
542 flow.setMatch(createToSMatch().build());
543 flow.setInstructions(createOutputInstructions("NORMAL", 40).build());
547 flow.setMatch(createToSMatch().build());
548 flow.setInstructions(createOutputInstructions("LOCAL", 50).build());
552 flow.setMatch(createToSMatch().build());
553 flow.setInstructions(createOutputInstructions("TABLE", 60).build());
557 flow.setMatch(createToSMatch().build());
558 flow.setInstructions(createOutputInstructions("NONE", 70).build());
562 flow.setMatch(createToSMatch().build());
563 flow.setInstructions(createStripVlanInstructions().build());
564 flow.setBarrier(Boolean.TRUE);
568 flow.setMatch(createMatch1().build());
569 flow.setInstructions(createAppyActionInstruction35().build());
573 flow.setMatch(createMatch1().build());
574 flow.setInstructions(createAppyActionInstruction36().build());
578 flow.setMatch(createMatch1().build());
579 flow.setInstructions(createAppyActionInstruction37().build());
583 flow.setMatch(createMatch1().build());
584 flow.setInstructions(createAppyActionInstruction38().build());
588 flow.setMatch(createL4TCPMatch().build());
589 flow.setInstructions(createAppyActionInstruction39().build());
593 flow.setMatch(createL4UDPMatch().build());
594 flow.setInstructions(createAppyActionInstruction40().build());
598 flow.setMatch(createL4SCTPMatch().build());
599 flow.setInstructions(createAppyActionInstruction41().build());
603 flow.setMatch(createICMPv4Match().build());
604 flow.setInstructions(createAppyActionInstruction42().build());
608 flow.setMatch(createArpMatch().build());
609 flow.setInstructions(createAppyActionInstruction43().build());
613 flow.setMatch(createL3IPv6Match().build());
614 flow.setInstructions(createAppyActionInstruction44().build());
618 flow.setMatch(createICMPv6Match().build());
619 flow.setInstructions(createAppyActionInstruction45().build());
623 flow.setMatch(createMplsMatch().build());
624 flow.setInstructions(createAppyActionInstruction46().build());
628 flow.setMatch(createPbbMatch().build());
629 flow.setInstructions(createAppyActionInstruction47().build());
633 flow.setMatch(createTunnelIDMatch().build());
634 flow.setInstructions(createAppyActionInstruction48().build());
638 flow.setMatch(createMatch33().build());
639 flow.setInstructions(createDropInstructions().build());
643 flow.setMatch(createICMPv6Match1().build());
644 flow.setInstructions(createDecNwTtlInstructions().build());
648 flow.setMatch(createVlanMatch().build());
649 flow.setInstructions(createAppyActionInstruction88().build());
653 flow.setMatch(createLLDPMatch().build());
654 flow.setInstructions(createSentToControllerInstructions().build());
658 flow.setMatch(createToSMatch().build());
659 flow.setInstructions(createOutputInstructions().build());
662 // Test TCP_Flag Match
664 flow.setMatch(createTcpFlagMatch().build());
665 flow.setInstructions(createDropInstructions().build());
669 // match vlan=10,dl_vlan_pcp=3
670 flow.setMatch(createVlanMatch().build());
672 flow.setInstructions(createAppyActionInstruction88().build());
675 // Test Tunnel IPv4 Src (e.g. set_field:172.16.100.200->tun_src)
677 flow.setMatch(createMatch3().build());
678 flow.setInstructions(createTunnelIpv4SrcInstructions().build());
681 // Test Tunnel IPv4 Dst (e.g. set_field:172.16.100.100->tun_dst)
683 flow.setMatch(createMatch1().build());
684 flow.setInstructions(createTunnelIpv4DstInstructions().build());
687 LOG.warn("flow type not understood: {}", flowType);
690 final FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
691 if (null == flow.isBarrier()) {
692 flow.setBarrier(Boolean.FALSE);
694 final BigInteger value = BigInteger.valueOf(10);
695 flow.setCookie(new FlowCookie(value));
696 flow.setCookieMask(new FlowCookie(value));
697 flow.setHardTimeout(0);
698 flow.setIdleTimeout(0);
699 flow.setInstallHw(false);
700 flow.setStrict(false);
701 flow.setContainerName(null);
702 flow.setFlags(new FlowModFlags(false, false, false, false, true));
703 flow.setId(new FlowId("12"));
704 flow.setTableId(getTableId(tableId));
707 flow.setFlowName(ORIGINAL_FLOW_NAME + "X" + flowType);
713 private FlowBuilder createTestFlowPerfTest(final String flowTypeArg, final String tableId, final int id) {
714 final FlowBuilder flow = new FlowBuilder();
715 String flowType = flowTypeArg;
718 if (flowType == null) {
722 flow.setPriority(flowId);
727 flow.setMatch(createMatch1().build());
728 flow.setInstructions(createDecNwTtlInstructions().build());
731 LOG.warn("flow type not understood: {}", flowType);
734 final FlowKey key = new FlowKey(new FlowId(Long.toString(flowId)));
735 if (null == flow.isBarrier()) {
736 flow.setBarrier(Boolean.FALSE);
738 final BigInteger value = BigInteger.valueOf(10);
739 flow.setCookie(new FlowCookie(value));
740 flow.setCookieMask(new FlowCookie(value));
741 flow.setHardTimeout(0);
742 flow.setIdleTimeout(0);
743 flow.setInstallHw(false);
744 flow.setStrict(false);
745 flow.setContainerName(null);
746 flow.setFlags(new FlowModFlags(false, false, false, false, true));
747 flow.setId(new FlowId("12"));
748 flow.setTableId(getTableId(tableId));
751 flow.setFlowName(ORIGINAL_FLOW_NAME + "X" + flowType);
756 private FlowBuilder createtablemiss() {
757 final FlowBuilder flow = new FlowBuilder();
759 final MatchBuilder matchBuilder = new MatchBuilder();
760 flow.setMatch(matchBuilder.build());
761 flow.setInstructions(createSentToControllerInstructions().build());
763 flow.setTableId((short) 0);
764 final FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
770 private short getTableId(final String tableId) {
771 final short TABLE_ID = 2;
772 short table = TABLE_ID;
774 table = Short.parseShort(tableId);
775 } catch (final Exception ex) {
776 LOG.info("Parsing String tableId {} failed. Continuing with default tableId {}.",
785 private static InstructionsBuilder createDecNwTtlInstructions() {
786 final DecNwTtlBuilder ta = new DecNwTtlBuilder();
787 final DecNwTtl decNwTtl = ta.build();
788 final ActionBuilder ab = new ActionBuilder();
789 ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
790 ab.setKey(new ActionKey(0));
791 // Add our drop action to a list
792 final List<Action> actionList = new ArrayList<Action>();
793 actionList.add(ab.build());
795 // Create an Apply Action
796 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
797 aab.setAction(actionList);
799 // Wrap our Apply Action in an Instruction
800 final InstructionBuilder ib = new InstructionBuilder();
801 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
802 ib.setKey(new InstructionKey(0));
805 // Put our Instruction in a list of Instructions
806 final InstructionsBuilder isb = new InstructionsBuilder();
807 final List<Instruction> instructions = new ArrayList<Instruction>();
808 instructions.add(ib.build());
809 ib.setKey(new InstructionKey(0));
810 isb.setInstruction(instructions);
817 private static InstructionsBuilder createMeterInstructions() {
819 final MeterBuilder aab = new MeterBuilder();
820 aab.setMeterId(new MeterId(1L));
822 final InstructionBuilder ib = new InstructionBuilder();
823 ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
825 // Put our Instruction in a list of Instructions
826 final InstructionsBuilder isb = new InstructionsBuilder();
827 final List<Instruction> instructions = new ArrayList<Instruction>();
828 ib.setKey(new InstructionKey(0));
829 instructions.add(ib.build());
830 isb.setInstruction(instructions);
834 private static InstructionsBuilder createMetadataInstructions() {
836 final WriteMetadataBuilder aab = new WriteMetadataBuilder();
837 aab.setMetadata(BigInteger.valueOf(10));
838 aab.setMetadataMask(BigInteger.valueOf(10));
840 final InstructionBuilder ib = new InstructionBuilder();
841 ib.setInstruction(new WriteMetadataCaseBuilder().setWriteMetadata(aab.build()).build());
843 // Put our Instruction in a list of Instructions
844 final InstructionsBuilder isb = new InstructionsBuilder();
845 final List<Instruction> instructions = new ArrayList<Instruction>();
846 ib.setKey(new InstructionKey(0));
847 instructions.add(ib.build());
848 isb.setInstruction(instructions);
852 private static InstructionsBuilder createGotoTableInstructions() {
854 final GoToTableBuilder aab = new GoToTableBuilder();
855 aab.setTableId((short) 5);
857 final InstructionBuilder ib = new InstructionBuilder();
858 ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
860 // Put our Instruction in a list of Instructions
861 final InstructionsBuilder isb = new InstructionsBuilder();
862 final List<Instruction> instructions = new ArrayList<Instruction>();
863 ib.setKey(new InstructionKey(0));
864 instructions.add(ib.build());
865 isb.setInstruction(instructions);
869 private static InstructionsBuilder createDropInstructions() {
870 final DropActionBuilder dab = new DropActionBuilder();
871 final DropAction dropAction = dab.build();
872 final ActionBuilder ab = new ActionBuilder();
873 ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
874 ab.setKey(new ActionKey(0));
875 // Add our drop action to a list
876 final List<Action> actionList = new ArrayList<Action>();
877 actionList.add(ab.build());
878 ab.setKey(new ActionKey(0));
879 // Create an Apply Action
880 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
881 aab.setAction(actionList);
883 // Wrap our Apply Action in an Instruction
884 final InstructionBuilder ib = new InstructionBuilder();
885 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
887 // Put our Instruction in a list of Instructions
888 final InstructionsBuilder isb = new InstructionsBuilder();
889 final List<Instruction> instructions = new ArrayList<Instruction>();
890 ib.setKey(new InstructionKey(0));
891 instructions.add(ib.build());
892 isb.setInstruction(instructions);
896 private static InstructionsBuilder createAppyActionInstruction() {
898 final List<Action> actionList = new ArrayList<Action>();
899 final ActionBuilder ab = new ActionBuilder();
900 final ControllerActionBuilder controller = new ControllerActionBuilder();
901 controller.setMaxLength(5);
902 ab.setAction(new ControllerActionCaseBuilder().setControllerAction(controller.build()).build());
903 ab.setKey(new ActionKey(0));
904 actionList.add(ab.build());
905 // Create an Apply Action
906 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
907 aab.setAction(actionList);
909 // Wrap our Apply Action in an Instruction
910 final InstructionBuilder ib = new InstructionBuilder();
911 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
913 // Put our Instruction in a list of Instructions
914 final InstructionsBuilder isb = new InstructionsBuilder();
915 final List<Instruction> instructions = new ArrayList<Instruction>();
916 ib.setKey(new InstructionKey(0));
917 instructions.add(ib.build());
918 isb.setInstruction(instructions);
922 private static InstructionsBuilder createAppyActionInstruction1() {
924 final List<Action> actionList = new ArrayList<Action>();
925 final ActionBuilder ab = new ActionBuilder();
927 final OutputActionBuilder output = new OutputActionBuilder();
928 output.setMaxLength(56);
929 final Uri value = new Uri("PCEP");
930 output.setOutputNodeConnector(value);
931 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
932 ab.setKey(new ActionKey(0));
933 actionList.add(ab.build());
934 // Create an Apply Action
935 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
936 aab.setAction(actionList);
938 // Wrap our Apply Action in an Instruction
939 final InstructionBuilder ib = new InstructionBuilder();
940 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
942 // Put our Instruction in a list of Instructions
943 final InstructionsBuilder isb = new InstructionsBuilder();
944 final List<Instruction> instructions = new ArrayList<Instruction>();
945 ib.setKey(new InstructionKey(0));
946 instructions.add(ib.build());
947 isb.setInstruction(instructions);
951 private static InstructionsBuilder createOutputInstructions() {
953 // test case for Output Port works if the particular port exists
954 // this particular test-case is for Port : 1
955 // tested as (addMDFlow openflow:<dpid> f82)
956 final List<Action> actionList = new ArrayList<Action>();
957 final ActionBuilder ab = new ActionBuilder();
958 final OutputActionBuilder output = new OutputActionBuilder();
960 final Uri value = new Uri("1");
961 output.setOutputNodeConnector(value);
962 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
964 ab.setKey(new ActionKey(0));
965 actionList.add(ab.build());
966 // Create an Apply Action
967 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
968 aab.setAction(actionList);
970 // Wrap our Apply Action in an Instruction
971 final InstructionBuilder ib = new InstructionBuilder();
972 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
974 ib.setKey(new InstructionKey(0));
976 // Put our Instruction in a list of Instructions
977 final InstructionsBuilder isb = new InstructionsBuilder();
978 final List<Instruction> instructions = new ArrayList<Instruction>();
979 instructions.add(ib.build());
980 isb.setInstruction(instructions);
984 private static InstructionsBuilder createSentToControllerInstructions() {
985 final List<Action> actionList = new ArrayList<Action>();
986 final ActionBuilder ab = new ActionBuilder();
988 final OutputActionBuilder output = new OutputActionBuilder();
989 output.setMaxLength(Integer.valueOf(0xffff));
990 final Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
991 output.setOutputNodeConnector(value);
992 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
994 ab.setKey(new ActionKey(0));
995 actionList.add(ab.build());
996 // Create an Apply Action
997 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
998 aab.setAction(actionList);
1000 // Wrap our Apply Action in an Instruction
1001 final InstructionBuilder ib = new InstructionBuilder();
1002 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1004 ib.setKey(new InstructionKey(0));
1006 // Put our Instruction in a list of Instructions
1007 final InstructionsBuilder isb = new InstructionsBuilder();
1008 final List<Instruction> instructions = new ArrayList<Instruction>();
1009 instructions.add(ib.build());
1010 isb.setInstruction(instructions);
1014 private static InstructionsBuilder createOutputInstructions(final String outputType, final int outputValue) {
1015 final List<Action> actionList = new ArrayList<Action>();
1016 final ActionBuilder ab = new ActionBuilder();
1018 final OutputActionBuilder output = new OutputActionBuilder();
1019 output.setMaxLength(outputValue);
1020 final Uri value = new Uri(outputType);
1021 output.setOutputNodeConnector(value);
1022 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
1024 ab.setKey(new ActionKey(0));
1025 actionList.add(ab.build());
1026 // Create an Apply Action
1027 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1028 aab.setAction(actionList);
1030 // Wrap our Apply Action in an Instruction
1031 final InstructionBuilder ib = new InstructionBuilder();
1032 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1034 ib.setKey(new InstructionKey(0));
1036 // Put our Instruction in a list of Instructions
1037 final InstructionsBuilder isb = new InstructionsBuilder();
1038 final List<Instruction> instructions = new ArrayList<Instruction>();
1039 instructions.add(ib.build());
1040 isb.setInstruction(instructions);
1044 private static InstructionsBuilder createStripVlanInstructions() {
1045 final List<Action> actionList = new ArrayList<Action>();
1046 final ActionBuilder ab = new ActionBuilder();
1048 final StripVlanActionBuilder stripActionBuilder = new StripVlanActionBuilder();
1049 ab.setAction(new StripVlanActionCaseBuilder().setStripVlanAction(stripActionBuilder.build()).build());
1051 ab.setKey(new ActionKey(0));
1052 actionList.add(ab.build());
1053 // Create an Apply Action
1054 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1055 aab.setAction(actionList);
1057 // Wrap our Apply Action in an Instruction
1058 final InstructionBuilder ib = new InstructionBuilder();
1059 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1061 ib.setKey(new InstructionKey(0));
1063 // Put our Instruction in a list of Instructions
1064 final InstructionsBuilder isb = new InstructionsBuilder();
1065 final List<Instruction> instructions = new ArrayList<Instruction>();
1066 instructions.add(ib.build());
1067 isb.setInstruction(instructions);
1071 private static InstructionsBuilder createAppyActionInstruction2() {
1073 final List<Action> actionList = new ArrayList<Action>();
1074 final ActionBuilder ab = new ActionBuilder();
1076 final PushMplsActionBuilder push = new PushMplsActionBuilder();
1077 push.setEthernetType(Integer.valueOf(0x8847));
1078 ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
1079 ab.setKey(new ActionKey(0));
1080 actionList.add(ab.build());
1081 // Create an Apply Action
1082 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1083 aab.setAction(actionList);
1085 // Wrap our Apply Action in an Instruction
1086 final InstructionBuilder ib = new InstructionBuilder();
1087 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1089 // Put our Instruction in a list of Instructions
1090 final InstructionsBuilder isb = new InstructionsBuilder();
1091 final List<Instruction> instructions = new ArrayList<Instruction>();
1092 ib.setKey(new InstructionKey(0));
1093 instructions.add(ib.build());
1094 isb.setInstruction(instructions);
1098 private static InstructionsBuilder createAppyActionInstruction3() {
1100 final List<Action> actionList = new ArrayList<Action>();
1101 final ActionBuilder ab = new ActionBuilder();
1103 final PushPbbActionBuilder pbb = new PushPbbActionBuilder();
1104 pbb.setEthernetType(Integer.valueOf(0x88E7));
1105 ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
1106 ab.setKey(new ActionKey(0));
1107 actionList.add(ab.build());
1108 // Create an Apply Action
1109 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1110 aab.setAction(actionList);
1112 // Wrap our Apply Action in an Instruction
1113 final InstructionBuilder ib = new InstructionBuilder();
1114 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1116 // Put our Instruction in a list of Instructions
1117 final InstructionsBuilder isb = new InstructionsBuilder();
1118 final List<Instruction> instructions = new ArrayList<Instruction>();
1119 ib.setKey(new InstructionKey(0));
1120 instructions.add(ib.build());
1121 isb.setInstruction(instructions);
1125 private static InstructionsBuilder createAppyActionInstruction4() {
1127 final List<Action> actionList = new ArrayList<Action>();
1128 final ActionBuilder ab = new ActionBuilder();
1130 final PushVlanActionBuilder vlan = new PushVlanActionBuilder();
1131 vlan.setEthernetType(Integer.valueOf(0x8100));
1132 ab.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
1133 ab.setKey(new ActionKey(0));
1134 actionList.add(ab.build());
1136 // Create an Apply Action
1137 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1138 aab.setAction(actionList);
1140 // Wrap our Apply Action in an Instruction
1141 final InstructionBuilder ib = new InstructionBuilder();
1142 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1144 // Put our Instruction in a list of Instructions
1145 final InstructionsBuilder isb = new InstructionsBuilder();
1146 final List<Instruction> instructions = new ArrayList<Instruction>();
1147 ib.setKey(new InstructionKey(0));
1148 instructions.add(ib.build());
1149 isb.setInstruction(instructions);
1153 private static InstructionsBuilder createAppyActionInstruction5() {
1155 final List<Action> actionList = new ArrayList<Action>();
1156 final ActionBuilder ab = new ActionBuilder();
1158 final SetDlDstActionBuilder setdl = new SetDlDstActionBuilder();
1159 setdl.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1160 ab.setAction(new SetDlDstActionCaseBuilder().setSetDlDstAction(setdl.build()).build());
1161 ab.setKey(new ActionKey(0));
1162 actionList.add(ab.build());
1163 // Create an Apply Action
1164 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1165 aab.setAction(actionList);
1167 // Wrap our Apply Action in an Instruction
1168 final InstructionBuilder ib = new InstructionBuilder();
1169 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1171 // Put our Instruction in a list of Instructions
1172 final InstructionsBuilder isb = new InstructionsBuilder();
1173 final List<Instruction> instructions = new ArrayList<Instruction>();
1174 ib.setKey(new InstructionKey(0));
1175 instructions.add(ib.build());
1176 isb.setInstruction(instructions);
1180 private static InstructionsBuilder createAppyActionInstruction6() {
1182 final List<Action> actionList = new ArrayList<Action>();
1183 final ActionBuilder ab = new ActionBuilder();
1185 final SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
1186 src.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1187 ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(src.build()).build());
1188 ab.setKey(new ActionKey(0));
1189 actionList.add(ab.build());
1191 // Create an Apply Action
1192 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1193 aab.setAction(actionList);
1195 // Wrap our Apply Action in an Instruction
1196 final InstructionBuilder ib = new InstructionBuilder();
1197 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1199 // Put our Instruction in a list of Instructions
1200 final InstructionsBuilder isb = new InstructionsBuilder();
1201 final List<Instruction> instructions = new ArrayList<Instruction>();
1202 ib.setKey(new InstructionKey(0));
1203 instructions.add(ib.build());
1204 isb.setInstruction(instructions);
1208 private static InstructionsBuilder createAppyActionInstruction7() {
1210 final List<Action> actionList = new ArrayList<Action>();
1211 final ActionBuilder ab = new ActionBuilder();
1213 final SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
1214 final VlanId a = new VlanId(4000);
1216 ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
1217 ab.setKey(new ActionKey(0));
1218 actionList.add(ab.build());
1219 // Create an Apply Action
1220 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1221 aab.setAction(actionList);
1223 // Wrap our Apply Action in an Instruction
1224 final InstructionBuilder ib = new InstructionBuilder();
1225 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1227 // Put our Instruction in a list of Instructions
1228 final InstructionsBuilder isb = new InstructionsBuilder();
1229 final List<Instruction> instructions = new ArrayList<Instruction>();
1230 ib.setKey(new InstructionKey(0));
1231 instructions.add(ib.build());
1232 isb.setInstruction(instructions);
1236 private static InstructionsBuilder createAppyActionInstruction8() {
1238 final List<Action> actionList = new ArrayList<Action>();
1239 final ActionBuilder ab = new ActionBuilder();
1241 final SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
1242 final VlanPcp pcp1 = new VlanPcp((short) 2);
1243 pcp.setVlanPcp(pcp1);
1244 ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
1245 ab.setKey(new ActionKey(0));
1246 actionList.add(ab.build());
1247 // Create an Apply Action
1248 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1249 aab.setAction(actionList);
1251 // Wrap our Apply Action in an Instruction
1252 final InstructionBuilder ib = new InstructionBuilder();
1253 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1255 // Put our Instruction in a list of Instructions
1256 final InstructionsBuilder isb = new InstructionsBuilder();
1257 final List<Instruction> instructions = new ArrayList<Instruction>();
1258 ib.setKey(new InstructionKey(0));
1259 instructions.add(ib.build());
1260 isb.setInstruction(instructions);
1264 private static InstructionsBuilder createAppyActionInstruction88() {
1266 final List<Action> actionList = new ArrayList<Action>();
1267 final ActionBuilder ab = new ActionBuilder();
1269 final SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
1270 // the code point is a 3-bit(0-7) field representing the frame priority level
1271 final VlanPcp pcp1 = new VlanPcp((short) 4);
1272 pcp.setVlanPcp(pcp1);
1273 ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
1274 ab.setKey(new ActionKey(0));
1275 actionList.add(ab.build());
1276 // Create an Apply Action
1277 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1278 aab.setAction(actionList);
1280 // Wrap our Apply Action in an Instruction
1281 final InstructionBuilder ib = new InstructionBuilder();
1282 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1284 // Put our Instruction in a list of Instructions
1285 final InstructionsBuilder isb = new InstructionsBuilder();
1286 final List<Instruction> instructions = new ArrayList<Instruction>();
1287 ib.setKey(new InstructionKey(0));
1288 instructions.add(ib.build());
1289 isb.setInstruction(instructions);
1293 private static InstructionsBuilder createAppyActionInstruction9() {
1295 final List<Action> actionList = new ArrayList<Action>();
1296 final ActionBuilder ab = new ActionBuilder();
1298 final CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
1299 ab.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
1300 ab.setKey(new ActionKey(0));
1301 actionList.add(ab.build());
1302 // Create an Apply Action
1303 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1304 aab.setAction(actionList);
1306 // Wrap our Apply Action in an Instruction
1307 final InstructionBuilder ib = new InstructionBuilder();
1308 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1310 // Put our Instruction in a list of Instructions
1311 final InstructionsBuilder isb = new InstructionsBuilder();
1312 final List<Instruction> instructions = new ArrayList<Instruction>();
1313 ib.setKey(new InstructionKey(0));
1314 instructions.add(ib.build());
1315 isb.setInstruction(instructions);
1319 private static InstructionsBuilder createAppyActionInstruction10() {
1321 final List<Action> actionList = new ArrayList<Action>();
1322 final ActionBuilder ab = new ActionBuilder();
1324 final CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
1325 ab.setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(ttlout.build()).build());
1326 ab.setKey(new ActionKey(0));
1327 actionList.add(ab.build());
1328 // Create an Apply Action
1329 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1330 aab.setAction(actionList);
1332 // Wrap our Apply Action in an Instruction
1333 final InstructionBuilder ib = new InstructionBuilder();
1334 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1336 // Put our Instruction in a list of Instructions
1337 final InstructionsBuilder isb = new InstructionsBuilder();
1338 final List<Instruction> instructions = new ArrayList<Instruction>();
1339 ib.setKey(new InstructionKey(0));
1340 instructions.add(ib.build());
1341 isb.setInstruction(instructions);
1345 private static InstructionsBuilder createAppyActionInstruction11() {
1347 final List<Action> actionList = new ArrayList<Action>();
1348 final ActionBuilder ab = new ActionBuilder();
1350 final DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
1351 ab.setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(mpls.build()).build());
1352 ab.setKey(new ActionKey(0));
1353 actionList.add(ab.build());
1354 // Create an Apply Action
1355 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1356 aab.setAction(actionList);
1358 // Wrap our Apply Action in an Instruction
1359 final InstructionBuilder ib = new InstructionBuilder();
1360 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1361 ib.setKey(new InstructionKey(0));
1364 // Put our Instruction in a list of Instruction
1365 final InstructionsBuilder isb = new InstructionsBuilder();
1366 final List<Instruction> instructions = new ArrayList<Instruction>();
1367 instructions.add(ib.build());
1368 isb.setInstruction(instructions);
1372 private static InstructionsBuilder createAppyActionInstruction12() {
1374 final List<Action> actionList = new ArrayList<Action>();
1375 final ActionBuilder ab = new ActionBuilder();
1377 final DecNwTtlBuilder nwttl = new DecNwTtlBuilder();
1378 ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(nwttl.build()).build());
1379 ab.setKey(new ActionKey(0));
1380 actionList.add(ab.build());
1382 // Create an Apply Action
1383 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1384 aab.setAction(actionList);
1386 // Wrap our Apply Action in an Instruction
1387 final InstructionBuilder ib = new InstructionBuilder();
1388 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1390 // Put our Instruction in a list of Instructions
1391 final InstructionsBuilder isb = new InstructionsBuilder();
1392 final List<Instruction> instructions = new ArrayList<Instruction>();
1393 ib.setKey(new InstructionKey(0));
1394 instructions.add(ib.build());
1395 isb.setInstruction(instructions);
1399 private static InstructionsBuilder createAppyActionInstruction13() {
1401 final List<Action> actionList = new ArrayList<Action>();
1402 final ActionBuilder ab = new ActionBuilder();
1404 final DropActionBuilder drop = new DropActionBuilder();
1405 ab.setAction(new DropActionCaseBuilder().setDropAction(drop.build()).build());
1406 ab.setKey(new ActionKey(0));
1407 actionList.add(ab.build());
1409 // Create an Apply Action
1410 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1411 aab.setAction(actionList);
1413 // Wrap our Apply Action in an Instruction
1414 final InstructionBuilder ib = new InstructionBuilder();
1415 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1417 // Put our Instruction in a list of Instructions
1418 final InstructionsBuilder isb = new InstructionsBuilder();
1419 final List<Instruction> instructions = new ArrayList<Instruction>();
1420 ib.setKey(new InstructionKey(0));
1421 instructions.add(ib.build());
1422 isb.setInstruction(instructions);
1426 private static InstructionsBuilder createAppyActionInstruction14() {
1428 final List<Action> actionList = new ArrayList<Action>();
1429 final ActionBuilder ab = new ActionBuilder();
1431 final FloodActionBuilder fld = new FloodActionBuilder();
1432 ab.setAction(new FloodActionCaseBuilder().setFloodAction(fld.build()).build());
1433 ab.setKey(new ActionKey(0));
1434 actionList.add(ab.build());
1435 // Create an Apply Action
1436 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1437 aab.setAction(actionList);
1439 // Wrap our Apply Action in an Instruction
1440 final InstructionBuilder ib = new InstructionBuilder();
1441 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1443 // Put our Instruction in a list of Instructions
1444 final InstructionsBuilder isb = new InstructionsBuilder();
1445 final List<Instruction> instructions = new ArrayList<Instruction>();
1446 ib.setKey(new InstructionKey(0));
1447 instructions.add(ib.build());
1448 isb.setInstruction(instructions);
1452 private static InstructionsBuilder createAppyActionInstruction15() {
1454 final List<Action> actionList = new ArrayList<Action>();
1455 final ActionBuilder ab = new ActionBuilder();
1457 final FloodAllActionBuilder fldall = new FloodAllActionBuilder();
1458 ab.setAction(new FloodAllActionCaseBuilder().setFloodAllAction(fldall.build()).build());
1459 ab.setKey(new ActionKey(0));
1460 actionList.add(ab.build());
1461 // Create an Apply Action
1462 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1463 aab.setAction(actionList);
1465 // Wrap our Apply Action in an Instruction
1466 final InstructionBuilder ib = new InstructionBuilder();
1467 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1469 // Put our Instruction in a list of Instructions
1470 final InstructionsBuilder isb = new InstructionsBuilder();
1471 final List<Instruction> instructions = new ArrayList<Instruction>();
1472 ib.setKey(new InstructionKey(0));
1473 instructions.add(ib.build());
1474 isb.setInstruction(instructions);
1478 private static InstructionsBuilder createAppyActionInstruction16() {
1480 final List<Action> actionList = new ArrayList<Action>();
1481 final ActionBuilder ab = new ActionBuilder();
1483 final GroupActionBuilder groupActionB = new GroupActionBuilder();
1484 groupActionB.setGroupId(1L);
1485 groupActionB.setGroup("0");
1486 ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
1487 ab.setKey(new ActionKey(0));
1488 actionList.add(ab.build());
1490 // Create an Apply Action
1491 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1492 aab.setAction(actionList);
1494 // Wrap our Apply Action in an Instruction
1495 final InstructionBuilder ib = new InstructionBuilder();
1496 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1498 // Put our Instruction in a list of Instructions
1499 final InstructionsBuilder isb = new InstructionsBuilder();
1500 final List<Instruction> instructions = new ArrayList<Instruction>();
1501 ib.setKey(new InstructionKey(0));
1502 instructions.add(ib.build());
1503 isb.setInstruction(instructions);
1507 private static InstructionsBuilder createAppyActionInstruction17() {
1509 final List<Action> actionList = new ArrayList<Action>();
1510 final ActionBuilder ab = new ActionBuilder();
1512 final HwPathActionBuilder hwPathB = new HwPathActionBuilder();
1513 ab.setAction(new HwPathActionCaseBuilder().setHwPathAction(hwPathB.build()).build());
1514 ab.setKey(new ActionKey(0));
1515 actionList.add(ab.build());
1516 // Create an Apply Action
1517 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1518 aab.setAction(actionList);
1520 // Wrap our Apply Action in an Instruction
1521 final InstructionBuilder ib = new InstructionBuilder();
1522 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1524 // Put our Instruction in a list of Instructions
1525 final InstructionsBuilder isb = new InstructionsBuilder();
1526 final List<Instruction> instructions = new ArrayList<Instruction>();
1527 ib.setKey(new InstructionKey(0));
1528 instructions.add(ib.build());
1529 isb.setInstruction(instructions);
1533 private static InstructionsBuilder createAppyActionInstruction18() {
1535 final List<Action> actionList = new ArrayList<Action>();
1536 final ActionBuilder ab = new ActionBuilder();
1538 final LoopbackActionBuilder loopbackActionBuilder = new LoopbackActionBuilder();
1539 ab.setAction(new LoopbackActionCaseBuilder().setLoopbackAction(loopbackActionBuilder.build()).build());
1540 ab.setKey(new ActionKey(0));
1541 actionList.add(ab.build());
1543 // Create an Apply Action
1544 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1545 aab.setAction(actionList);
1547 // Wrap our Apply Action in an Instruction
1548 final InstructionBuilder ib = new InstructionBuilder();
1549 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1551 // Put our Instruction in a list of Instructions
1552 final InstructionsBuilder isb = new InstructionsBuilder();
1553 final List<Instruction> instructions = new ArrayList<Instruction>();
1554 ib.setKey(new InstructionKey(0));
1555 instructions.add(ib.build());
1556 isb.setInstruction(instructions);
1560 private static InstructionsBuilder createAppyActionInstruction19() {
1562 final List<Action> actionList = new ArrayList<Action>();
1563 final ActionBuilder ab = new ActionBuilder();
1565 final PopMplsActionBuilder popMplsActionBuilder = new PopMplsActionBuilder();
1566 popMplsActionBuilder.setEthernetType(0XB);
1567 ab.setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsActionBuilder.build()).build());
1568 ab.setKey(new ActionKey(0));
1569 actionList.add(ab.build());
1570 // Create an Apply Action
1571 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1572 aab.setAction(actionList);
1574 // Wrap our Apply Action in an Instruction
1575 final InstructionBuilder ib = new InstructionBuilder();
1576 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1578 // Put our Instruction in a list of Instructions
1579 final InstructionsBuilder isb = new InstructionsBuilder();
1580 final List<Instruction> instructions = new ArrayList<Instruction>();
1581 ib.setKey(new InstructionKey(0));
1582 instructions.add(ib.build());
1583 isb.setInstruction(instructions);
1587 private static InstructionsBuilder createAppyActionInstruction20() {
1589 final List<Action> actionList = new ArrayList<Action>();
1590 final ActionBuilder ab = new ActionBuilder();
1592 final PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
1593 ab.setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPbbActionBuilder.build()).build());
1594 ab.setKey(new ActionKey(0));
1595 actionList.add(ab.build());
1596 // Create an Apply Action
1597 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1598 aab.setAction(actionList);
1600 // Wrap our Apply Action in an Instruction
1601 final InstructionBuilder ib = new InstructionBuilder();
1602 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1604 // Put our Instruction in a list of Instructions
1605 final InstructionsBuilder isb = new InstructionsBuilder();
1606 final List<Instruction> instructions = new ArrayList<Instruction>();
1607 ib.setKey(new InstructionKey(0));
1608 instructions.add(ib.build());
1609 isb.setInstruction(instructions);
1613 private static InstructionsBuilder createAppyActionInstruction21() {
1615 final List<Action> actionList = new ArrayList<Action>();
1616 final ActionBuilder ab = new ActionBuilder();
1618 final PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
1619 ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
1620 ab.setKey(new ActionKey(0));
1621 actionList.add(ab.build());
1623 // Create an Apply Action
1624 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1625 aab.setAction(actionList);
1627 // Wrap our Apply Action in an Instruction
1628 final InstructionBuilder ib = new InstructionBuilder();
1629 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1631 // Put our Instruction in a list of Instructions
1632 final InstructionsBuilder isb = new InstructionsBuilder();
1633 final List<Instruction> instructions = new ArrayList<Instruction>();
1634 ib.setKey(new InstructionKey(0));
1635 instructions.add(ib.build());
1636 isb.setInstruction(instructions);
1640 private static InstructionsBuilder createAppyActionInstruction22() {
1642 final List<Action> actionList = new ArrayList<Action>();
1643 final ActionBuilder ab = new ActionBuilder();
1645 final SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
1646 setDlTypeActionBuilder.setDlType(new EtherType(8L));
1647 ab.setAction(new SetDlTypeActionCaseBuilder().setSetDlTypeAction(setDlTypeActionBuilder.build()).build());
1648 ab.setKey(new ActionKey(0));
1649 actionList.add(ab.build());
1651 // Create an Apply Action
1652 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1653 aab.setAction(actionList);
1655 // Wrap our Apply Action in an Instruction
1656 final InstructionBuilder ib = new InstructionBuilder();
1657 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1659 // Put our Instruction in a list of Instructions
1660 final InstructionsBuilder isb = new InstructionsBuilder();
1661 final List<Instruction> instructions = new ArrayList<Instruction>();
1662 ib.setKey(new InstructionKey(0));
1663 instructions.add(ib.build());
1664 isb.setInstruction(instructions);
1668 private static InstructionsBuilder createAppyActionInstruction23(final NodeId nodeId) {
1670 final List<Action> actionList = new ArrayList<Action>();
1671 final ActionBuilder ab = new ActionBuilder();
1673 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1674 setFieldBuilder.setInPort(new NodeConnectorId(nodeId + ":2"));
1675 ab.setKey(new ActionKey(0));
1676 actionList.add(ab.build());
1678 // Create an Apply Action
1679 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1680 aab.setAction(actionList);
1682 // Wrap our Apply Action in an Instruction
1683 final InstructionBuilder ib = new InstructionBuilder();
1684 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1686 // Put our Instruction in a list of Instructions
1687 final InstructionsBuilder isb = new InstructionsBuilder();
1688 final List<Instruction> instructions = new ArrayList<Instruction>();
1689 ib.setKey(new InstructionKey(0));
1690 instructions.add(ib.build());
1691 isb.setInstruction(instructions);
1695 private static InstructionsBuilder createAppyActionInstruction24() {
1697 final List<Action> actionList = new ArrayList<Action>();
1698 final ActionBuilder ab = new ActionBuilder();
1700 final SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
1701 setMplsTtlActionBuilder.setMplsTtl((short) 0X1);
1702 ab.setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMplsTtlActionBuilder.build()).build());
1703 ab.setKey(new ActionKey(0));
1704 actionList.add(ab.build());
1706 // Create an Apply Action
1707 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1708 aab.setAction(actionList);
1710 // Wrap our Apply Action in an Instruction
1711 final InstructionBuilder ib = new InstructionBuilder();
1712 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1714 // Put our Instruction in a list of Instructions
1715 final InstructionsBuilder isb = new InstructionsBuilder();
1716 final List<Instruction> instructions = new ArrayList<Instruction>();
1717 ib.setKey(new InstructionKey(0));
1718 instructions.add(ib.build());
1719 isb.setInstruction(instructions);
1723 private static InstructionsBuilder createAppyActionInstruction25() {
1725 final List<Action> actionList = new ArrayList<Action>();
1726 final ActionBuilder ab = new ActionBuilder();
1728 final SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
1729 final Ipv4Builder ipnext = new Ipv4Builder();
1730 final Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);
1731 ipnext.setIpv4Address(prefix);
1732 setNextHopActionBuilder.setAddress(ipnext.build());
1733 ab.setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilder.build()).build());
1734 ab.setKey(new ActionKey(0));
1735 actionList.add(ab.build());
1737 // Create an Apply Action
1738 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1739 aab.setAction(actionList);
1741 // Wrap our Apply Action in an Instruction
1742 final InstructionBuilder ib = new InstructionBuilder();
1743 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1745 // Put our Instruction in a list of Instructions
1746 final InstructionsBuilder isb = new InstructionsBuilder();
1747 final List<Instruction> instructions = new ArrayList<Instruction>();
1748 ib.setKey(new InstructionKey(0));
1749 instructions.add(ib.build());
1750 isb.setInstruction(instructions);
1754 private static InstructionsBuilder createAppyActionInstruction26() {
1756 final List<Action> actionList = new ArrayList<Action>();
1757 final ActionBuilder ab = new ActionBuilder();
1759 final SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
1760 final Ipv4Builder ipdst = new Ipv4Builder();
1761 final Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
1762 ipdst.setIpv4Address(prefixdst);
1763 setNwDstActionBuilder.setAddress(ipdst.build());
1764 ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
1765 ab.setKey(new ActionKey(0));
1766 actionList.add(ab.build());
1768 // Create an Apply Action
1769 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1770 aab.setAction(actionList);
1772 // Wrap our Apply Action in an Instruction
1773 final InstructionBuilder ib = new InstructionBuilder();
1774 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1776 // Put our Instruction in a list of Instructions
1777 final InstructionsBuilder isb = new InstructionsBuilder();
1778 final List<Instruction> instructions = new ArrayList<Instruction>();
1779 ib.setKey(new InstructionKey(0));
1780 instructions.add(ib.build());
1781 isb.setInstruction(instructions);
1785 private static InstructionsBuilder createAppyActionInstruction27() {
1787 final List<Action> actionList = new ArrayList<Action>();
1788 final ActionBuilder ab = new ActionBuilder();
1790 final SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
1791 final Ipv4Builder ipsrc = new Ipv4Builder();
1792 final Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
1793 ipsrc.setIpv4Address(prefixsrc);
1794 setNwsrcActionBuilder.setAddress(ipsrc.build());
1795 ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
1796 ab.setKey(new ActionKey(0));
1797 actionList.add(ab.build());
1799 // Create an Apply Action
1800 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1801 aab.setAction(actionList);
1803 // Wrap our Apply Action in an Instruction
1804 final InstructionBuilder ib = new InstructionBuilder();
1805 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1807 // Put our Instruction in a list of Instructions
1808 final InstructionsBuilder isb = new InstructionsBuilder();
1809 final List<Instruction> instructions = new ArrayList<Instruction>();
1810 ib.setKey(new InstructionKey(0));
1811 instructions.add(ib.build());
1812 isb.setInstruction(instructions);
1816 private static InstructionsBuilder createAppyActionInstruction28() {
1818 final List<Action> actionList = new ArrayList<Action>();
1819 final ActionBuilder ab = new ActionBuilder();
1821 final SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
1822 setNwTosActionBuilder.setTos(8);
1823 ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.build()).build());
1824 ab.setKey(new ActionKey(0));
1825 actionList.add(ab.build());
1826 // Create an Apply Action
1827 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1828 aab.setAction(actionList);
1830 // Wrap our Apply Action in an Instruction
1831 final InstructionBuilder ib = new InstructionBuilder();
1832 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1834 // Put our Instruction in a list of Instructions
1835 final InstructionsBuilder isb = new InstructionsBuilder();
1836 final List<Instruction> instructions = new ArrayList<Instruction>();
1837 ib.setKey(new InstructionKey(0));
1838 instructions.add(ib.build());
1839 isb.setInstruction(instructions);
1843 private static InstructionsBuilder createAppyActionInstruction29() {
1845 final List<Action> actionList = new ArrayList<Action>();
1846 final ActionBuilder ab = new ActionBuilder();
1848 final SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
1849 setNwTtlActionBuilder.setNwTtl((short) 1);
1850 ab.setAction(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
1851 ab.setKey(new ActionKey(0));
1852 actionList.add(ab.build());
1854 // Create an Apply Action
1855 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1856 aab.setAction(actionList);
1858 // Wrap our Apply Action in an Instruction
1859 final InstructionBuilder ib = new InstructionBuilder();
1860 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1862 // Put our Instruction in a list of Instructions
1863 final InstructionsBuilder isb = new InstructionsBuilder();
1864 final List<Instruction> instructions = new ArrayList<Instruction>();
1865 ib.setKey(new InstructionKey(0));
1866 instructions.add(ib.build());
1867 isb.setInstruction(instructions);
1871 private static InstructionsBuilder createAppyActionInstruction30() {
1873 final List<Action> actionList = new ArrayList<Action>();
1874 final ActionBuilder ab = new ActionBuilder();
1876 final SetQueueActionBuilder setQueueActionBuilder = new SetQueueActionBuilder();
1877 setQueueActionBuilder.setQueueId(1L);
1878 ab.setAction(new SetQueueActionCaseBuilder().setSetQueueAction(setQueueActionBuilder.build()).build());
1879 ab.setKey(new ActionKey(0));
1880 actionList.add(ab.build());
1881 // Create an Apply Action
1882 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1883 aab.setAction(actionList);
1885 // Wrap our Apply Action in an Instruction
1886 final InstructionBuilder ib = new InstructionBuilder();
1887 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1889 // Put our Instruction in a list of Instructions
1890 final InstructionsBuilder isb = new InstructionsBuilder();
1891 final List<Instruction> instructions = new ArrayList<Instruction>();
1892 ib.setKey(new InstructionKey(0));
1893 instructions.add(ib.build());
1894 isb.setInstruction(instructions);
1898 private static InstructionsBuilder createAppyActionInstruction31() {
1900 final List<Action> actionList = new ArrayList<Action>();
1901 final ActionBuilder ab = new ActionBuilder();
1903 final SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
1904 setTpDstActionBuilder.setPort(new PortNumber(109));
1906 ab.setAction(new SetTpDstActionCaseBuilder().setSetTpDstAction(setTpDstActionBuilder.build()).build());
1907 ab.setKey(new ActionKey(0));
1908 actionList.add(ab.build());
1909 // Create an Apply Action
1910 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1911 aab.setAction(actionList);
1913 // Wrap our Apply Action in an Instruction
1914 final InstructionBuilder ib = new InstructionBuilder();
1915 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1917 // Put our Instruction in a list of Instructions
1918 final InstructionsBuilder isb = new InstructionsBuilder();
1919 final List<Instruction> instructions = new ArrayList<Instruction>();
1920 ib.setKey(new InstructionKey(0));
1921 instructions.add(ib.build());
1922 isb.setInstruction(instructions);
1926 private static InstructionsBuilder createAppyActionInstruction32() {
1928 final List<Action> actionList = new ArrayList<Action>();
1929 final ActionBuilder ab = new ActionBuilder();
1931 final SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
1932 setTpSrcActionBuilder.setPort(new PortNumber(109));
1933 ab.setAction(new SetTpSrcActionCaseBuilder().setSetTpSrcAction(setTpSrcActionBuilder.build()).build());
1934 ab.setKey(new ActionKey(0));
1935 actionList.add(ab.build());
1937 // Create an Apply Action
1938 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1939 aab.setAction(actionList);
1941 // Wrap our Apply Action in an Instruction
1942 final InstructionBuilder ib = new InstructionBuilder();
1943 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1945 // Put our Instruction in a list of Instructions
1946 final InstructionsBuilder isb = new InstructionsBuilder();
1947 final List<Instruction> instructions = new ArrayList<Instruction>();
1948 ib.setKey(new InstructionKey(0));
1949 instructions.add(ib.build());
1950 isb.setInstruction(instructions);
1954 private static InstructionsBuilder createAppyActionInstruction33() {
1956 final List<Action> actionList = new ArrayList<Action>();
1957 final ActionBuilder ab = new ActionBuilder();
1959 final SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
1960 setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(2));
1961 ab.setAction(new SetVlanCfiActionCaseBuilder().setSetVlanCfiAction(setVlanCfiActionBuilder.build()).build());
1962 ab.setKey(new ActionKey(0));
1963 actionList.add(ab.build());
1965 // Create an Apply Action
1966 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1967 aab.setAction(actionList);
1969 // Wrap our Apply Action in an Instruction
1970 final InstructionBuilder ib = new InstructionBuilder();
1971 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1973 // Put our Instruction in a list of Instructions
1974 final InstructionsBuilder isb = new InstructionsBuilder();
1975 final List<Instruction> instructions = new ArrayList<Instruction>();
1976 ib.setKey(new InstructionKey(0));
1977 instructions.add(ib.build());
1978 isb.setInstruction(instructions);
1982 private static InstructionsBuilder createAppyActionInstruction34() {
1984 final List<Action> actionList = new ArrayList<Action>();
1985 final ActionBuilder ab = new ActionBuilder();
1987 final SwPathActionBuilder swPathAction = new SwPathActionBuilder();
1988 ab.setAction(new SwPathActionCaseBuilder().setSwPathAction(swPathAction.build()).build());
1989 ab.setKey(new ActionKey(0));
1990 actionList.add(ab.build());
1992 // Create an Apply Action
1993 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
1994 aab.setAction(actionList);
1996 // Wrap our Apply Action in an Instruction
1997 final InstructionBuilder ib = new InstructionBuilder();
1998 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2000 // Put our Instruction in a list of Instructions
2001 final InstructionsBuilder isb = new InstructionsBuilder();
2002 final List<Instruction> instructions = new ArrayList<Instruction>();
2003 ib.setKey(new InstructionKey(0));
2004 instructions.add(ib.build());
2005 isb.setInstruction(instructions);
2009 private static InstructionsBuilder createAppyActionInstruction35() {
2011 final List<Action> actionList = new ArrayList<Action>();
2012 final ActionBuilder ab = new ActionBuilder();
2013 final ActionBuilder ab1 = new ActionBuilder();
2014 final ActionBuilder ab2 = new ActionBuilder();
2016 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2017 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2018 final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2021 final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2022 final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2023 ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2024 final EthernetMatchBuilder ethernetMatch1 = new EthernetMatchBuilder();
2025 final EthernetDestinationBuilder ethDestBuilder = new EthernetDestinationBuilder();
2026 ethDestBuilder.setAddress(new MacAddress("00:00:00:00:00:02"));
2027 final EthernetMatchBuilder ethernetMatch2 = new EthernetMatchBuilder();
2028 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2029 ethTypeBuilder.setType(new EtherType(0x86ddL));
2031 ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2032 ethernetMatch1.setEthernetDestination(ethDestBuilder.build());
2033 ethernetMatch2.setEthernetType(ethTypeBuilder.build());
2034 setFieldBuilder.setEthernetMatch(ethernetMatch.build());
2035 setFieldBuilder1.setEthernetMatch(ethernetMatch1.build());
2036 setFieldBuilder2.setEthernetMatch(ethernetMatch2.build());
2037 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2038 ab.setKey(new ActionKey(0));
2039 actionList.add(ab.build());
2041 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2042 ab1.setKey(new ActionKey(1));
2043 actionList.add(ab1.build());
2045 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2046 ab2.setKey(new ActionKey(2));
2047 actionList.add(ab2.build());
2049 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2050 aab.setAction(actionList);
2052 final InstructionBuilder ib = new InstructionBuilder();
2053 ib.setKey(new InstructionKey(0));
2054 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2056 // Put our Instruction in a list of Instructions
2057 final InstructionsBuilder isb = new InstructionsBuilder();
2058 final List<Instruction> instructions = new ArrayList<Instruction>();
2059 ib.setKey(new InstructionKey(0));
2060 instructions.add(ib.build());
2061 isb.setInstruction(instructions);
2065 private static InstructionsBuilder createAppyActionInstruction36() {
2067 final List<Action> actionList = new ArrayList<Action>();
2068 final ActionBuilder ab = new ActionBuilder();
2069 final ActionBuilder ab1 = new ActionBuilder();
2071 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2072 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2075 final VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
2076 final VlanMatchBuilder vlanBuilder1 = new VlanMatchBuilder();
2077 final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2078 final VlanId vlanId = new VlanId(10);
2079 final VlanPcp vpcp = new VlanPcp((short) 3);
2080 vlanBuilder.setVlanPcp(vpcp);
2081 vlanBuilder1.setVlanId(vlanIdBuilder.setVlanId(vlanId).setVlanIdPresent(true).build());
2082 setFieldBuilder.setVlanMatch(vlanBuilder.build());
2083 setFieldBuilder1.setVlanMatch(vlanBuilder1.build());
2084 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2085 ab.setKey(new ActionKey(0));
2086 actionList.add(ab.build());
2087 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2088 ab1.setKey(new ActionKey(1));
2089 actionList.add(ab1.build());
2091 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2092 aab.setAction(actionList);
2094 final InstructionBuilder ib = new InstructionBuilder();
2095 ib.setKey(new InstructionKey(0));
2096 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2098 // Put our Instruction in a list of Instructions
2099 final InstructionsBuilder isb = new InstructionsBuilder();
2100 final List<Instruction> instructions = new ArrayList<Instruction>();
2101 instructions.add(ib.build());
2102 isb.setInstruction(instructions);
2106 private static InstructionsBuilder createAppyActionInstruction37() {
2108 final List<Action> actionList = new ArrayList<Action>();
2109 final ActionBuilder ab = new ActionBuilder();
2110 final ActionBuilder ab1 = new ActionBuilder();
2111 final ActionBuilder ab2 = new ActionBuilder();
2113 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2114 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2115 final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2117 final IpMatchBuilder ipmatch = new IpMatchBuilder();
2118 final IpMatchBuilder ipmatch1 = new IpMatchBuilder();
2119 final IpMatchBuilder ipmatch2 = new IpMatchBuilder();
2120 final Dscp dscp = new Dscp((short) 3);
2121 ipmatch.setIpDscp(dscp);
2122 ipmatch1.setIpEcn((short) 2);
2123 ipmatch2.setIpProtocol((short) 120);
2124 setFieldBuilder.setIpMatch(ipmatch.build());
2125 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2126 ab.setKey(new ActionKey(0));
2127 actionList.add(ab.build());
2129 setFieldBuilder1.setIpMatch(ipmatch1.build());
2130 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2131 ab1.setKey(new ActionKey(1));
2132 actionList.add(ab1.build());
2134 setFieldBuilder2.setIpMatch(ipmatch2.build());
2135 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2136 ab2.setKey(new ActionKey(2));
2137 actionList.add(ab2.build());
2139 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2140 aab.setAction(actionList);
2142 final InstructionBuilder ib = new InstructionBuilder();
2143 ib.setKey(new InstructionKey(0));
2144 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2146 // Put our Instruction in a list of Instructions
2147 final InstructionsBuilder isb = new InstructionsBuilder();
2148 final List<Instruction> instructions = new ArrayList<Instruction>();
2149 instructions.add(ib.build());
2150 isb.setInstruction(instructions);
2154 private static InstructionsBuilder createAppyActionInstruction38() {
2156 final List<Action> actionList = new ArrayList<Action>();
2157 final ActionBuilder ab = new ActionBuilder();
2158 final ActionBuilder ab1 = new ActionBuilder();
2160 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2161 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2163 final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2164 final Ipv4MatchBuilder ipv4Match1 = new Ipv4MatchBuilder();
2165 final Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.5210");
2166 final Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1");
2167 ipv4Match1.setIpv4Destination(dstip);
2168 ipv4Match.setIpv4Source(srcip);
2169 setFieldBuilder.setLayer3Match(ipv4Match.build());
2170 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2171 ab.setKey(new ActionKey(0));
2172 actionList.add(ab.build());
2174 setFieldBuilder1.setLayer3Match(ipv4Match1.build());
2175 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2176 ab1.setKey(new ActionKey(1));
2177 actionList.add(ab1.build());
2179 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2180 aab.setAction(actionList);
2182 final InstructionBuilder ib = new InstructionBuilder();
2183 ib.setKey(new InstructionKey(0));
2184 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2186 // Put our Instruction in a list of Instructions
2187 final InstructionsBuilder isb = new InstructionsBuilder();
2188 final List<Instruction> instructions = new ArrayList<Instruction>();
2189 instructions.add(ib.build());
2190 isb.setInstruction(instructions);
2194 private static InstructionsBuilder createAppyActionInstruction39() {
2196 final List<Action> actionList = new ArrayList<Action>();
2197 final ActionBuilder ab = new ActionBuilder();
2198 final ActionBuilder ab1 = new ActionBuilder();
2200 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2201 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2204 final PortNumber tcpsrcport = new PortNumber(1213);
2205 final PortNumber tcpdstport = new PortNumber(646);
2206 final TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
2207 final TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder();
2208 tcpmatch.setTcpSourcePort(tcpsrcport);
2209 tcpmatch1.setTcpDestinationPort(tcpdstport);
2210 setFieldBuilder.setLayer4Match(tcpmatch.build());
2211 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2212 ab.setKey(new ActionKey(0));
2213 actionList.add(ab.build());
2215 setFieldBuilder1.setLayer4Match(tcpmatch1.build());
2216 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2217 ab1.setKey(new ActionKey(1));
2218 actionList.add(ab.build());
2220 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2221 aab.setAction(actionList);
2223 final InstructionBuilder ib = new InstructionBuilder();
2224 ib.setKey(new InstructionKey(0));
2225 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2227 // Put our Instruction in a list of Instructions
2228 final InstructionsBuilder isb = new InstructionsBuilder();
2229 final List<Instruction> instructions = new ArrayList<Instruction>();
2230 instructions.add(ib.build());
2231 isb.setInstruction(instructions);
2235 private static InstructionsBuilder createAppyActionInstruction40() {
2237 final List<Action> actionList = new ArrayList<Action>();
2238 final ActionBuilder ab = new ActionBuilder();
2239 final ActionBuilder ab1 = new ActionBuilder();
2241 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2242 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2245 final PortNumber udpsrcport = new PortNumber(1325);
2246 final PortNumber udpdstport = new PortNumber(42);
2247 final UdpMatchBuilder udpmatch = new UdpMatchBuilder();
2248 final UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
2249 udpmatch.setUdpDestinationPort(udpdstport);
2250 udpmatch1.setUdpSourcePort(udpsrcport);
2251 setFieldBuilder.setLayer4Match(udpmatch.build());
2252 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2253 ab.setKey(new ActionKey(0));
2254 actionList.add(ab.build());
2256 setFieldBuilder1.setLayer4Match(udpmatch1.build());
2257 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2258 ab1.setKey(new ActionKey(1));
2259 actionList.add(ab1.build());
2261 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2262 aab.setAction(actionList);
2264 final InstructionBuilder ib = new InstructionBuilder();
2265 ib.setKey(new InstructionKey(0));
2266 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2268 // Put our Instruction in a list of Instructions
2269 final InstructionsBuilder isb = new InstructionsBuilder();
2270 final List<Instruction> instructions = new ArrayList<Instruction>();
2271 instructions.add(ib.build());
2272 isb.setInstruction(instructions);
2276 private static InstructionsBuilder createAppyActionInstruction41() {
2278 final List<Action> actionList = new ArrayList<Action>();
2279 final ActionBuilder ab = new ActionBuilder();
2280 final ActionBuilder ab1 = new ActionBuilder();
2282 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2283 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2286 final SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
2287 final SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
2288 final PortNumber srcport = new PortNumber(1435);
2289 final PortNumber dstport = new PortNumber(22);
2290 sctpmatch.setSctpSourcePort(srcport);
2291 sctpmatch1.setSctpDestinationPort(dstport);
2292 setFieldBuilder.setLayer4Match(sctpmatch.build());
2293 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2294 ab.setKey(new ActionKey(0));
2295 actionList.add(ab.build());
2297 setFieldBuilder1.setLayer4Match(sctpmatch1.build());
2298 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2299 ab1.setKey(new ActionKey(1));
2300 actionList.add(ab1.build());
2302 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2303 aab.setAction(actionList);
2305 final InstructionBuilder ib = new InstructionBuilder();
2306 ib.setKey(new InstructionKey(0));
2307 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2309 // Put our Instruction in a list of Instructions
2310 final InstructionsBuilder isb = new InstructionsBuilder();
2311 final List<Instruction> instructions = new ArrayList<Instruction>();
2312 instructions.add(ib.build());
2313 isb.setInstruction(instructions);
2317 private static InstructionsBuilder createAppyActionInstruction42() {
2319 final List<Action> actionList = new ArrayList<Action>();
2320 final ActionBuilder ab = new ActionBuilder();
2321 final ActionBuilder ab1 = new ActionBuilder();
2322 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2323 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2326 final Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
2327 final Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
2328 icmpv4match.setIcmpv4Type((short) 8);
2329 icmpv4match1.setIcmpv4Code((short) 0);
2330 setFieldBuilder.setIcmpv4Match(icmpv4match.build());
2331 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2332 ab.setKey(new ActionKey(0));
2333 actionList.add(ab.build());
2335 setFieldBuilder1.setIcmpv4Match(icmpv4match1.build());
2336 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2337 ab1.setKey(new ActionKey(1));
2338 actionList.add(ab1.build());
2340 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2341 aab.setAction(actionList);
2343 final InstructionBuilder ib = new InstructionBuilder();
2344 ib.setKey(new InstructionKey(0));
2345 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2347 // Put our Instruction in a list of Instructions
2348 final InstructionsBuilder isb = new InstructionsBuilder();
2349 final List<Instruction> instructions = new ArrayList<Instruction>();
2350 instructions.add(ib.build());
2351 isb.setInstruction(instructions);
2355 private static InstructionsBuilder createAppyActionInstruction43() {
2357 final List<Action> actionList = new ArrayList<Action>();
2358 final ActionBuilder ab = new ActionBuilder();
2359 final ActionBuilder ab1 = new ActionBuilder();
2360 final ActionBuilder ab2 = new ActionBuilder();
2361 final ActionBuilder ab3 = new ActionBuilder();
2362 final ActionBuilder ab4 = new ActionBuilder();
2364 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2365 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2366 final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2367 final SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
2368 final SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
2370 // setting the values of ARP
2371 final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
2372 final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
2373 final Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52");
2374 final Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1");
2375 // create ARP match action
2376 final ArpMatchBuilder arpmatch = new ArpMatchBuilder();
2377 final ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
2378 final ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
2379 final ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
2380 final ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
2381 final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2382 arpsrc.setAddress(macsrc);
2383 final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2384 arpdst.setAddress(macdest);
2385 arpmatch.setArpOp(2);
2386 arpmatch1.setArpSourceHardwareAddress(arpsrc.build());
2387 arpmatch2.setArpTargetHardwareAddress(arpdst.build());
2388 arpmatch3.setArpSourceTransportAddress(srciparp);
2389 arpmatch4.setArpTargetTransportAddress(dstiparp);
2390 setFieldBuilder.setLayer3Match(arpmatch.build());
2391 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2392 ab.setKey(new ActionKey(0));
2393 actionList.add(ab.build());
2395 setFieldBuilder1.setLayer3Match(arpmatch1.build());
2396 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2397 ab1.setKey(new ActionKey(1));
2398 actionList.add(ab1.build());
2400 setFieldBuilder2.setLayer3Match(arpmatch2.build());
2401 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2402 ab2.setKey(new ActionKey(2));
2403 actionList.add(ab2.build());
2405 setFieldBuilder3.setLayer3Match(arpmatch3.build());
2406 ab3.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
2407 ab3.setKey(new ActionKey(3));
2408 actionList.add(ab3.build());
2410 setFieldBuilder4.setLayer3Match(arpmatch4.build());
2411 ab4.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
2412 ab4.setKey(new ActionKey(4));
2413 actionList.add(ab4.build());
2415 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2416 aab.setAction(actionList);
2418 final InstructionBuilder ib = new InstructionBuilder();
2419 ib.setKey(new InstructionKey(0));
2420 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2422 // Put our Instruction in a list of Instructions
2423 final InstructionsBuilder isb = new InstructionsBuilder();
2424 final List<Instruction> instructions = new ArrayList<Instruction>();
2425 instructions.add(ib.build());
2426 isb.setInstruction(instructions);
2430 private static InstructionsBuilder createAppyActionInstruction44() {
2432 final List<Action> actionLists = new ArrayList<Action>();
2433 final ActionBuilder ab = new ActionBuilder();
2434 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2435 final ActionBuilder ab1 = new ActionBuilder();
2436 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2437 final ActionBuilder ab5 = new ActionBuilder();
2438 final SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
2439 final ActionBuilder ab6 = new ActionBuilder();
2440 final SetFieldBuilder setFieldBuilder6 = new SetFieldBuilder();
2443 final Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
2444 final Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
2445 final Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
2446 final Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
2448 final Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/128");
2449 final Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/128");
2450 final Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
2451 nextheader.setIpv6Exthdr(58);
2452 final Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2453 final Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
2454 ipv6label.setIpv6Flabel(label);
2456 ipv6Builder.setIpv6Source(srcip6);
2457 ipv6Builder1.setIpv6Destination(dstip6);
2458 ipv6Builder5.setIpv6ExtHeader(nextheader.build());
2459 ipv6Builder6.setIpv6Label(ipv6label.build());
2461 setFieldBuilder.setLayer3Match(ipv6Builder.build());
2462 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2463 ab.setKey(new ActionKey(0));
2464 actionLists.add(ab.build());
2466 setFieldBuilder1.setLayer3Match(ipv6Builder1.build());
2467 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2468 ab1.setKey(new ActionKey(1));
2469 actionLists.add(ab1.build());
2471 setFieldBuilder5.setLayer3Match(ipv6Builder5.build());
2472 ab5.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder5.build()).build());
2473 ab5.setKey(new ActionKey(5));
2474 actionLists.add(ab5.build());
2476 setFieldBuilder6.setLayer3Match(ipv6Builder6.build());
2477 ab6.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder6.build()).build());
2478 ab6.setKey(new ActionKey(6));
2479 actionLists.add(ab6.build());
2481 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2482 aab.setAction(actionLists);
2484 final InstructionBuilder ib = new InstructionBuilder();
2485 ib.setKey(new InstructionKey(0));
2486 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2488 // Put our Instruction in a list of Instructions
2489 final InstructionsBuilder isb = new InstructionsBuilder();
2490 final List<Instruction> instructions = new ArrayList<Instruction>();
2491 instructions.add(ib.build());
2492 isb.setInstruction(instructions);
2496 private static InstructionsBuilder createAppyActionInstruction45() {
2498 final List<Action> actionList = new ArrayList<Action>();
2499 final ActionBuilder ab = new ActionBuilder();
2500 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2501 final ActionBuilder ab1 = new ActionBuilder();
2502 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2505 final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
2506 final Icmpv6MatchBuilder icmpv6match1 = new Icmpv6MatchBuilder();
2507 icmpv6match.setIcmpv6Type((short) 135);
2508 icmpv6match1.setIcmpv6Code((short) 0);
2509 setFieldBuilder.setIcmpv6Match(icmpv6match.build());
2510 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2511 ab.setKey(new ActionKey(0));
2512 actionList.add(ab.build());
2514 setFieldBuilder1.setIcmpv6Match(icmpv6match1.build());
2515 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2516 ab1.setKey(new ActionKey(1));
2517 actionList.add(ab1.build());
2519 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2520 aab.setAction(actionList);
2522 final InstructionBuilder ib = new InstructionBuilder();
2523 ib.setKey(new InstructionKey(0));
2524 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2526 // Put our Instruction in a list of Instructions
2527 final InstructionsBuilder isb = new InstructionsBuilder();
2528 final List<Instruction> instructions = new ArrayList<Instruction>();
2529 instructions.add(ib.build());
2530 isb.setInstruction(instructions);
2534 private static InstructionsBuilder createAppyActionInstruction46() {
2536 final List<Action> actionList = new ArrayList<Action>();
2537 final ActionBuilder ab = new ActionBuilder();
2538 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2539 final ActionBuilder ab1 = new ActionBuilder();
2540 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2541 final ActionBuilder ab2 = new ActionBuilder();
2542 final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2545 final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2546 final ProtocolMatchFieldsBuilder protomatch1 = new ProtocolMatchFieldsBuilder();
2547 final ProtocolMatchFieldsBuilder protomatch2 = new ProtocolMatchFieldsBuilder();
2548 protomatch.setMplsLabel((long) 36008);
2549 protomatch1.setMplsTc((short) 4);
2550 protomatch2.setMplsBos((short) 1);
2551 setFieldBuilder.setProtocolMatchFields(protomatch.build());
2552 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2553 ab.setKey(new ActionKey(0));
2554 actionList.add(ab.build());
2556 setFieldBuilder1.setProtocolMatchFields(protomatch1.build());
2557 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2558 ab1.setKey(new ActionKey(1));
2559 actionList.add(ab1.build());
2561 setFieldBuilder2.setProtocolMatchFields(protomatch2.build());
2562 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2563 ab2.setKey(new ActionKey(2));
2564 actionList.add(ab2.build());
2566 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2567 aab.setAction(actionList);
2569 final InstructionBuilder ib = new InstructionBuilder();
2570 ib.setKey(new InstructionKey(0));
2571 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2573 // Put our Instruction in a list of Instructions
2574 final InstructionsBuilder isb = new InstructionsBuilder();
2575 final List<Instruction> instructions = new ArrayList<Instruction>();
2576 instructions.add(ib.build());
2577 isb.setInstruction(instructions);
2581 private static InstructionsBuilder createAppyActionInstruction47() {
2583 final List<Action> actionList = new ArrayList<Action>();
2584 final ActionBuilder ab = new ActionBuilder();
2585 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2587 final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2588 protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask((new BigInteger(new byte[]{0, 1, 0, 0}).longValue())).build());
2589 setFieldBuilder.setProtocolMatchFields(protomatch.build());
2590 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2591 actionList.add(ab.build());
2593 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2594 aab.setAction(actionList);
2596 final InstructionBuilder ib = new InstructionBuilder();
2597 ib.setKey(new InstructionKey(0));
2598 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2600 // Put our Instruction in a list of Instructions
2601 final InstructionsBuilder isb = new InstructionsBuilder();
2602 final List<Instruction> instructions = new ArrayList<Instruction>();
2603 instructions.add(ib.build());
2604 isb.setInstruction(instructions);
2608 private static InstructionsBuilder createAppyActionInstruction48() {
2610 final List<Action> actionList = new ArrayList<Action>();
2611 final ActionBuilder ab = new ActionBuilder();
2612 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2614 final TunnelBuilder tunnel = new TunnelBuilder();
2615 tunnel.setTunnelId(BigInteger.valueOf(10668));
2616 setFieldBuilder.setTunnel(tunnel.build());
2617 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2618 ab.setKey(new ActionKey(0));
2619 actionList.add(ab.build());
2621 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2622 aab.setAction(actionList);
2624 final InstructionBuilder ib = new InstructionBuilder();
2625 ib.setKey(new InstructionKey(0));
2626 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2628 // Put our Instruction in a list of Instructions
2629 final InstructionsBuilder isb = new InstructionsBuilder();
2630 final List<Instruction> instructions = new ArrayList<Instruction>();
2631 instructions.add(ib.build());
2632 isb.setInstruction(instructions);
2636 private static InstructionsBuilder createTunnelIpv4DstInstructions() {
2638 final List<Action> actionList = new ArrayList<Action>();
2639 final ActionBuilder ab = new ActionBuilder();
2640 // Build the tunnel endpoint destination IPv4 address
2641 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2642 final Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.100");
2643 // Add the mew IPv4 object as the tunnel destination
2644 final TunnelIpv4MatchBuilder tunnelIpv4DstMatchBuilder = new TunnelIpv4MatchBuilder();
2645 tunnelIpv4DstMatchBuilder.setTunnelIpv4Destination(dstIp);
2646 setFieldBuilder.setLayer3Match(tunnelIpv4DstMatchBuilder.build());
2647 // Add the IPv4 tunnel dst to the set_field value
2648 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2650 ab.setKey(new ActionKey(0));
2651 actionList.add(ab.build());
2652 // Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_dst)
2653 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2654 aab.setAction(actionList);
2655 // Add the action to the ordered list of Instructions
2656 final InstructionBuilder ib = new InstructionBuilder();
2658 ib.setKey(new InstructionKey(0));
2659 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2660 // Add the Instruction in a list of Instructions
2661 final InstructionsBuilder isb = new InstructionsBuilder();
2662 final List<Instruction> instructions = new ArrayList<Instruction>();
2663 instructions.add(ib.build());
2664 isb.setInstruction(instructions);
2668 private static InstructionsBuilder createTunnelIpv4SrcInstructions() {
2670 final List<Action> actionList = new ArrayList<Action>();
2671 final ActionBuilder ab = new ActionBuilder();
2672 // Build the tunnel endpoint source IPv4 address
2673 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2674 final Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.200");
2675 // Add the new IPv4 object as the tunnel destination
2676 final TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
2677 tunnelIpv4MatchBuilder.setTunnelIpv4Source(dstIp);
2678 setFieldBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
2679 // Add the IPv4 tunnel src to the set_field value
2680 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2682 ab.setKey(new ActionKey(0));
2683 actionList.add(ab.build());
2684 // Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_src)
2685 final ApplyActionsBuilder aab = new ApplyActionsBuilder();
2686 aab.setAction(actionList);
2687 // Add the action to the ordered list of Instructions
2688 final InstructionBuilder ib = new InstructionBuilder();
2690 ib.setKey(new InstructionKey(0));
2691 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2692 // Put our Instruction in a list of Instructions
2693 final InstructionsBuilder isb = new InstructionsBuilder();
2694 final List<Instruction> instructions = new ArrayList<Instruction>();
2695 instructions.add(ib.build());
2696 isb.setInstruction(instructions);
2700 private static MatchBuilder createLLDPMatch() {
2701 final MatchBuilder match = new MatchBuilder();
2702 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2703 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2704 ethTypeBuilder.setType(new EtherType(0x88ccL));
2705 eth.setEthernetType(ethTypeBuilder.build());
2706 match.setEthernetMatch(eth.build());
2713 private static MatchBuilder createMatch1() {
2714 final MatchBuilder match = new MatchBuilder();
2715 final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2716 final Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);;
2717 ipv4Match.setIpv4Destination(prefix);
2718 final Ipv4Match i4m = ipv4Match.build();
2719 match.setLayer3Match(i4m);
2721 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2722 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2723 ethTypeBuilder.setType(new EtherType(0x0800L));
2724 eth.setEthernetType(ethTypeBuilder.build());
2725 match.setEthernetMatch(eth.build());
2733 private static MatchBuilder createMatch2() {
2734 final MatchBuilder match = new MatchBuilder();
2735 final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2736 final Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
2737 ipv4Match.setIpv4Source(prefix);
2738 final Ipv4Match i4m = ipv4Match.build();
2739 match.setLayer3Match(i4m);
2741 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2742 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2743 ethTypeBuilder.setType(new EtherType(0x0800L));
2744 eth.setEthernetType(ethTypeBuilder.build());
2745 match.setEthernetMatch(eth.build());
2752 private static MatchBuilder createMatch3() {
2753 final MatchBuilder match = new MatchBuilder();
2754 final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2755 final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2756 ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2757 ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2758 match.setEthernetMatch(ethernetMatch.build());
2766 private static MatchBuilder createICMPv6Match1() {
2768 final MatchBuilder match = new MatchBuilder();
2769 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2770 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2771 ethTypeBuilder.setType(new EtherType(0x86ddL));
2772 eth.setEthernetType(ethTypeBuilder.build());
2773 match.setEthernetMatch(eth.build());
2776 final IpMatchBuilder ipmatch = new IpMatchBuilder();
2777 ipmatch.setIpProtocol((short) 256);
2778 match.setIpMatch(ipmatch.build());
2781 final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
2784 icmpv6match.setIcmpv6Type((short) 135);
2785 icmpv6match.setIcmpv6Code((short) 1);
2786 match.setIcmpv6Match(icmpv6match.build());
2791 private static MatchBuilder createMatch33() {
2793 final MatchBuilder match = new MatchBuilder();
2794 final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2795 final Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
2796 ipv4Match.setIpv4Source(prefix);
2797 final Ipv4Match i4m = ipv4Match.build();
2798 match.setLayer3Match(i4m);
2800 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2801 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2802 ethTypeBuilder.setType(new EtherType(0xfffeL));
2803 eth.setEthernetType(ethTypeBuilder.build());
2804 match.setEthernetMatch(eth.build());
2808 private static MatchBuilder createInphyportMatch(final NodeId nodeId) {
2809 final MatchBuilder match = new MatchBuilder();
2810 match.setInPort(new NodeConnectorId(nodeId + ":202"));
2811 match.setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
2815 private static MatchBuilder createEthernetMatch() {
2816 final MatchBuilder match = new MatchBuilder();
2817 final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
2819 final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2820 final EtherType type = new EtherType(0x0800L);
2821 ethmatch.setEthernetType(ethtype.setType(type).build());
2823 final EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
2826 final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
2827 ethdest.setAddress(macdest);
2828 ethdest.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2830 ethmatch.setEthernetDestination(ethdest.build());
2832 final EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
2833 final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
2834 ethsrc.setAddress(macsrc);
2835 ethsrc.setMask(new MacAddress("ff:ff:00:00:00:00"));
2837 ethmatch.setEthernetSource(ethsrc.build());
2838 match.setEthernetMatch(ethmatch.build());
2847 private static MatchBuilder createVlanMatch() {
2848 final MatchBuilder match = new MatchBuilder();
2850 final VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
2851 final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2852 final VlanId vlanId = new VlanId(10);
2853 final VlanPcp vpcp = new VlanPcp((short) 3);
2854 vlanBuilder.setVlanPcp(vpcp);
2855 vlanIdBuilder.setVlanId(vlanId);
2856 vlanIdBuilder.setVlanIdPresent(true);
2857 vlanBuilder.setVlanId(vlanIdBuilder.build());
2858 match.setVlanMatch(vlanBuilder.build());
2865 private static MatchBuilder createArpMatch() {
2866 final MatchBuilder match = new MatchBuilder();
2868 final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2869 final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
2870 final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
2872 final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2873 final EtherType type = new EtherType(0x0806L);
2874 ethmatch.setEthernetType(ethtype.setType(type).build());
2877 final Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10");
2878 final Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2881 final ArpMatchBuilder arpmatch = new ArpMatchBuilder();
2882 final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2883 arpsrc.setAddress(macsrc);
2884 arpsrc.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2885 final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2886 arpdst.setAddress(macdest);
2887 arpdst.setMask(new MacAddress("ff:ff:00:00:00:00"));
2888 arpmatch.setArpOp(2);
2889 arpmatch.setArpSourceHardwareAddress(arpsrc.build());
2890 arpmatch.setArpTargetHardwareAddress(arpdst.build());
2891 arpmatch.setArpSourceTransportAddress(srcip);
2892 arpmatch.setArpTargetTransportAddress(dstip);
2894 match.setEthernetMatch(ethmatch.build());
2895 match.setLayer3Match(arpmatch.build());
2904 private static MatchBuilder createL3IPv4Match() {
2905 final MatchBuilder match = new MatchBuilder();
2907 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2908 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2909 ethTypeBuilder.setType(new EtherType(0x0800L));
2910 eth.setEthernetType(ethTypeBuilder.build());
2911 match.setEthernetMatch(eth.build());
2913 final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2915 final Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10");
2916 final Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2917 final Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
2918 ipv4match.setIpv4Destination(dstip);
2919 ipv4match.setIpv4Source(srcip);
2920 match.setLayer3Match(ipv4match.build());
2929 private static MatchBuilder createL3IPv6Match() {
2930 final MatchBuilder match = new MatchBuilder();
2932 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2933 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2934 ethTypeBuilder.setType(new EtherType(0x86ddL));
2935 eth.setEthernetType(ethTypeBuilder.build());
2936 match.setEthernetMatch(eth.build());
2938 final Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
2939 final Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
2940 final Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
2941 final MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
2942 final MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
2943 final Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
2944 nextheader.setIpv6Exthdr(58);
2945 final Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2946 final Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
2947 ipv6label.setIpv6Flabel(label);
2948 ipv6label.setFlabelMask(new Ipv6FlowLabel(1L));
2950 final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2952 icmpv6match.setIcmpv6Type((short) 135);
2953 icmpv6match.setIcmpv6Code((short) 0);
2954 match.setIcmpv6Match(icmpv6match.build());
2956 final Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
2957 // ipv6match.setIpv6Source(srcip6);
2958 // ipv6match.setIpv6Destination(dstip6);
2959 // ipv6match.setIpv6ExtHeader(nextheader.build());
2960 ipv6match.setIpv6NdSll(ndsll);
2961 ipv6match.setIpv6NdTll(ndtll);
2962 // ipv6match.setIpv6NdTarget(ndtarget);
2963 ipv6match.setIpv6Label(ipv6label.build());
2965 match.setLayer3Match(ipv6match.build());
2974 private static MatchBuilder createICMPv4Match() {
2975 final MatchBuilder match = new MatchBuilder();
2976 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2977 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2978 ethTypeBuilder.setType(new EtherType(0x0800L));
2979 eth.setEthernetType(ethTypeBuilder.build());
2980 match.setEthernetMatch(eth.build());
2982 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2983 ipmatch.setIpProtocol((short) 1);
2984 match.setIpMatch(ipmatch.build());
2986 final Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
2988 icmpv4match.setIcmpv4Type((short) 8);
2989 icmpv4match.setIcmpv4Code((short) 0);
2990 match.setIcmpv4Match(icmpv4match.build());
2997 private static MatchBuilder createICMPv6Match() {
2999 final MatchBuilder match = new MatchBuilder();
3000 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
3001 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3002 ethTypeBuilder.setType(new EtherType(0x86ddL));
3003 eth.setEthernetType(ethTypeBuilder.build());
3004 match.setEthernetMatch(eth.build());
3006 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3007 ipmatch.setIpProtocol((short) 58);
3008 match.setIpMatch(ipmatch.build());
3010 final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
3012 icmpv6match.setIcmpv6Type((short) 135);
3013 icmpv6match.setIcmpv6Code((short) 1);
3014 match.setIcmpv6Match(icmpv6match.build());
3022 private static MatchBuilder createToSMatch() {
3023 final MatchBuilder match = new MatchBuilder();
3024 final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
3025 final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
3026 final EtherType type = new EtherType(0x0800L);
3027 ethmatch.setEthernetType(ethtype.setType(type).build());
3028 match.setEthernetMatch(ethmatch.build());
3030 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3031 ipmatch.setIpProtocol((short) 6);
3032 final Dscp dscp = new Dscp((short) 8);
3033 ipmatch.setIpDscp(dscp);
3034 match.setIpMatch(ipmatch.build());
3042 private static MatchBuilder createL4TCPMatch() {
3043 final MatchBuilder match = new MatchBuilder();
3045 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
3046 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3047 ethTypeBuilder.setType(new EtherType(0x0800L));
3048 eth.setEthernetType(ethTypeBuilder.build());
3049 match.setEthernetMatch(eth.build());
3051 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3052 ipmatch.setIpProtocol((short) 6);
3053 match.setIpMatch(ipmatch.build());
3055 final PortNumber srcport = new PortNumber(1213);
3056 final PortNumber dstport = new PortNumber(646);
3057 final TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
3058 tcpmatch.setTcpSourcePort(srcport);
3059 tcpmatch.setTcpDestinationPort(dstport);
3060 match.setLayer4Match(tcpmatch.build());
3068 private static MatchBuilder createL4UDPMatch() {
3069 final MatchBuilder match = new MatchBuilder();
3071 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
3072 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3073 ethTypeBuilder.setType(new EtherType(0x0800L));
3074 eth.setEthernetType(ethTypeBuilder.build());
3075 match.setEthernetMatch(eth.build());
3077 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3078 ipmatch.setIpProtocol((short) 17);
3079 match.setIpMatch(ipmatch.build());
3081 final PortNumber srcport = new PortNumber(1325);
3082 final PortNumber dstport = new PortNumber(42);
3083 final UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
3084 udpmatch.setUdpDestinationPort(dstport);
3085 udpmatch.setUdpSourcePort(srcport);
3086 match.setLayer4Match(udpmatch.build());
3094 private static MatchBuilder createL4SCTPMatch() {
3095 final MatchBuilder match = new MatchBuilder();
3097 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
3098 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3099 ethTypeBuilder.setType(new EtherType(0x0800L));
3100 eth.setEthernetType(ethTypeBuilder.build());
3101 match.setEthernetMatch(eth.build());
3103 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3104 ipmatch.setIpProtocol((short) 132);
3105 match.setIpMatch(ipmatch.build());
3107 final SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
3108 final PortNumber srcport = new PortNumber(1435);
3109 final PortNumber dstport = new PortNumber(22);
3110 sctpmatch.setSctpSourcePort(srcport);
3111 sctpmatch.setSctpDestinationPort(dstport);
3112 match.setLayer4Match(sctpmatch.build());
3120 private static MatchBuilder createMetadataMatch() {
3121 final MatchBuilder match = new MatchBuilder();
3122 final byte[] metamask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
3123 final MetadataBuilder metadata = new MetadataBuilder(); // metadata match
3124 metadata.setMetadata(BigInteger.valueOf(500L));
3125 metadata.setMetadataMask(new BigInteger(1, metamask));
3126 match.setMetadata(metadata.build());
3134 private static MatchBuilder createMplsMatch() {
3135 final MatchBuilder match = new MatchBuilder();
3137 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
3138 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3139 ethTypeBuilder.setType(new EtherType(0x8847L));
3140 eth.setEthernetType(ethTypeBuilder.build());
3141 match.setEthernetMatch(eth.build());
3143 final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
3145 protomatch.setMplsLabel((long) 36008);
3146 protomatch.setMplsTc((short) 4);
3147 protomatch.setMplsBos((short) 1);
3148 match.setProtocolMatchFields(protomatch.build());
3157 private static MatchBuilder createPbbMatch() {
3158 final MatchBuilder match = new MatchBuilder();
3160 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
3161 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3162 ethTypeBuilder.setType(new EtherType(0x88E7L));
3163 eth.setEthernetType(ethTypeBuilder.build());
3164 match.setEthernetMatch(eth.build());
3166 final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
3168 protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new BigInteger(new byte[]{0, 1, 0, 0}).longValue()).build());
3169 match.setProtocolMatchFields(protomatch.build());
3178 private static MatchBuilder createTunnelIDMatch() {
3179 final MatchBuilder match = new MatchBuilder();
3180 final TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
3181 tunnel.setTunnelId(BigInteger.valueOf(10668));
3182 final byte[] mask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
3183 tunnel.setTunnelMask(new BigInteger(1, mask));
3184 match.setTunnel(tunnel.build());
3190 * Test match for TCP_Flags
3192 * @return match containing Ethertype (0x0800), IP Protocol (TCP), TCP_Flag (SYN)
3194 //FIXME: move to extensible support
3195 private static MatchBuilder createTcpFlagMatch() {
3196 final MatchBuilder match = new MatchBuilder();
3199 final EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
3200 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3201 ethTypeBuilder.setType(new EtherType(0x0800L));
3202 ethernetType.setEthernetType(ethTypeBuilder.build());
3203 match.setEthernetMatch(ethernetType.build());
3205 // TCP Protocol Match
3206 final IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
3207 ipMatch.setIpProtocol((short) 6);
3208 match.setIpMatch(ipMatch.build());
3211 final PortNumber dstPort = new PortNumber(80);
3212 final TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
3213 tcpMatch.setTcpDestinationPort(dstPort);
3214 match.setLayer4Match(tcpMatch.build());
3216 * Defined TCP Flag values in OVS v2.1+
3217 * TCP_FIN 0x001 / TCP_SYN 0x002 / TCP_RST 0x004
3218 * TCP_PSH 0x008 / TCP_ACK 0x010 / TCP_URG 0x020
3219 * TCP_ECE 0x040 / TCP_CWR 0x080 / TCP_NS 0x100
3221 final TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
3222 tcpFlagMatch.setTcpFlag(0x002);
3223 match.setTcpFlagMatch(tcpFlagMatch.build());
3228 public void _removeMDFlow(final CommandInterpreter ci) {
3229 final ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
3230 final NodeBuilder tn = createTestNode(ci.nextArgument());
3231 final String flowtype = ci.nextArgument();
3233 if (flowtype.equals("fTM")) {
3234 tf = createtablemiss();
3236 tf = createTestFlow(tn, flowtype, ci.nextArgument());
3238 final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey())
3239 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
3240 .child(Flow.class, tf.getKey());
3241 modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
3242 final CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
3243 Futures.addCallback(commitFuture, new FutureCallback<Void>() {
3245 public void onSuccess(final Void aVoid) {
3246 ci.println("Status of Group Data Loaded Transaction: success.");
3250 public void onFailure(final Throwable throwable) {
3251 LOG.error(throwable.getMessage(), throwable);
3252 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
3258 * @param ci arguments: switchId flowType tableNum
3261 * e.g.: addMDFlow openflow:1 f1 42
3264 public void _addMDFlow(final CommandInterpreter ci) {
3265 final NodeBuilder tn = createTestNode(ci.nextArgument());
3266 final String flowtype = ci.nextArgument();
3268 if (flowtype.equals("fTM")) {
3269 tf = createtablemiss();
3271 tf = createTestFlow(tn, flowtype, ci.nextArgument());
3273 writeFlow(ci, tf, tn);
3276 private void writeFlow(final CommandInterpreter ci, final FlowBuilder flow, final NodeBuilder nodeBuilder) {
3277 final ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
3278 final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
3279 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
3280 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey());
3281 modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
3282 modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
3283 final CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
3284 Futures.addCallback(commitFuture, new FutureCallback<Void>() {
3286 public void onSuccess(final Void aVoid) {
3287 ci.println("Status of Group Data Loaded Transaction: success.");
3291 public void onFailure(final Throwable throwable) {
3292 LOG.error(throwable.getMessage(), throwable);
3293 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
3298 public void _modifyMDFlow(final CommandInterpreter ci) {
3299 final NodeBuilder tn = createTestNode(ci.nextArgument());
3300 final FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
3301 tf.setFlowName(UPDATED_FLOW_NAME);
3302 writeFlow(ci, tf, tn);
3303 tf.setFlowName(ORIGINAL_FLOW_NAME);
3304 writeFlow(ci, tf, tn);
3307 private static NodeRef createNodeRef(final String string) {
3308 final NodeKey key = new NodeKey(new NodeId(string));
3309 final InstanceIdentifier<Node> path = InstanceIdentifier.create(Nodes.class).child(Node.class, key);
3311 return new NodeRef(path);
3315 public String getHelp() {
3320 * usage testSwitchFlows <numberOfSwitches> <numberOfFlows> <warmup iterations> <Number Of Threads>
3321 * ex: _perfFlowTest 10 5 1 2
3323 public void _perfFlowTest(final CommandInterpreter ci) {
3325 final String numberOfSwtichesStr = ci.nextArgument();
3326 final String numberOfFlowsStr = ci.nextArgument();
3327 final String warmupIterationsStr = ci.nextArgument();
3328 final String threadCountStr = ci.nextArgument();
3329 final String warmUpStr = ci.nextArgument();
3331 Collection<String> testResults = null;
3332 if (testResults == null) {
3333 testResults = new ArrayList<String>();
3336 int numberOfSwtiches = 0;
3337 int numberOfFlows = 0;
3338 int warmupIterations = 0;
3339 boolean warmUpIterations = false;
3341 int threadCount = 0;
3342 if (numberOfSwtichesStr != null && !numberOfSwtichesStr.trim().equals("")) {
3343 numberOfSwtiches = Integer.parseInt(numberOfSwtichesStr);
3345 numberOfSwtiches = 2;
3348 if (numberOfFlowsStr != null && !numberOfFlowsStr.trim().equals("")) {
3349 numberOfFlows = Integer.parseInt(numberOfFlowsStr);
3354 if (warmupIterationsStr != null && !warmupIterationsStr.trim().equals("")) {
3355 warmupIterations = Integer.parseInt(warmupIterationsStr);
3357 warmupIterations = 2;
3360 if (threadCountStr != null && !threadCountStr.trim().equals("")) {
3361 threadCount = Integer.parseInt(threadCountStr);
3365 if (warmUpStr != null && !warmUpStr.trim().equals("") && warmUpStr.trim().equals("true")) {
3366 warmUpIterations = true;
3368 warmUpIterations = false;
3370 ci.println("* Test Configurations*");
3371 ci.println("* numberOfSwtiches:::" + numberOfSwtiches + "");
3372 ci.println("* numberOfFlows:::" + numberOfFlows + "");
3373 ci.println("* warmupIterations:::" + warmupIterations + "");
3374 ci.println("* Number of Threads :::" + threadCount + "");
3375 ci.println("* Warmup Required? :::" + warmUpIterations + "");
3377 String dataPath = "openflow:1";
3380 final String tableId = "0";
3381 if (warmUpIterations) {
3382 ci.println("----Warmup Started-----");
3383 for (int j = 1; j <= warmupIterations; j++) {
3384 for (int i = 1; i <= numberOfSwtiches; i++) {
3385 dataPath = "openflow:" + i;
3386 tn = createTestNode(dataPath);
3387 for (int flow = 1; flow < numberOfFlows; flow++) {
3388 tf = createTestFlowPerfTest("f1", tableId, flow);
3389 writeFlow(ci, tf, tn);
3394 ci.println("----Warmup Done-----");
3397 final ExecutorService executor = Executors.newFixedThreadPool(threadCount);
3399 for (int t = 0; t < threadCount; t++) {
3401 final Runnable tRunnable = new TestFlowThread(numberOfSwtiches, numberOfFlows, ci, t, tableID);
3402 executor.execute(tRunnable);
3404 executor.shutdown();
3405 executor.awaitTermination(1, TimeUnit.SECONDS);
3406 } catch (final Exception e) {
3407 ci.println("Exception:" + e.getMessage());
3411 public class TestFlowThread implements Runnable {
3413 int numberOfSwitches;
3416 CommandInterpreter ci;
3419 Collection<String> testResults = null;
3422 TestFlowThread(final int numberOfSwtiches, final int numberOfFlows, final CommandInterpreter ci, final int t, final int tableID) {
3423 this.numberOfSwitches = numberOfSwtiches;
3424 this.numberOfFlows = numberOfFlows;
3426 this.theadNumber = t;
3427 this.tableID = tableID;
3435 public void executeFlow() {
3437 String dataPath = "openflow:1";
3440 //String tableId = "0";
3442 ci.println("New Thread started with id: ID_"
3443 + this.theadNumber);
3444 int totalNumberOfFlows = 0;
3445 final long startTime = System.currentTimeMillis();
3447 for (int i = 1; i <= this.numberOfSwitches; i++) {
3448 dataPath = "openflow:" + i;
3449 tn = createTestNode(dataPath);
3450 for (int flow2 = 1; flow2 <= this.numberOfFlows; flow2++) {
3451 tf = createTestFlowPerfTest("f1", "" + this.tableID, flow2);
3452 writeFlow(this.ci, tf, tn);
3453 totalNumberOfFlows++;
3456 final long endTime = System.currentTimeMillis();
3457 final long timeInSeconds = Math.round((endTime - startTime) / 1000);
3458 if (timeInSeconds > 0) {
3459 ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::" + Math.round(totalNumberOfFlows / timeInSeconds));
3461 ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::" + totalNumberOfFlows);
3468 * usage testAllFlows <dp>
3469 * ex: _perfFlowTest 1
3471 public void _testAllFlows(final CommandInterpreter ci) {
3472 String dataPathID = ci.nextArgument();
3473 final int numberOfFlows = 82;
3474 if (dataPathID == null || dataPathID.trim().equals("")) {
3477 ci.println("* Test All Flows *");
3478 ci.println("* dataPathID:::" + dataPathID + "");
3479 final String dataPath = "openflow:" + dataPathID;
3480 final String tableId = "0";
3481 final NodeBuilder tn = createTestNode(dataPath);
3483 for (int flow = 1; flow < numberOfFlows; flow++) {
3484 final String flowID = "f" + flow;
3486 tf = createTestFlow(tn, flowID, tableId);
3487 writeFlow(ci, tf, tn);
3488 } catch (final Exception e) {
3489 ci.println("--Test Failed--Issue found while adding flow" + flow);