2 * Copyright (c) 2013 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.rev100924.Dscp;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
34 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
35 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
36 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.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.concepts.Registration;
179 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
180 import org.osgi.framework.BundleContext;
181 import org.slf4j.Logger;
182 import org.slf4j.LoggerFactory;
184 public class OpenflowpluginTestCommandProvider implements CommandProvider {
186 private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
188 private DataBroker dataBroker;
189 private ProviderContext pc;
190 private final BundleContext ctx;
191 private FlowBuilder testFlow;
192 private NodeBuilder testNode;
193 private final String originalFlowName = "Foo";
194 private final String updatedFlowName = "Bar";
195 private final SalFlowListener flowEventListener = new FlowEventListenerLoggingImpl();
196 private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl();
197 private static NotificationService notificationService;
198 private Registration listener1Reg;
199 private Registration listener2Reg;
201 public OpenflowpluginTestCommandProvider(BundleContext ctx) {
205 public void onSessionInitiated(ProviderContext session) {
207 notificationService = session.getSALService(NotificationService.class);
209 listener1Reg = notificationService.registerNotificationListener(flowEventListener);
210 listener2Reg = notificationService.registerNotificationListener(nodeErrorListener);
211 dataBroker = session.getSALService(DataBroker.class);
212 ctx.registerService(CommandProvider.class.getName(), this, null);
213 createTestFlow(createTestNode(null), null, null);
216 private NodeBuilder createTestNode(String nodeId) {
217 if (nodeId == null) {
218 nodeId = OpenflowpluginTestActivator.NODE_ID;
220 NodeRef nodeOne = createNodeRef(nodeId);
221 NodeBuilder builder = new NodeBuilder();
222 builder.setId(new NodeId(nodeId));
223 builder.setKey(new NodeKey(builder.getId()));
228 private InstanceIdentifier<Node> nodeBuilderToInstanceId(NodeBuilder node) {
229 return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
232 private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
234 FlowBuilder flow = new FlowBuilder();
237 String flowType = flowTypeArg;
238 if (flowType == null) {
247 flow.setMatch(createMatch1().build());
248 flow.setInstructions(createDecNwTtlInstructions().build());
252 flow.setMatch(createMatch2().build());
253 flow.setInstructions(createDropInstructions().build());
257 flow.setMatch(createMatch3().build());
258 flow.setInstructions(createDropInstructions().build());
262 flow.setMatch(createEthernetMatch().build());
263 flow.setInstructions(createDropInstructions().build());
267 flow.setMatch(createMatch1().build());
268 flow.setInstructions(createAppyActionInstruction().build());
272 flow.setMatch(createMatch1().build());
273 flow.setInstructions(createGotoTableInstructions().build());
277 flow.setMatch(createMatch1().build());
278 flow.setInstructions(createMeterInstructions().build());
282 flow.setMatch(createMatch1().build());
283 flow.setInstructions(createAppyActionInstruction1().build());
287 flow.setMatch(createMatch1().build());
288 flow.setInstructions(createAppyActionInstruction2().build());
292 flow.setMatch(createMatch1().build());
293 flow.setInstructions(createAppyActionInstruction3().build());
297 flow.setMatch(createMatch1().build());
298 flow.setInstructions(createAppyActionInstruction4().build());
302 flow.setMatch(createMatch1().build());
303 flow.setInstructions(createAppyActionInstruction5().build());
307 flow.setMatch(createMatch1().build());
308 flow.setInstructions(createAppyActionInstruction6().build());
312 flow.setMatch(createMatch1().build());
313 flow.setInstructions(createAppyActionInstruction7().build());
317 flow.setMatch(createMatch1().build());
318 flow.setInstructions(createAppyActionInstruction8().build());
322 flow.setMatch(createMatch1().build());
323 flow.setInstructions(createAppyActionInstruction9().build());
327 flow.setMatch(createMatch1().build());
328 flow.setInstructions(createAppyActionInstruction10().build());
332 flow.setMatch(createMatch1().build());
333 flow.setInstructions(createAppyActionInstruction11().build());
337 flow.setMatch(createMatch1().build());
338 flow.setInstructions(createAppyActionInstruction12().build());
342 flow.setMatch(createMatch1().build());
343 flow.setInstructions(createAppyActionInstruction13().build());
347 flow.setMatch(createMatch1().build());
348 flow.setInstructions(createAppyActionInstruction14().build());
352 flow.setMatch(createMatch1().build());
353 flow.setInstructions(createAppyActionInstruction15().build());
357 // f23 can be used as test-case for generating error notification
358 // if the particular group is not configured - tested
359 flow.setMatch(createMatch1().build());
360 flow.setInstructions(createAppyActionInstruction16().build());
364 flow.setMatch(createMatch1().build());
365 flow.setInstructions(createAppyActionInstruction17().build());
369 flow.setMatch(createMatch1().build());
370 flow.setInstructions(createAppyActionInstruction18().build());
374 flow.setMatch(createMatch1().build());
375 flow.setInstructions(createAppyActionInstruction19().build());
379 flow.setMatch(createMatch1().build());
380 flow.setInstructions(createMetadataInstructions().build());
384 flow.setMatch(createMatch1().build());
385 flow.setInstructions(createAppyActionInstruction20().build());
389 flow.setMatch(createMatch1().build());
390 flow.setInstructions(createAppyActionInstruction21().build());
394 flow.setMatch(createMatch1().build());
395 flow.setInstructions(createAppyActionInstruction22().build());
399 flow.setMatch(createMatch1().build());
400 flow.setInstructions(createAppyActionInstruction23(nodeBuilder.getId()).build());
404 flow.setMatch(createMatch1().build());
405 flow.setInstructions(createAppyActionInstruction24().build());
409 flow.setMatch(createMatch1().build());
410 flow.setInstructions(createAppyActionInstruction25().build());
414 flow.setMatch(createMatch1().build());
415 flow.setInstructions(createAppyActionInstruction26().build());
419 flow.setMatch(createMatch1().build());
420 flow.setInstructions(createAppyActionInstruction27().build());
424 flow.setMatch(createMatch1().build());
425 flow.setInstructions(createAppyActionInstruction28().build());
429 flow.setMatch(createMatch1().build());
430 flow.setInstructions(createAppyActionInstruction29().build());
434 flow.setMatch(createMatch1().build());
435 flow.setInstructions(createAppyActionInstruction30().build());
439 flow.setMatch(createMatch1().build());
440 flow.setInstructions(createAppyActionInstruction31().build());
444 flow.setMatch(createMatch1().build());
445 flow.setInstructions(createAppyActionInstruction32().build());
449 flow.setMatch(createMatch1().build());
450 flow.setInstructions(createAppyActionInstruction33().build());
454 flow.setMatch(createMatch1().build());
455 flow.setInstructions(createAppyActionInstruction34().build());
459 flow.setMatch(createICMPv6Match().build());
460 flow.setInstructions(createDecNwTtlInstructions().build());
464 flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
465 flow.setInstructions(createDropInstructions().build());
469 flow.setMatch(createMetadataMatch().build());
470 flow.setInstructions(createDropInstructions().build());
474 flow.setMatch(createL3IPv6Match().build());
475 flow.setInstructions(createDecNwTtlInstructions().build());
479 flow.setMatch(createL4SCTPMatch().build());
480 flow.setInstructions(createAppyActionInstruction().build());
484 flow.setMatch(createTunnelIDMatch().build());
485 flow.setInstructions(createGotoTableInstructions().build());
489 flow.setMatch(createVlanMatch().build());
490 flow.setInstructions(createMeterInstructions().build());
494 flow.setMatch(createPbbMatch().build());
495 flow.setInstructions(createMeterInstructions().build());
499 flow.setMatch(createVlanMatch().build());
500 flow.setInstructions(createDropInstructions().build());
504 flow.setMatch(createL4TCPMatch().build());
505 flow.setInstructions(createDropInstructions().build());
510 flow.setMatch(createL4UDPMatch().build());
511 flow.setInstructions(createDropInstructions().build());
515 flow.setMatch(new MatchBuilder().build());
516 flow.setInstructions(createSentToControllerInstructions().build());
521 flow.setMatch(createToSMatch().build());
522 flow.setInstructions(createDropInstructions().build());
526 flow.setMatch(createToSMatch().build());
527 flow.setInstructions(createOutputInstructions("INPORT", 10).build());
531 flow.setMatch(createToSMatch().build());
532 flow.setInstructions(createOutputInstructions("FLOOD", 20).build());
536 flow.setMatch(createToSMatch().build());
537 flow.setInstructions(createOutputInstructions("ALL", 30).build());
541 flow.setMatch(createToSMatch().build());
542 flow.setInstructions(createOutputInstructions("NORMAL", 40).build());
546 flow.setMatch(createToSMatch().build());
547 flow.setInstructions(createOutputInstructions("LOCAL", 50).build());
551 flow.setMatch(createToSMatch().build());
552 flow.setInstructions(createOutputInstructions("TABLE", 60).build());
556 flow.setMatch(createToSMatch().build());
557 flow.setInstructions(createOutputInstructions("NONE", 70).build());
561 flow.setMatch(createToSMatch().build());
562 flow.setInstructions(createStripVlanInstructions().build());
563 flow.setBarrier(Boolean.TRUE);
567 flow.setMatch(createMatch1().build());
568 flow.setInstructions(createAppyActionInstruction35().build());
572 flow.setMatch(createMatch1().build());
573 flow.setInstructions(createAppyActionInstruction36().build());
577 flow.setMatch(createMatch1().build());
578 flow.setInstructions(createAppyActionInstruction37().build());
582 flow.setMatch(createMatch1().build());
583 flow.setInstructions(createAppyActionInstruction38().build());
587 flow.setMatch(createL4TCPMatch().build());
588 flow.setInstructions(createAppyActionInstruction39().build());
592 flow.setMatch(createL4UDPMatch().build());
593 flow.setInstructions(createAppyActionInstruction40().build());
597 flow.setMatch(createL4SCTPMatch().build());
598 flow.setInstructions(createAppyActionInstruction41().build());
602 flow.setMatch(createICMPv4Match().build());
603 flow.setInstructions(createAppyActionInstruction42().build());
607 flow.setMatch(createArpMatch().build());
608 flow.setInstructions(createAppyActionInstruction43().build());
612 flow.setMatch(createL3IPv6Match().build());
613 flow.setInstructions(createAppyActionInstruction44().build());
617 flow.setMatch(createICMPv6Match().build());
618 flow.setInstructions(createAppyActionInstruction45().build());
622 flow.setMatch(createMplsMatch().build());
623 flow.setInstructions(createAppyActionInstruction46().build());
627 flow.setMatch(createPbbMatch().build());
628 flow.setInstructions(createAppyActionInstruction47().build());
632 flow.setMatch(createTunnelIDMatch().build());
633 flow.setInstructions(createAppyActionInstruction48().build());
637 flow.setMatch(createMatch33().build());
638 flow.setInstructions(createDropInstructions().build());
642 flow.setMatch(createICMPv6Match1().build());
643 flow.setInstructions(createDecNwTtlInstructions().build());
647 flow.setMatch(createVlanMatch().build());
648 flow.setInstructions(createAppyActionInstruction88().build());
652 flow.setMatch(createLLDPMatch().build());
653 flow.setInstructions(createSentToControllerInstructions().build());
657 flow.setMatch(createToSMatch().build());
658 flow.setInstructions(createOutputInstructions().build());
661 id += 83; // Test TCP_Flag Match
662 flow.setMatch(createTcpFlagMatch().build());
663 flow.setInstructions(createDropInstructions().build());
667 flow.setMatch(createVlanMatch().build()); // match vlan=10,dl_vlan_pcp=3
668 flow.setInstructions(createAppyActionInstruction88().build()); // vlan_pcp=4
671 id += 85; // Test Tunnel IPv4 Src (e.g. set_field:172.16.100.200->tun_src)
672 flow.setMatch(createMatch3().build());
673 flow.setInstructions(createTunnelIpv4SrcInstructions().build());
676 id += 86; // Test Tunnel IPv4 Dst (e.g. set_field:172.16.100.100->tun_dst)
677 flow.setMatch(createMatch1().build());
678 flow.setInstructions(createTunnelIpv4DstInstructions().build());
681 LOG.warn("flow type not understood: {}", flowType);
684 FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
685 if (null == flow.isBarrier()) {
686 flow.setBarrier(Boolean.FALSE);
688 // flow.setBufferId(new Long(12));
689 BigInteger value = new BigInteger("10", 10);
690 // BigInteger outputPort = new BigInteger("65535", 10);
691 flow.setCookie(new FlowCookie(value));
692 flow.setCookieMask(new FlowCookie(value));
693 flow.setHardTimeout(0);
694 flow.setIdleTimeout(0);
695 flow.setInstallHw(false);
696 flow.setStrict(false);
697 flow.setContainerName(null);
698 flow.setFlags(new FlowModFlags(false, false, false, false, true));
699 flow.setId(new FlowId("12"));
700 flow.setTableId(getTableId(tableId));
701 // commenting setOutGroup and setOutPort, as by default
703 // enable setOutGroup and setOutPort to enable output filtering
704 // flow.setOutGroup(new Long(2));
705 // set outport to OFPP_NONE (65535) to disable remove restriction for
707 // flow.setOutPort(outputPort);
710 flow.setFlowName(originalFlowName + "X" + flowType);
716 private FlowBuilder createTestFlow_perfTest(NodeBuilder nodeBuilder, String flowTypeArg, String tableId, int id) {
718 FlowBuilder flow = new FlowBuilder();
721 String flowType = flowTypeArg;
722 if (flowType == null) {
726 flow.setPriority(id);
731 flow.setMatch(createMatch1().build());
732 flow.setInstructions(createDecNwTtlInstructions().build());
735 LOG.warn("flow type not understood: {}", flowType);
738 FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
739 if (null == flow.isBarrier()) {
740 flow.setBarrier(Boolean.FALSE);
742 // flow.setBufferId(new Long(12));
743 BigInteger value = new BigInteger("10", 10);
744 // BigInteger outputPort = new BigInteger("65535", 10);
745 flow.setCookie(new FlowCookie(value));
746 flow.setCookieMask(new FlowCookie(value));
747 flow.setHardTimeout(0);
748 flow.setIdleTimeout(0);
749 flow.setInstallHw(false);
750 flow.setStrict(false);
751 flow.setContainerName(null);
752 flow.setFlags(new FlowModFlags(false, false, false, false, true));
753 flow.setId(new FlowId("12"));
754 flow.setTableId(getTableId(tableId));
755 // commenting setOutGroup and setOutPort, as by default
757 // enable setOutGroup and setOutPort to enable output filtering
758 // flow.setOutGroup(new Long(2));
759 // set outport to OFPP_NONE (65535) to disable remove restriction for
761 // flow.setOutPort(outputPort);
764 flow.setFlowName(originalFlowName + "X" + flowType);
769 private FlowBuilder createtablemiss(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
770 FlowBuilder flow = new FlowBuilder();
772 MatchBuilder matchBuilder = new MatchBuilder();
773 flow.setMatch(matchBuilder.build());
774 flow.setInstructions(createSentToControllerInstructions().build());
776 flow.setTableId((short) 0);
777 FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
783 private short getTableId(String tableId) {
786 table = Short.parseShort(tableId);
787 } catch (Exception ex) {
788 // ignore exception and continue with default value
798 private static InstructionsBuilder createDecNwTtlInstructions() {
799 DecNwTtlBuilder ta = new DecNwTtlBuilder();
800 DecNwTtl decNwTtl = ta.build();
801 ActionBuilder ab = new ActionBuilder();
802 ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
803 ab.setKey(new ActionKey(0));
804 // Add our drop action to a list
805 List<Action> actionList = new ArrayList<Action>();
806 actionList.add(ab.build());
808 // Create an Apply Action
809 ApplyActionsBuilder aab = new ApplyActionsBuilder();
810 aab.setAction(actionList);
812 // Wrap our Apply Action in an Instruction
813 InstructionBuilder ib = new InstructionBuilder();
814 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
815 ib.setKey(new InstructionKey(0));
818 // Put our Instruction in a list of Instructions
819 InstructionsBuilder isb = new InstructionsBuilder();
820 List<Instruction> instructions = new ArrayList<Instruction>();
821 instructions.add(ib.build());
822 ib.setKey(new InstructionKey(0));
823 isb.setInstruction(instructions);
830 private static InstructionsBuilder createMeterInstructions() {
832 MeterBuilder aab = new MeterBuilder();
833 aab.setMeterId(new MeterId(new Long(1)));
835 InstructionBuilder ib = new InstructionBuilder();
836 ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
838 // Put our Instruction in a list of Instructions
839 InstructionsBuilder isb = new InstructionsBuilder();
840 List<Instruction> instructions = new ArrayList<Instruction>();
841 ib.setKey(new InstructionKey(0));
842 instructions.add(ib.build());
843 isb.setInstruction(instructions);
847 private static InstructionsBuilder createMetadataInstructions() {
849 WriteMetadataBuilder aab = new WriteMetadataBuilder();
850 aab.setMetadata(new BigInteger("10", 10));
851 aab.setMetadataMask(new BigInteger("12", 10));
853 InstructionBuilder ib = new InstructionBuilder();
854 ib.setInstruction(new WriteMetadataCaseBuilder().setWriteMetadata(aab.build()).build());
856 // Put our Instruction in a list of Instructions
857 InstructionsBuilder isb = new InstructionsBuilder();
858 List<Instruction> instructions = new ArrayList<Instruction>();
859 ib.setKey(new InstructionKey(0));
860 instructions.add(ib.build());
861 isb.setInstruction(instructions);
865 private static InstructionsBuilder createGotoTableInstructions() {
867 GoToTableBuilder aab = new GoToTableBuilder();
868 aab.setTableId((short) 5);
870 InstructionBuilder ib = new InstructionBuilder();
871 ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
873 // Put our Instruction in a list of Instructions
874 InstructionsBuilder isb = new InstructionsBuilder();
875 List<Instruction> instructions = new ArrayList<Instruction>();
876 ib.setKey(new InstructionKey(0));
877 instructions.add(ib.build());
878 isb.setInstruction(instructions);
882 private static InstructionsBuilder createDropInstructions() {
883 DropActionBuilder dab = new DropActionBuilder();
884 DropAction dropAction = dab.build();
885 ActionBuilder ab = new ActionBuilder();
886 ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
887 ab.setKey(new ActionKey(0));
888 // Add our drop action to a list
889 List<Action> actionList = new ArrayList<Action>();
890 actionList.add(ab.build());
891 ab.setKey(new ActionKey(0));
892 // Create an Apply Action
893 ApplyActionsBuilder aab = new ApplyActionsBuilder();
894 aab.setAction(actionList);
896 // Wrap our Apply Action in an Instruction
897 InstructionBuilder ib = new InstructionBuilder();
898 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
900 // Put our Instruction in a list of Instructions
901 InstructionsBuilder isb = new InstructionsBuilder();
902 List<Instruction> instructions = new ArrayList<Instruction>();
903 ib.setKey(new InstructionKey(0));
904 instructions.add(ib.build());
905 isb.setInstruction(instructions);
909 private static InstructionsBuilder createAppyActionInstruction() {
911 List<Action> actionList = new ArrayList<Action>();
912 ActionBuilder ab = new ActionBuilder();
913 ControllerActionBuilder controller = new ControllerActionBuilder();
914 controller.setMaxLength(5);
915 ab.setAction(new ControllerActionCaseBuilder().setControllerAction(controller.build()).build());
916 ab.setKey(new ActionKey(0));
917 actionList.add(ab.build());
918 // Create an Apply Action
919 ApplyActionsBuilder aab = new ApplyActionsBuilder();
920 aab.setAction(actionList);
922 // Wrap our Apply Action in an Instruction
923 InstructionBuilder ib = new InstructionBuilder();
924 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
926 // Put our Instruction in a list of Instructions
927 InstructionsBuilder isb = new InstructionsBuilder();
928 List<Instruction> instructions = new ArrayList<Instruction>();
929 ib.setKey(new InstructionKey(0));
930 instructions.add(ib.build());
931 isb.setInstruction(instructions);
935 private static InstructionsBuilder createAppyActionInstruction1() {
937 List<Action> actionList = new ArrayList<Action>();
938 ActionBuilder ab = new ActionBuilder();
940 OutputActionBuilder output = new OutputActionBuilder();
941 output.setMaxLength(56);
942 Uri value = new Uri("PCEP");
943 output.setOutputNodeConnector(value);
944 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
945 ab.setKey(new ActionKey(0));
946 actionList.add(ab.build());
947 // Create an Apply Action
948 ApplyActionsBuilder aab = new ApplyActionsBuilder();
949 aab.setAction(actionList);
951 // Wrap our Apply Action in an Instruction
952 InstructionBuilder ib = new InstructionBuilder();
953 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
955 // Put our Instruction in a list of Instructions
956 InstructionsBuilder isb = new InstructionsBuilder();
957 List<Instruction> instructions = new ArrayList<Instruction>();
958 ib.setKey(new InstructionKey(0));
959 instructions.add(ib.build());
960 isb.setInstruction(instructions);
964 private static InstructionsBuilder createOutputInstructions() {
966 // test case for Output Port works if the particular port exists
967 // this particular test-case is for Port : 1
968 // tested as (addMDFlow openflow:<dpid> f82)
969 List<Action> actionList = new ArrayList<Action>();
970 ActionBuilder ab = new ActionBuilder();
971 OutputActionBuilder output = new OutputActionBuilder();
973 Uri value = new Uri("1");
974 output.setOutputNodeConnector(value);
975 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
977 ab.setKey(new ActionKey(0));
978 actionList.add(ab.build());
979 // Create an Apply Action
980 ApplyActionsBuilder aab = new ApplyActionsBuilder();
981 aab.setAction(actionList);
983 // Wrap our Apply Action in an Instruction
984 InstructionBuilder ib = new InstructionBuilder();
985 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
987 ib.setKey(new InstructionKey(0));
989 // Put our Instruction in a list of Instructions
990 InstructionsBuilder isb = new InstructionsBuilder();
991 List<Instruction> instructions = new ArrayList<Instruction>();
992 instructions.add(ib.build());
993 isb.setInstruction(instructions);
997 private static InstructionsBuilder createSentToControllerInstructions() {
998 List<Action> actionList = new ArrayList<Action>();
999 ActionBuilder ab = new ActionBuilder();
1001 OutputActionBuilder output = new OutputActionBuilder();
1002 output.setMaxLength(new Integer(0xffff));
1003 Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
1004 output.setOutputNodeConnector(value);
1005 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
1007 ab.setKey(new ActionKey(0));
1008 actionList.add(ab.build());
1009 // Create an Apply Action
1010 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1011 aab.setAction(actionList);
1013 // Wrap our Apply Action in an Instruction
1014 InstructionBuilder ib = new InstructionBuilder();
1015 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1017 ib.setKey(new InstructionKey(0));
1019 // Put our Instruction in a list of Instructions
1020 InstructionsBuilder isb = new InstructionsBuilder();
1021 List<Instruction> instructions = new ArrayList<Instruction>();
1022 instructions.add(ib.build());
1023 isb.setInstruction(instructions);
1027 private static InstructionsBuilder createOutputInstructions(String outputType, int outputValue) {
1028 List<Action> actionList = new ArrayList<Action>();
1029 ActionBuilder ab = new ActionBuilder();
1031 OutputActionBuilder output = new OutputActionBuilder();
1032 output.setMaxLength(outputValue);
1033 Uri value = new Uri(outputType);
1034 output.setOutputNodeConnector(value);
1035 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
1037 ab.setKey(new ActionKey(0));
1038 actionList.add(ab.build());
1039 // Create an Apply Action
1040 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1041 aab.setAction(actionList);
1043 // Wrap our Apply Action in an Instruction
1044 InstructionBuilder ib = new InstructionBuilder();
1045 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1047 ib.setKey(new InstructionKey(0));
1049 // Put our Instruction in a list of Instructions
1050 InstructionsBuilder isb = new InstructionsBuilder();
1051 List<Instruction> instructions = new ArrayList<Instruction>();
1052 instructions.add(ib.build());
1053 isb.setInstruction(instructions);
1057 private static InstructionsBuilder createStripVlanInstructions() {
1058 List<Action> actionList = new ArrayList<Action>();
1059 ActionBuilder ab = new ActionBuilder();
1061 StripVlanActionBuilder stripActionBuilder = new StripVlanActionBuilder();
1062 ab.setAction(new StripVlanActionCaseBuilder().setStripVlanAction(stripActionBuilder.build()).build());
1064 ab.setKey(new ActionKey(0));
1065 actionList.add(ab.build());
1066 // Create an Apply Action
1067 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1068 aab.setAction(actionList);
1070 // Wrap our Apply Action in an Instruction
1071 InstructionBuilder ib = new InstructionBuilder();
1072 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1074 ib.setKey(new InstructionKey(0));
1076 // Put our Instruction in a list of Instructions
1077 InstructionsBuilder isb = new InstructionsBuilder();
1078 List<Instruction> instructions = new ArrayList<Instruction>();
1079 instructions.add(ib.build());
1080 isb.setInstruction(instructions);
1084 private static InstructionsBuilder createAppyActionInstruction2() {
1086 List<Action> actionList = new ArrayList<Action>();
1087 ActionBuilder ab = new ActionBuilder();
1089 PushMplsActionBuilder push = new PushMplsActionBuilder();
1090 push.setEthernetType(new Integer(0x8847));
1091 ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
1092 ab.setKey(new ActionKey(0));
1093 actionList.add(ab.build());
1094 // Create an Apply Action
1095 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1096 aab.setAction(actionList);
1098 // Wrap our Apply Action in an Instruction
1099 InstructionBuilder ib = new InstructionBuilder();
1100 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1102 // Put our Instruction in a list of Instructions
1103 InstructionsBuilder isb = new InstructionsBuilder();
1104 List<Instruction> instructions = new ArrayList<Instruction>();
1105 ib.setKey(new InstructionKey(0));
1106 instructions.add(ib.build());
1107 isb.setInstruction(instructions);
1111 private static InstructionsBuilder createAppyActionInstruction3() {
1113 List<Action> actionList = new ArrayList<Action>();
1114 ActionBuilder ab = new ActionBuilder();
1116 PushPbbActionBuilder pbb = new PushPbbActionBuilder();
1117 pbb.setEthernetType(new Integer(0x88E7));
1118 ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
1119 ab.setKey(new ActionKey(0));
1120 actionList.add(ab.build());
1121 // Create an Apply Action
1122 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1123 aab.setAction(actionList);
1125 // Wrap our Apply Action in an Instruction
1126 InstructionBuilder ib = new InstructionBuilder();
1127 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1129 // Put our Instruction in a list of Instructions
1130 InstructionsBuilder isb = new InstructionsBuilder();
1131 List<Instruction> instructions = new ArrayList<Instruction>();
1132 ib.setKey(new InstructionKey(0));
1133 instructions.add(ib.build());
1134 isb.setInstruction(instructions);
1138 private static InstructionsBuilder createAppyActionInstruction4() {
1140 List<Action> actionList = new ArrayList<Action>();
1141 ActionBuilder ab = new ActionBuilder();
1143 PushVlanActionBuilder vlan = new PushVlanActionBuilder();
1144 vlan.setEthernetType(new Integer(0x8100));
1145 ab.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
1146 ab.setKey(new ActionKey(0));
1147 actionList.add(ab.build());
1149 // Create an Apply Action
1150 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1151 aab.setAction(actionList);
1153 // Wrap our Apply Action in an Instruction
1154 InstructionBuilder ib = new InstructionBuilder();
1155 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1157 // Put our Instruction in a list of Instructions
1158 InstructionsBuilder isb = new InstructionsBuilder();
1159 List<Instruction> instructions = new ArrayList<Instruction>();
1160 ib.setKey(new InstructionKey(0));
1161 instructions.add(ib.build());
1162 isb.setInstruction(instructions);
1166 private static InstructionsBuilder createAppyActionInstruction5() {
1168 List<Action> actionList = new ArrayList<Action>();
1169 ActionBuilder ab = new ActionBuilder();
1171 SetDlDstActionBuilder setdl = new SetDlDstActionBuilder();
1172 setdl.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1173 ab.setAction(new SetDlDstActionCaseBuilder().setSetDlDstAction(setdl.build()).build());
1174 ab.setKey(new ActionKey(0));
1175 actionList.add(ab.build());
1176 // Create an Apply Action
1177 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1178 aab.setAction(actionList);
1180 // Wrap our Apply Action in an Instruction
1181 InstructionBuilder ib = new InstructionBuilder();
1182 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1184 // Put our Instruction in a list of Instructions
1185 InstructionsBuilder isb = new InstructionsBuilder();
1186 List<Instruction> instructions = new ArrayList<Instruction>();
1187 ib.setKey(new InstructionKey(0));
1188 instructions.add(ib.build());
1189 isb.setInstruction(instructions);
1193 private static InstructionsBuilder createAppyActionInstruction6() {
1195 List<Action> actionList = new ArrayList<Action>();
1196 ActionBuilder ab = new ActionBuilder();
1198 SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
1199 src.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1200 ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(src.build()).build());
1201 ab.setKey(new ActionKey(0));
1202 actionList.add(ab.build());
1204 // Create an Apply Action
1205 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1206 aab.setAction(actionList);
1208 // Wrap our Apply Action in an Instruction
1209 InstructionBuilder ib = new InstructionBuilder();
1210 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1212 // Put our Instruction in a list of Instructions
1213 InstructionsBuilder isb = new InstructionsBuilder();
1214 List<Instruction> instructions = new ArrayList<Instruction>();
1215 ib.setKey(new InstructionKey(0));
1216 instructions.add(ib.build());
1217 isb.setInstruction(instructions);
1221 private static InstructionsBuilder createAppyActionInstruction7() {
1223 List<Action> actionList = new ArrayList<Action>();
1224 ActionBuilder ab = new ActionBuilder();
1226 SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
1227 VlanId a = new VlanId(4000);
1229 ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
1230 ab.setKey(new ActionKey(0));
1231 actionList.add(ab.build());
1232 // Create an Apply Action
1233 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1234 aab.setAction(actionList);
1236 // Wrap our Apply Action in an Instruction
1237 InstructionBuilder ib = new InstructionBuilder();
1238 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1240 // Put our Instruction in a list of Instructions
1241 InstructionsBuilder isb = new InstructionsBuilder();
1242 List<Instruction> instructions = new ArrayList<Instruction>();
1243 ib.setKey(new InstructionKey(0));
1244 instructions.add(ib.build());
1245 isb.setInstruction(instructions);
1249 private static InstructionsBuilder createAppyActionInstruction8() {
1251 List<Action> actionList = new ArrayList<Action>();
1252 ActionBuilder ab = new ActionBuilder();
1254 SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
1255 VlanPcp pcp1 = new VlanPcp((short) 2);
1256 pcp.setVlanPcp(pcp1);
1257 ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
1258 ab.setKey(new ActionKey(0));
1259 actionList.add(ab.build());
1260 // Create an Apply Action
1261 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1262 aab.setAction(actionList);
1264 // Wrap our Apply Action in an Instruction
1265 InstructionBuilder ib = new InstructionBuilder();
1266 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1268 // Put our Instruction in a list of Instructions
1269 InstructionsBuilder isb = new InstructionsBuilder();
1270 List<Instruction> instructions = new ArrayList<Instruction>();
1271 ib.setKey(new InstructionKey(0));
1272 instructions.add(ib.build());
1273 isb.setInstruction(instructions);
1277 private static InstructionsBuilder createAppyActionInstruction88() {
1279 List<Action> actionList = new ArrayList<Action>();
1280 ActionBuilder ab = new ActionBuilder();
1282 SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
1283 // the code point is a 3-bit(0-7) field representing the frame priority level
1284 VlanPcp pcp1 = new VlanPcp((short) 4);
1285 pcp.setVlanPcp(pcp1);
1286 ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
1287 ab.setKey(new ActionKey(0));
1288 actionList.add(ab.build());
1289 // Create an Apply Action
1290 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1291 aab.setAction(actionList);
1293 // Wrap our Apply Action in an Instruction
1294 InstructionBuilder ib = new InstructionBuilder();
1295 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1297 // Put our Instruction in a list of Instructions
1298 InstructionsBuilder isb = new InstructionsBuilder();
1299 List<Instruction> instructions = new ArrayList<Instruction>();
1300 ib.setKey(new InstructionKey(0));
1301 instructions.add(ib.build());
1302 isb.setInstruction(instructions);
1306 private static InstructionsBuilder createAppyActionInstruction9() {
1308 List<Action> actionList = new ArrayList<Action>();
1309 ActionBuilder ab = new ActionBuilder();
1311 CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
1312 ab.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
1313 ab.setKey(new ActionKey(0));
1314 actionList.add(ab.build());
1315 // Create an Apply Action
1316 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1317 aab.setAction(actionList);
1319 // Wrap our Apply Action in an Instruction
1320 InstructionBuilder ib = new InstructionBuilder();
1321 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1323 // Put our Instruction in a list of Instructions
1324 InstructionsBuilder isb = new InstructionsBuilder();
1325 List<Instruction> instructions = new ArrayList<Instruction>();
1326 ib.setKey(new InstructionKey(0));
1327 instructions.add(ib.build());
1328 isb.setInstruction(instructions);
1332 private static InstructionsBuilder createAppyActionInstruction10() {
1334 List<Action> actionList = new ArrayList<Action>();
1335 ActionBuilder ab = new ActionBuilder();
1337 CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
1338 ab.setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(ttlout.build()).build());
1339 ab.setKey(new ActionKey(0));
1340 actionList.add(ab.build());
1341 // Create an Apply Action
1342 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1343 aab.setAction(actionList);
1345 // Wrap our Apply Action in an Instruction
1346 InstructionBuilder ib = new InstructionBuilder();
1347 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1349 // Put our Instruction in a list of Instructions
1350 InstructionsBuilder isb = new InstructionsBuilder();
1351 List<Instruction> instructions = new ArrayList<Instruction>();
1352 ib.setKey(new InstructionKey(0));
1353 instructions.add(ib.build());
1354 isb.setInstruction(instructions);
1358 private static InstructionsBuilder createAppyActionInstruction11() {
1360 List<Action> actionList = new ArrayList<Action>();
1361 ActionBuilder ab = new ActionBuilder();
1363 DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
1364 ab.setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(mpls.build()).build());
1365 ab.setKey(new ActionKey(0));
1366 actionList.add(ab.build());
1367 // Create an Apply Action
1368 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1369 aab.setAction(actionList);
1371 // Wrap our Apply Action in an Instruction
1372 InstructionBuilder ib = new InstructionBuilder();
1373 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1374 ib.setKey(new InstructionKey(0));
1377 // Put our Instruction in a list of Instruction
1378 InstructionsBuilder isb = new InstructionsBuilder();
1379 List<Instruction> instructions = new ArrayList<Instruction>();
1380 instructions.add(ib.build());
1381 isb.setInstruction(instructions);
1385 private static InstructionsBuilder createAppyActionInstruction12() {
1387 List<Action> actionList = new ArrayList<Action>();
1388 ActionBuilder ab = new ActionBuilder();
1390 DecNwTtlBuilder nwttl = new DecNwTtlBuilder();
1391 ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(nwttl.build()).build());
1392 ab.setKey(new ActionKey(0));
1393 actionList.add(ab.build());
1395 // Create an Apply Action
1396 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1397 aab.setAction(actionList);
1399 // Wrap our Apply Action in an Instruction
1400 InstructionBuilder ib = new InstructionBuilder();
1401 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1403 // Put our Instruction in a list of Instructions
1404 InstructionsBuilder isb = new InstructionsBuilder();
1405 List<Instruction> instructions = new ArrayList<Instruction>();
1406 ib.setKey(new InstructionKey(0));
1407 instructions.add(ib.build());
1408 isb.setInstruction(instructions);
1412 private static InstructionsBuilder createAppyActionInstruction13() {
1414 List<Action> actionList = new ArrayList<Action>();
1415 ActionBuilder ab = new ActionBuilder();
1417 DropActionBuilder drop = new DropActionBuilder();
1418 ab.setAction(new DropActionCaseBuilder().setDropAction(drop.build()).build());
1419 ab.setKey(new ActionKey(0));
1420 actionList.add(ab.build());
1422 // Create an Apply Action
1423 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1424 aab.setAction(actionList);
1426 // Wrap our Apply Action in an Instruction
1427 InstructionBuilder ib = new InstructionBuilder();
1428 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1430 // Put our Instruction in a list of Instructions
1431 InstructionsBuilder isb = new InstructionsBuilder();
1432 List<Instruction> instructions = new ArrayList<Instruction>();
1433 ib.setKey(new InstructionKey(0));
1434 instructions.add(ib.build());
1435 isb.setInstruction(instructions);
1439 private static InstructionsBuilder createAppyActionInstruction14() {
1441 List<Action> actionList = new ArrayList<Action>();
1442 ActionBuilder ab = new ActionBuilder();
1444 FloodActionBuilder fld = new FloodActionBuilder();
1445 ab.setAction(new FloodActionCaseBuilder().setFloodAction(fld.build()).build());
1446 ab.setKey(new ActionKey(0));
1447 actionList.add(ab.build());
1448 // Create an Apply Action
1449 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1450 aab.setAction(actionList);
1452 // Wrap our Apply Action in an Instruction
1453 InstructionBuilder ib = new InstructionBuilder();
1454 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1456 // Put our Instruction in a list of Instructions
1457 InstructionsBuilder isb = new InstructionsBuilder();
1458 List<Instruction> instructions = new ArrayList<Instruction>();
1459 ib.setKey(new InstructionKey(0));
1460 instructions.add(ib.build());
1461 isb.setInstruction(instructions);
1465 private static InstructionsBuilder createAppyActionInstruction15() {
1467 List<Action> actionList = new ArrayList<Action>();
1468 ActionBuilder ab = new ActionBuilder();
1470 FloodAllActionBuilder fldall = new FloodAllActionBuilder();
1471 ab.setAction(new FloodAllActionCaseBuilder().setFloodAllAction(fldall.build()).build());
1472 ab.setKey(new ActionKey(0));
1473 actionList.add(ab.build());
1474 // Create an Apply Action
1475 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1476 aab.setAction(actionList);
1478 // Wrap our Apply Action in an Instruction
1479 InstructionBuilder ib = new InstructionBuilder();
1480 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1482 // Put our Instruction in a list of Instructions
1483 InstructionsBuilder isb = new InstructionsBuilder();
1484 List<Instruction> instructions = new ArrayList<Instruction>();
1485 ib.setKey(new InstructionKey(0));
1486 instructions.add(ib.build());
1487 isb.setInstruction(instructions);
1491 private static InstructionsBuilder createAppyActionInstruction16() {
1493 List<Action> actionList = new ArrayList<Action>();
1494 ActionBuilder ab = new ActionBuilder();
1496 GroupActionBuilder groupActionB = new GroupActionBuilder();
1497 groupActionB.setGroupId(1L);
1498 groupActionB.setGroup("0");
1499 ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
1500 ab.setKey(new ActionKey(0));
1501 actionList.add(ab.build());
1503 // Create an Apply Action
1504 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1505 aab.setAction(actionList);
1507 // Wrap our Apply Action in an Instruction
1508 InstructionBuilder ib = new InstructionBuilder();
1509 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1511 // Put our Instruction in a list of Instructions
1512 InstructionsBuilder isb = new InstructionsBuilder();
1513 List<Instruction> instructions = new ArrayList<Instruction>();
1514 ib.setKey(new InstructionKey(0));
1515 instructions.add(ib.build());
1516 isb.setInstruction(instructions);
1520 private static InstructionsBuilder createAppyActionInstruction17() {
1522 List<Action> actionList = new ArrayList<Action>();
1523 ActionBuilder ab = new ActionBuilder();
1525 HwPathActionBuilder hwPathB = new HwPathActionBuilder();
1526 ab.setAction(new HwPathActionCaseBuilder().setHwPathAction(hwPathB.build()).build());
1527 ab.setKey(new ActionKey(0));
1528 actionList.add(ab.build());
1529 // Create an Apply Action
1530 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1531 aab.setAction(actionList);
1533 // Wrap our Apply Action in an Instruction
1534 InstructionBuilder ib = new InstructionBuilder();
1535 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1537 // Put our Instruction in a list of Instructions
1538 InstructionsBuilder isb = new InstructionsBuilder();
1539 List<Instruction> instructions = new ArrayList<Instruction>();
1540 ib.setKey(new InstructionKey(0));
1541 instructions.add(ib.build());
1542 isb.setInstruction(instructions);
1546 private static InstructionsBuilder createAppyActionInstruction18() {
1548 List<Action> actionList = new ArrayList<Action>();
1549 ActionBuilder ab = new ActionBuilder();
1551 LoopbackActionBuilder loopbackActionBuilder = new LoopbackActionBuilder();
1552 ab.setAction(new LoopbackActionCaseBuilder().setLoopbackAction(loopbackActionBuilder.build()).build());
1553 ab.setKey(new ActionKey(0));
1554 actionList.add(ab.build());
1556 // Create an Apply Action
1557 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1558 aab.setAction(actionList);
1560 // Wrap our Apply Action in an Instruction
1561 InstructionBuilder ib = new InstructionBuilder();
1562 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1564 // Put our Instruction in a list of Instructions
1565 InstructionsBuilder isb = new InstructionsBuilder();
1566 List<Instruction> instructions = new ArrayList<Instruction>();
1567 ib.setKey(new InstructionKey(0));
1568 instructions.add(ib.build());
1569 isb.setInstruction(instructions);
1573 private static InstructionsBuilder createAppyActionInstruction19() {
1575 List<Action> actionList = new ArrayList<Action>();
1576 ActionBuilder ab = new ActionBuilder();
1578 PopMplsActionBuilder popMplsActionBuilder = new PopMplsActionBuilder();
1579 popMplsActionBuilder.setEthernetType(0XB);
1580 ab.setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsActionBuilder.build()).build());
1581 ab.setKey(new ActionKey(0));
1582 actionList.add(ab.build());
1583 // Create an Apply Action
1584 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1585 aab.setAction(actionList);
1587 // Wrap our Apply Action in an Instruction
1588 InstructionBuilder ib = new InstructionBuilder();
1589 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1591 // Put our Instruction in a list of Instructions
1592 InstructionsBuilder isb = new InstructionsBuilder();
1593 List<Instruction> instructions = new ArrayList<Instruction>();
1594 ib.setKey(new InstructionKey(0));
1595 instructions.add(ib.build());
1596 isb.setInstruction(instructions);
1600 private static InstructionsBuilder createAppyActionInstruction20() {
1602 List<Action> actionList = new ArrayList<Action>();
1603 ActionBuilder ab = new ActionBuilder();
1605 PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
1606 ab.setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPbbActionBuilder.build()).build());
1607 ab.setKey(new ActionKey(0));
1608 actionList.add(ab.build());
1609 // Create an Apply Action
1610 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1611 aab.setAction(actionList);
1613 // Wrap our Apply Action in an Instruction
1614 InstructionBuilder ib = new InstructionBuilder();
1615 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1617 // Put our Instruction in a list of Instructions
1618 InstructionsBuilder isb = new InstructionsBuilder();
1619 List<Instruction> instructions = new ArrayList<Instruction>();
1620 ib.setKey(new InstructionKey(0));
1621 instructions.add(ib.build());
1622 isb.setInstruction(instructions);
1626 private static InstructionsBuilder createAppyActionInstruction21() {
1628 List<Action> actionList = new ArrayList<Action>();
1629 ActionBuilder ab = new ActionBuilder();
1631 PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
1632 ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
1633 ab.setKey(new ActionKey(0));
1634 actionList.add(ab.build());
1636 // Create an Apply Action
1637 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1638 aab.setAction(actionList);
1640 // Wrap our Apply Action in an Instruction
1641 InstructionBuilder ib = new InstructionBuilder();
1642 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1644 // Put our Instruction in a list of Instructions
1645 InstructionsBuilder isb = new InstructionsBuilder();
1646 List<Instruction> instructions = new ArrayList<Instruction>();
1647 ib.setKey(new InstructionKey(0));
1648 instructions.add(ib.build());
1649 isb.setInstruction(instructions);
1653 private static InstructionsBuilder createAppyActionInstruction22() {
1655 List<Action> actionList = new ArrayList<Action>();
1656 ActionBuilder ab = new ActionBuilder();
1658 SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
1659 setDlTypeActionBuilder.setDlType(new EtherType(8L));
1660 ab.setAction(new SetDlTypeActionCaseBuilder().setSetDlTypeAction(setDlTypeActionBuilder.build()).build());
1661 ab.setKey(new ActionKey(0));
1662 actionList.add(ab.build());
1664 // Create an Apply Action
1665 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1666 aab.setAction(actionList);
1668 // Wrap our Apply Action in an Instruction
1669 InstructionBuilder ib = new InstructionBuilder();
1670 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1672 // Put our Instruction in a list of Instructions
1673 InstructionsBuilder isb = new InstructionsBuilder();
1674 List<Instruction> instructions = new ArrayList<Instruction>();
1675 ib.setKey(new InstructionKey(0));
1676 instructions.add(ib.build());
1677 isb.setInstruction(instructions);
1681 private static InstructionsBuilder createAppyActionInstruction23(NodeId nodeId) {
1683 List<Action> actionList = new ArrayList<Action>();
1684 ActionBuilder ab = new ActionBuilder();
1686 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1687 setFieldBuilder.setInPort(new NodeConnectorId(nodeId + ":2"));
1688 ab.setKey(new ActionKey(0));
1689 actionList.add(ab.build());
1691 // Create an Apply Action
1692 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1693 aab.setAction(actionList);
1695 // Wrap our Apply Action in an Instruction
1696 InstructionBuilder ib = new InstructionBuilder();
1697 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1699 // Put our Instruction in a list of Instructions
1700 InstructionsBuilder isb = new InstructionsBuilder();
1701 List<Instruction> instructions = new ArrayList<Instruction>();
1702 ib.setKey(new InstructionKey(0));
1703 instructions.add(ib.build());
1704 isb.setInstruction(instructions);
1708 private static InstructionsBuilder createAppyActionInstruction24() {
1710 List<Action> actionList = new ArrayList<Action>();
1711 ActionBuilder ab = new ActionBuilder();
1713 SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
1714 setMplsTtlActionBuilder.setMplsTtl((short) 0X1);
1715 ab.setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMplsTtlActionBuilder.build()).build());
1716 ab.setKey(new ActionKey(0));
1717 actionList.add(ab.build());
1719 // Create an Apply Action
1720 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1721 aab.setAction(actionList);
1723 // Wrap our Apply Action in an Instruction
1724 InstructionBuilder ib = new InstructionBuilder();
1725 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1727 // Put our Instruction in a list of Instructions
1728 InstructionsBuilder isb = new InstructionsBuilder();
1729 List<Instruction> instructions = new ArrayList<Instruction>();
1730 ib.setKey(new InstructionKey(0));
1731 instructions.add(ib.build());
1732 isb.setInstruction(instructions);
1736 private static InstructionsBuilder createAppyActionInstruction25() {
1738 List<Action> actionList = new ArrayList<Action>();
1739 ActionBuilder ab = new ActionBuilder();
1741 SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
1742 Ipv4Builder ipnext = new Ipv4Builder();
1743 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
1744 ipnext.setIpv4Address(prefix);
1745 setNextHopActionBuilder.setAddress(ipnext.build());
1746 ab.setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilder.build()).build());
1747 ab.setKey(new ActionKey(0));
1748 actionList.add(ab.build());
1750 // Create an Apply Action
1751 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1752 aab.setAction(actionList);
1754 // Wrap our Apply Action in an Instruction
1755 InstructionBuilder ib = new InstructionBuilder();
1756 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1758 // Put our Instruction in a list of Instructions
1759 InstructionsBuilder isb = new InstructionsBuilder();
1760 List<Instruction> instructions = new ArrayList<Instruction>();
1761 ib.setKey(new InstructionKey(0));
1762 instructions.add(ib.build());
1763 isb.setInstruction(instructions);
1767 private static InstructionsBuilder createAppyActionInstruction26() {
1769 List<Action> actionList = new ArrayList<Action>();
1770 ActionBuilder ab = new ActionBuilder();
1772 SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
1773 Ipv4Builder ipdst = new Ipv4Builder();
1774 Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
1775 ipdst.setIpv4Address(prefixdst);
1776 setNwDstActionBuilder.setAddress(ipdst.build());
1777 ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
1778 ab.setKey(new ActionKey(0));
1779 actionList.add(ab.build());
1781 // Create an Apply Action
1782 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1783 aab.setAction(actionList);
1785 // Wrap our Apply Action in an Instruction
1786 InstructionBuilder ib = new InstructionBuilder();
1787 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1789 // Put our Instruction in a list of Instructions
1790 InstructionsBuilder isb = new InstructionsBuilder();
1791 List<Instruction> instructions = new ArrayList<Instruction>();
1792 ib.setKey(new InstructionKey(0));
1793 instructions.add(ib.build());
1794 isb.setInstruction(instructions);
1798 private static InstructionsBuilder createAppyActionInstruction27() {
1800 List<Action> actionList = new ArrayList<Action>();
1801 ActionBuilder ab = new ActionBuilder();
1803 SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
1804 Ipv4Builder ipsrc = new Ipv4Builder();
1805 Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
1806 ipsrc.setIpv4Address(prefixsrc);
1807 setNwsrcActionBuilder.setAddress(ipsrc.build());
1808 ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
1809 ab.setKey(new ActionKey(0));
1810 actionList.add(ab.build());
1812 // Create an Apply Action
1813 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1814 aab.setAction(actionList);
1816 // Wrap our Apply Action in an Instruction
1817 InstructionBuilder ib = new InstructionBuilder();
1818 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1820 // Put our Instruction in a list of Instructions
1821 InstructionsBuilder isb = new InstructionsBuilder();
1822 List<Instruction> instructions = new ArrayList<Instruction>();
1823 ib.setKey(new InstructionKey(0));
1824 instructions.add(ib.build());
1825 isb.setInstruction(instructions);
1829 private static InstructionsBuilder createAppyActionInstruction28() {
1831 List<Action> actionList = new ArrayList<Action>();
1832 ActionBuilder ab = new ActionBuilder();
1834 SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
1835 setNwTosActionBuilder.setTos(8);
1836 ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.build()).build());
1837 ab.setKey(new ActionKey(0));
1838 actionList.add(ab.build());
1839 // Create an Apply Action
1840 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1841 aab.setAction(actionList);
1843 // Wrap our Apply Action in an Instruction
1844 InstructionBuilder ib = new InstructionBuilder();
1845 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1847 // Put our Instruction in a list of Instructions
1848 InstructionsBuilder isb = new InstructionsBuilder();
1849 List<Instruction> instructions = new ArrayList<Instruction>();
1850 ib.setKey(new InstructionKey(0));
1851 instructions.add(ib.build());
1852 isb.setInstruction(instructions);
1856 private static InstructionsBuilder createAppyActionInstruction29() {
1858 List<Action> actionList = new ArrayList<Action>();
1859 ActionBuilder ab = new ActionBuilder();
1861 SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
1862 setNwTtlActionBuilder.setNwTtl((short) 1);
1863 ab.setAction(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
1864 ab.setKey(new ActionKey(0));
1865 actionList.add(ab.build());
1867 // Create an Apply Action
1868 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1869 aab.setAction(actionList);
1871 // Wrap our Apply Action in an Instruction
1872 InstructionBuilder ib = new InstructionBuilder();
1873 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1875 // Put our Instruction in a list of Instructions
1876 InstructionsBuilder isb = new InstructionsBuilder();
1877 List<Instruction> instructions = new ArrayList<Instruction>();
1878 ib.setKey(new InstructionKey(0));
1879 instructions.add(ib.build());
1880 isb.setInstruction(instructions);
1884 private static InstructionsBuilder createAppyActionInstruction30() {
1886 List<Action> actionList = new ArrayList<Action>();
1887 ActionBuilder ab = new ActionBuilder();
1889 SetQueueActionBuilder setQueueActionBuilder = new SetQueueActionBuilder();
1890 setQueueActionBuilder.setQueueId(1L);
1891 ab.setAction(new SetQueueActionCaseBuilder().setSetQueueAction(setQueueActionBuilder.build()).build());
1892 ab.setKey(new ActionKey(0));
1893 actionList.add(ab.build());
1894 // Create an Apply Action
1895 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1896 aab.setAction(actionList);
1898 // Wrap our Apply Action in an Instruction
1899 InstructionBuilder ib = new InstructionBuilder();
1900 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1902 // Put our Instruction in a list of Instructions
1903 InstructionsBuilder isb = new InstructionsBuilder();
1904 List<Instruction> instructions = new ArrayList<Instruction>();
1905 ib.setKey(new InstructionKey(0));
1906 instructions.add(ib.build());
1907 isb.setInstruction(instructions);
1911 private static InstructionsBuilder createAppyActionInstruction31() {
1913 List<Action> actionList = new ArrayList<Action>();
1914 ActionBuilder ab = new ActionBuilder();
1916 SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
1917 setTpDstActionBuilder.setPort(new PortNumber(109));
1919 ab.setAction(new SetTpDstActionCaseBuilder().setSetTpDstAction(setTpDstActionBuilder.build()).build());
1920 ab.setKey(new ActionKey(0));
1921 actionList.add(ab.build());
1922 // Create an Apply Action
1923 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1924 aab.setAction(actionList);
1926 // Wrap our Apply Action in an Instruction
1927 InstructionBuilder ib = new InstructionBuilder();
1928 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1930 // Put our Instruction in a list of Instructions
1931 InstructionsBuilder isb = new InstructionsBuilder();
1932 List<Instruction> instructions = new ArrayList<Instruction>();
1933 ib.setKey(new InstructionKey(0));
1934 instructions.add(ib.build());
1935 isb.setInstruction(instructions);
1939 private static InstructionsBuilder createAppyActionInstruction32() {
1941 List<Action> actionList = new ArrayList<Action>();
1942 ActionBuilder ab = new ActionBuilder();
1944 SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
1945 setTpSrcActionBuilder.setPort(new PortNumber(109));
1946 ab.setAction(new SetTpSrcActionCaseBuilder().setSetTpSrcAction(setTpSrcActionBuilder.build()).build());
1947 ab.setKey(new ActionKey(0));
1948 actionList.add(ab.build());
1950 // Create an Apply Action
1951 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1952 aab.setAction(actionList);
1954 // Wrap our Apply Action in an Instruction
1955 InstructionBuilder ib = new InstructionBuilder();
1956 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1958 // Put our Instruction in a list of Instructions
1959 InstructionsBuilder isb = new InstructionsBuilder();
1960 List<Instruction> instructions = new ArrayList<Instruction>();
1961 ib.setKey(new InstructionKey(0));
1962 instructions.add(ib.build());
1963 isb.setInstruction(instructions);
1967 private static InstructionsBuilder createAppyActionInstruction33() {
1969 List<Action> actionList = new ArrayList<Action>();
1970 ActionBuilder ab = new ActionBuilder();
1972 SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
1973 setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(2));
1974 ab.setAction(new SetVlanCfiActionCaseBuilder().setSetVlanCfiAction(setVlanCfiActionBuilder.build()).build());
1975 ab.setKey(new ActionKey(0));
1976 actionList.add(ab.build());
1978 // Create an Apply Action
1979 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1980 aab.setAction(actionList);
1982 // Wrap our Apply Action in an Instruction
1983 InstructionBuilder ib = new InstructionBuilder();
1984 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1986 // Put our Instruction in a list of Instructions
1987 InstructionsBuilder isb = new InstructionsBuilder();
1988 List<Instruction> instructions = new ArrayList<Instruction>();
1989 ib.setKey(new InstructionKey(0));
1990 instructions.add(ib.build());
1991 isb.setInstruction(instructions);
1995 private static InstructionsBuilder createAppyActionInstruction34() {
1997 List<Action> actionList = new ArrayList<Action>();
1998 ActionBuilder ab = new ActionBuilder();
2000 SwPathActionBuilder swPathAction = new SwPathActionBuilder();
2001 ab.setAction(new SwPathActionCaseBuilder().setSwPathAction(swPathAction.build()).build());
2002 ab.setKey(new ActionKey(0));
2003 actionList.add(ab.build());
2005 // Create an Apply Action
2006 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2007 aab.setAction(actionList);
2009 // Wrap our Apply Action in an Instruction
2010 InstructionBuilder ib = new InstructionBuilder();
2011 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2013 // Put our Instruction in a list of Instructions
2014 InstructionsBuilder isb = new InstructionsBuilder();
2015 List<Instruction> instructions = new ArrayList<Instruction>();
2016 ib.setKey(new InstructionKey(0));
2017 instructions.add(ib.build());
2018 isb.setInstruction(instructions);
2022 private static InstructionsBuilder createAppyActionInstruction35() {
2024 List<Action> actionList = new ArrayList<Action>();
2025 ActionBuilder ab = new ActionBuilder();
2026 ActionBuilder ab1 = new ActionBuilder();
2027 ActionBuilder ab2 = new ActionBuilder();
2029 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2030 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2031 SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2034 EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2035 EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2036 ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2037 EthernetMatchBuilder ethernetMatch1 = new EthernetMatchBuilder();
2038 EthernetDestinationBuilder ethDestBuilder = new EthernetDestinationBuilder();
2039 ethDestBuilder.setAddress(new MacAddress("00:00:00:00:00:02"));
2040 EthernetMatchBuilder ethernetMatch2 = new EthernetMatchBuilder();
2041 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2042 ethTypeBuilder.setType(new EtherType(0x86ddL));
2044 ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2045 ethernetMatch1.setEthernetDestination(ethDestBuilder.build());
2046 ethernetMatch2.setEthernetType(ethTypeBuilder.build());
2047 setFieldBuilder.setEthernetMatch(ethernetMatch.build());
2048 setFieldBuilder1.setEthernetMatch(ethernetMatch1.build());
2049 setFieldBuilder2.setEthernetMatch(ethernetMatch2.build());
2050 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2051 ab.setKey(new ActionKey(0));
2052 actionList.add(ab.build());
2054 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2055 ab1.setKey(new ActionKey(1));
2056 actionList.add(ab1.build());
2058 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2059 ab2.setKey(new ActionKey(2));
2060 actionList.add(ab2.build());
2062 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2063 aab.setAction(actionList);
2065 InstructionBuilder ib = new InstructionBuilder();
2066 ib.setKey(new InstructionKey(0));
2067 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2069 // Put our Instruction in a list of Instructions
2070 InstructionsBuilder isb = new InstructionsBuilder();
2071 List<Instruction> instructions = new ArrayList<Instruction>();
2072 ib.setKey(new InstructionKey(0));
2073 instructions.add(ib.build());
2074 isb.setInstruction(instructions);
2078 private static InstructionsBuilder createAppyActionInstruction36() {
2080 List<Action> actionList = new ArrayList<Action>();
2081 ActionBuilder ab = new ActionBuilder();
2082 ActionBuilder ab1 = new ActionBuilder();
2084 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2085 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2088 VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
2089 VlanMatchBuilder vlanBuilder1 = new VlanMatchBuilder();
2090 VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2091 VlanId vlanId = new VlanId(10);
2092 VlanPcp vpcp = new VlanPcp((short) 3);
2093 vlanBuilder.setVlanPcp(vpcp);
2094 vlanBuilder1.setVlanId(vlanIdBuilder.setVlanId(vlanId).setVlanIdPresent(true).build());
2095 setFieldBuilder.setVlanMatch(vlanBuilder.build());
2096 setFieldBuilder1.setVlanMatch(vlanBuilder1.build());
2097 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2098 ab.setKey(new ActionKey(0));
2099 actionList.add(ab.build());
2100 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2101 ab1.setKey(new ActionKey(1));
2102 actionList.add(ab1.build());
2104 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2105 aab.setAction(actionList);
2107 InstructionBuilder ib = new InstructionBuilder();
2108 ib.setKey(new InstructionKey(0));
2109 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2111 // Put our Instruction in a list of Instructions
2112 InstructionsBuilder isb = new InstructionsBuilder();
2113 List<Instruction> instructions = new ArrayList<Instruction>();
2114 instructions.add(ib.build());
2115 isb.setInstruction(instructions);
2119 private static InstructionsBuilder createAppyActionInstruction37() {
2121 List<Action> actionList = new ArrayList<Action>();
2122 ActionBuilder ab = new ActionBuilder();
2123 ActionBuilder ab1 = new ActionBuilder();
2124 ActionBuilder ab2 = new ActionBuilder();
2126 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2127 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2128 SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2130 IpMatchBuilder ipmatch = new IpMatchBuilder();
2131 IpMatchBuilder ipmatch1 = new IpMatchBuilder();
2132 IpMatchBuilder ipmatch2 = new IpMatchBuilder();
2133 Dscp dscp = new Dscp((short) 3);
2134 ipmatch.setIpDscp(dscp);
2135 ipmatch1.setIpEcn((short) 2);
2136 ipmatch2.setIpProtocol((short) 120);
2137 setFieldBuilder.setIpMatch(ipmatch.build());
2138 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2139 ab.setKey(new ActionKey(0));
2140 actionList.add(ab.build());
2142 setFieldBuilder1.setIpMatch(ipmatch1.build());
2143 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2144 ab1.setKey(new ActionKey(1));
2145 actionList.add(ab1.build());
2147 setFieldBuilder2.setIpMatch(ipmatch2.build());
2148 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2149 ab2.setKey(new ActionKey(2));
2150 actionList.add(ab2.build());
2152 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2153 aab.setAction(actionList);
2155 InstructionBuilder ib = new InstructionBuilder();
2156 ib.setKey(new InstructionKey(0));
2157 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2159 // Put our Instruction in a list of Instructions
2160 InstructionsBuilder isb = new InstructionsBuilder();
2161 List<Instruction> instructions = new ArrayList<Instruction>();
2162 instructions.add(ib.build());
2163 isb.setInstruction(instructions);
2167 private static InstructionsBuilder createAppyActionInstruction38() {
2169 List<Action> actionList = new ArrayList<Action>();
2170 ActionBuilder ab = new ActionBuilder();
2171 ActionBuilder ab1 = new ActionBuilder();
2173 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2174 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2176 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2177 Ipv4MatchBuilder ipv4Match1 = new Ipv4MatchBuilder();
2178 Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.5210");
2179 Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1");
2180 ipv4Match1.setIpv4Destination(dstip);
2181 ipv4Match.setIpv4Source(srcip);
2182 setFieldBuilder.setLayer3Match(ipv4Match.build());
2183 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2184 ab.setKey(new ActionKey(0));
2185 actionList.add(ab.build());
2187 setFieldBuilder1.setLayer3Match(ipv4Match1.build());
2188 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2189 ab1.setKey(new ActionKey(1));
2190 actionList.add(ab1.build());
2192 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2193 aab.setAction(actionList);
2195 InstructionBuilder ib = new InstructionBuilder();
2196 ib.setKey(new InstructionKey(0));
2197 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2199 // Put our Instruction in a list of Instructions
2200 InstructionsBuilder isb = new InstructionsBuilder();
2201 List<Instruction> instructions = new ArrayList<Instruction>();
2202 instructions.add(ib.build());
2203 isb.setInstruction(instructions);
2207 private static InstructionsBuilder createAppyActionInstruction39() {
2209 List<Action> actionList = new ArrayList<Action>();
2210 ActionBuilder ab = new ActionBuilder();
2211 ActionBuilder ab1 = new ActionBuilder();
2213 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2214 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2217 PortNumber tcpsrcport = new PortNumber(1213);
2218 PortNumber tcpdstport = new PortNumber(646);
2219 TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
2220 TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder();
2221 tcpmatch.setTcpSourcePort(tcpsrcport);
2222 tcpmatch1.setTcpDestinationPort(tcpdstport);
2223 setFieldBuilder.setLayer4Match(tcpmatch.build());
2224 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2225 ab.setKey(new ActionKey(0));
2226 actionList.add(ab.build());
2228 setFieldBuilder1.setLayer4Match(tcpmatch1.build());
2229 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2230 ab1.setKey(new ActionKey(1));
2231 actionList.add(ab.build());
2233 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2234 aab.setAction(actionList);
2236 InstructionBuilder ib = new InstructionBuilder();
2237 ib.setKey(new InstructionKey(0));
2238 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2240 // Put our Instruction in a list of Instructions
2241 InstructionsBuilder isb = new InstructionsBuilder();
2242 List<Instruction> instructions = new ArrayList<Instruction>();
2243 instructions.add(ib.build());
2244 isb.setInstruction(instructions);
2248 private static InstructionsBuilder createAppyActionInstruction40() {
2250 List<Action> actionList = new ArrayList<Action>();
2251 ActionBuilder ab = new ActionBuilder();
2252 ActionBuilder ab1 = new ActionBuilder();
2254 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2255 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2258 PortNumber udpsrcport = new PortNumber(1325);
2259 PortNumber udpdstport = new PortNumber(42);
2260 UdpMatchBuilder udpmatch = new UdpMatchBuilder();
2261 UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
2262 udpmatch.setUdpDestinationPort(udpdstport);
2263 udpmatch1.setUdpSourcePort(udpsrcport);
2264 setFieldBuilder.setLayer4Match(udpmatch.build());
2265 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2266 ab.setKey(new ActionKey(0));
2267 actionList.add(ab.build());
2269 setFieldBuilder1.setLayer4Match(udpmatch1.build());
2270 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2271 ab1.setKey(new ActionKey(1));
2272 actionList.add(ab1.build());
2274 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2275 aab.setAction(actionList);
2277 InstructionBuilder ib = new InstructionBuilder();
2278 ib.setKey(new InstructionKey(0));
2279 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2281 // Put our Instruction in a list of Instructions
2282 InstructionsBuilder isb = new InstructionsBuilder();
2283 List<Instruction> instructions = new ArrayList<Instruction>();
2284 instructions.add(ib.build());
2285 isb.setInstruction(instructions);
2289 private static InstructionsBuilder createAppyActionInstruction41() {
2291 List<Action> actionList = new ArrayList<Action>();
2292 ActionBuilder ab = new ActionBuilder();
2293 ActionBuilder ab1 = new ActionBuilder();
2295 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2296 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2299 SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
2300 SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
2301 PortNumber srcport = new PortNumber(1435);
2302 PortNumber dstport = new PortNumber(22);
2303 sctpmatch.setSctpSourcePort(srcport);
2304 sctpmatch1.setSctpDestinationPort(dstport);
2305 setFieldBuilder.setLayer4Match(sctpmatch.build());
2306 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2307 ab.setKey(new ActionKey(0));
2308 actionList.add(ab.build());
2310 setFieldBuilder1.setLayer4Match(sctpmatch1.build());
2311 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2312 ab1.setKey(new ActionKey(1));
2313 actionList.add(ab1.build());
2315 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2316 aab.setAction(actionList);
2318 InstructionBuilder ib = new InstructionBuilder();
2319 ib.setKey(new InstructionKey(0));
2320 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2322 // Put our Instruction in a list of Instructions
2323 InstructionsBuilder isb = new InstructionsBuilder();
2324 List<Instruction> instructions = new ArrayList<Instruction>();
2325 instructions.add(ib.build());
2326 isb.setInstruction(instructions);
2330 private static InstructionsBuilder createAppyActionInstruction42() {
2332 List<Action> actionList = new ArrayList<Action>();
2333 ActionBuilder ab = new ActionBuilder();
2334 ActionBuilder ab1 = new ActionBuilder();
2335 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2336 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2339 Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
2340 Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
2341 icmpv4match.setIcmpv4Type((short) 8);
2342 icmpv4match1.setIcmpv4Code((short) 0);
2343 setFieldBuilder.setIcmpv4Match(icmpv4match.build());
2344 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2345 ab.setKey(new ActionKey(0));
2346 actionList.add(ab.build());
2348 setFieldBuilder1.setIcmpv4Match(icmpv4match1.build());
2349 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2350 ab1.setKey(new ActionKey(1));
2351 actionList.add(ab1.build());
2353 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2354 aab.setAction(actionList);
2356 InstructionBuilder ib = new InstructionBuilder();
2357 ib.setKey(new InstructionKey(0));
2358 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2360 // Put our Instruction in a list of Instructions
2361 InstructionsBuilder isb = new InstructionsBuilder();
2362 List<Instruction> instructions = new ArrayList<Instruction>();
2363 instructions.add(ib.build());
2364 isb.setInstruction(instructions);
2368 private static InstructionsBuilder createAppyActionInstruction43() {
2370 List<Action> actionList = new ArrayList<Action>();
2371 ActionBuilder ab = new ActionBuilder();
2372 ActionBuilder ab1 = new ActionBuilder();
2373 ActionBuilder ab2 = new ActionBuilder();
2374 ActionBuilder ab3 = new ActionBuilder();
2375 ActionBuilder ab4 = new ActionBuilder();
2377 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2378 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2379 SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2380 SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
2381 SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
2383 // setting the values of ARP
2384 MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2385 MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2386 Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52");
2387 Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1");
2388 // create ARP match action
2389 ArpMatchBuilder arpmatch = new ArpMatchBuilder();
2390 ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
2391 ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
2392 ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
2393 ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
2394 ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2395 arpsrc.setAddress(macsrc);
2396 ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2397 arpdst.setAddress(macdest);
2398 arpmatch.setArpOp(2);
2399 arpmatch1.setArpSourceHardwareAddress(arpsrc.build());
2400 arpmatch2.setArpTargetHardwareAddress(arpdst.build());
2401 arpmatch3.setArpSourceTransportAddress(srciparp);
2402 arpmatch4.setArpTargetTransportAddress(dstiparp);
2403 setFieldBuilder.setLayer3Match(arpmatch.build());
2404 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2405 ab.setKey(new ActionKey(0));
2406 actionList.add(ab.build());
2408 setFieldBuilder1.setLayer3Match(arpmatch1.build());
2409 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2410 ab1.setKey(new ActionKey(1));
2411 actionList.add(ab1.build());
2413 setFieldBuilder2.setLayer3Match(arpmatch2.build());
2414 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2415 ab2.setKey(new ActionKey(2));
2416 actionList.add(ab2.build());
2418 setFieldBuilder3.setLayer3Match(arpmatch3.build());
2419 ab3.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
2420 ab3.setKey(new ActionKey(3));
2421 actionList.add(ab3.build());
2423 setFieldBuilder4.setLayer3Match(arpmatch4.build());
2424 ab4.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
2425 ab4.setKey(new ActionKey(4));
2426 actionList.add(ab4.build());
2428 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2429 aab.setAction(actionList);
2431 InstructionBuilder ib = new InstructionBuilder();
2432 ib.setKey(new InstructionKey(0));
2433 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2435 // Put our Instruction in a list of Instructions
2436 InstructionsBuilder isb = new InstructionsBuilder();
2437 List<Instruction> instructions = new ArrayList<Instruction>();
2438 instructions.add(ib.build());
2439 isb.setInstruction(instructions);
2443 private static InstructionsBuilder createAppyActionInstruction44() {
2445 List<Action> actionLists = new ArrayList<Action>();
2446 ActionBuilder ab = new ActionBuilder();
2447 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2448 ActionBuilder ab1 = new ActionBuilder();
2449 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2451 * ActionBuilder ab2 = new ActionBuilder(); SetFieldBuilder
2452 * setFieldBuilder2 = new SetFieldBuilder(); ActionBuilder ab3 = new
2453 * ActionBuilder(); SetFieldBuilder setFieldBuilder3 = new
2454 * SetFieldBuilder(); ActionBuilder ab4 = new ActionBuilder();
2455 * SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
2457 ActionBuilder ab5 = new ActionBuilder();
2458 SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
2459 ActionBuilder ab6 = new ActionBuilder();
2460 SetFieldBuilder setFieldBuilder6 = new SetFieldBuilder();
2463 Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
2464 Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
2465 // Ipv6MatchBuilder ipv6Builder2 = new Ipv6MatchBuilder();
2466 // Ipv6MatchBuilder ipv6Builder3 = new Ipv6MatchBuilder();
2467 // Ipv6MatchBuilder ipv6Builder4 = new Ipv6MatchBuilder();
2468 Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
2469 Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
2471 Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2");
2472 Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1");
2473 // Ipv6Address ndtarget = new
2474 // Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
2475 // MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
2476 // MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
2477 Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
2478 nextheader.setIpv6Exthdr(58);
2479 Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2480 Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
2481 ipv6label.setIpv6Flabel(label);
2483 ipv6Builder.setIpv6Source(srcip6);
2484 ipv6Builder1.setIpv6Destination(dstip6);
2485 // ipv6Builder2.setIpv6NdTarget(ndtarget);
2486 // ipv6Builder3.setIpv6NdSll(ndsll);
2487 // ipv6Builder4.setIpv6NdTll(ndtll);
2488 ipv6Builder5.setIpv6ExtHeader(nextheader.build());
2489 ipv6Builder6.setIpv6Label(ipv6label.build());
2491 setFieldBuilder.setLayer3Match(ipv6Builder.build());
2492 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2493 ab.setKey(new ActionKey(0));
2494 actionLists.add(ab.build());
2496 setFieldBuilder1.setLayer3Match(ipv6Builder1.build());
2497 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2498 ab1.setKey(new ActionKey(1));
2499 actionLists.add(ab1.build());
2502 * setFieldBuilder2.setLayer3Match(ipv6Builder2.build());
2504 * SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2505 * ab2.setKey(new ActionKey(2)); actionLists.add(ab2.build());
2507 * setFieldBuilder3.setLayer3Match(ipv6Builder3.build());
2509 * SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
2510 * ab3.setKey(new ActionKey(3)); actionLists.add(ab3.build());
2512 * setFieldBuilder4.setLayer3Match(ipv6Builder4.build());
2514 * SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
2515 * ab4.setKey(new ActionKey(4)); actionLists.add(ab4.build());
2517 setFieldBuilder5.setLayer3Match(ipv6Builder5.build());
2518 ab5.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder5.build()).build());
2519 ab5.setKey(new ActionKey(5));
2520 actionLists.add(ab5.build());
2522 setFieldBuilder6.setLayer3Match(ipv6Builder6.build());
2523 ab6.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder6.build()).build());
2524 ab6.setKey(new ActionKey(6));
2525 actionLists.add(ab6.build());
2527 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2528 aab.setAction(actionLists);
2530 InstructionBuilder ib = new InstructionBuilder();
2531 ib.setKey(new InstructionKey(0));
2532 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2534 // Put our Instruction in a list of Instructions
2535 InstructionsBuilder isb = new InstructionsBuilder();
2536 List<Instruction> instructions = new ArrayList<Instruction>();
2537 instructions.add(ib.build());
2538 isb.setInstruction(instructions);
2542 private static InstructionsBuilder createAppyActionInstruction45() {
2544 List<Action> actionList = new ArrayList<Action>();
2545 ActionBuilder ab = new ActionBuilder();
2546 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2547 ActionBuilder ab1 = new ActionBuilder();
2548 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2551 Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
2552 Icmpv6MatchBuilder icmpv6match1 = new Icmpv6MatchBuilder();
2553 icmpv6match.setIcmpv6Type((short) 135);
2554 icmpv6match1.setIcmpv6Code((short) 0);
2555 setFieldBuilder.setIcmpv6Match(icmpv6match.build());
2556 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2557 ab.setKey(new ActionKey(0));
2558 actionList.add(ab.build());
2560 setFieldBuilder1.setIcmpv6Match(icmpv6match1.build());
2561 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2562 ab1.setKey(new ActionKey(1));
2563 actionList.add(ab1.build());
2565 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2566 aab.setAction(actionList);
2568 InstructionBuilder ib = new InstructionBuilder();
2569 ib.setKey(new InstructionKey(0));
2570 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2572 // Put our Instruction in a list of Instructions
2573 InstructionsBuilder isb = new InstructionsBuilder();
2574 List<Instruction> instructions = new ArrayList<Instruction>();
2575 instructions.add(ib.build());
2576 isb.setInstruction(instructions);
2580 private static InstructionsBuilder createAppyActionInstruction46() {
2582 List<Action> actionList = new ArrayList<Action>();
2583 ActionBuilder ab = new ActionBuilder();
2584 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2585 ActionBuilder ab1 = new ActionBuilder();
2586 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2587 ActionBuilder ab2 = new ActionBuilder();
2588 SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2591 ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2592 ProtocolMatchFieldsBuilder protomatch1 = new ProtocolMatchFieldsBuilder();
2593 ProtocolMatchFieldsBuilder protomatch2 = new ProtocolMatchFieldsBuilder();
2594 protomatch.setMplsLabel((long) 36008);
2595 protomatch1.setMplsTc((short) 4);
2596 protomatch2.setMplsBos((short) 1);
2597 setFieldBuilder.setProtocolMatchFields(protomatch.build());
2598 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2599 ab.setKey(new ActionKey(0));
2600 actionList.add(ab.build());
2602 setFieldBuilder1.setProtocolMatchFields(protomatch1.build());
2603 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2604 ab1.setKey(new ActionKey(1));
2605 actionList.add(ab1.build());
2607 setFieldBuilder2.setProtocolMatchFields(protomatch2.build());
2608 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2609 ab2.setKey(new ActionKey(2));
2610 actionList.add(ab2.build());
2612 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2613 aab.setAction(actionList);
2615 InstructionBuilder ib = new InstructionBuilder();
2616 ib.setKey(new InstructionKey(0));
2617 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2619 // Put our Instruction in a list of Instructions
2620 InstructionsBuilder isb = new InstructionsBuilder();
2621 List<Instruction> instructions = new ArrayList<Instruction>();
2622 instructions.add(ib.build());
2623 isb.setInstruction(instructions);
2627 private static InstructionsBuilder createAppyActionInstruction47() {
2629 List<Action> actionList = new ArrayList<Action>();
2630 ActionBuilder ab = new ActionBuilder();
2631 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2633 ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2634 protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask((new BigInteger(new byte[]{0, 1, 0, 0}).longValue())).build());
2635 setFieldBuilder.setProtocolMatchFields(protomatch.build());
2636 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2637 actionList.add(ab.build());
2639 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2640 aab.setAction(actionList);
2642 InstructionBuilder ib = new InstructionBuilder();
2643 ib.setKey(new InstructionKey(0));
2644 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2646 // Put our Instruction in a list of Instructions
2647 InstructionsBuilder isb = new InstructionsBuilder();
2648 List<Instruction> instructions = new ArrayList<Instruction>();
2649 instructions.add(ib.build());
2650 isb.setInstruction(instructions);
2654 private static InstructionsBuilder createAppyActionInstruction48() {
2656 List<Action> actionList = new ArrayList<Action>();
2657 ActionBuilder ab = new ActionBuilder();
2658 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2660 TunnelBuilder tunnel = new TunnelBuilder();
2661 tunnel.setTunnelId(BigInteger.valueOf(10668));
2662 setFieldBuilder.setTunnel(tunnel.build());
2663 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2664 ab.setKey(new ActionKey(0));
2665 actionList.add(ab.build());
2667 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2668 aab.setAction(actionList);
2670 InstructionBuilder ib = new InstructionBuilder();
2671 ib.setKey(new InstructionKey(0));
2672 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2674 // Put our Instruction in a list of Instructions
2675 InstructionsBuilder isb = new InstructionsBuilder();
2676 List<Instruction> instructions = new ArrayList<Instruction>();
2677 instructions.add(ib.build());
2678 isb.setInstruction(instructions);
2682 private static InstructionsBuilder createTunnelIpv4DstInstructions() {
2684 List<Action> actionList = new ArrayList<Action>();
2685 ActionBuilder ab = new ActionBuilder();
2686 // Build the tunnel endpoint destination IPv4 address
2687 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2688 Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.100");
2689 // Add the mew IPv4 object as the tunnel destination
2690 TunnelIpv4MatchBuilder tunnelIpv4DstMatchBuilder = new TunnelIpv4MatchBuilder();
2691 tunnelIpv4DstMatchBuilder.setTunnelIpv4Destination(dstIp);
2692 setFieldBuilder.setLayer3Match(tunnelIpv4DstMatchBuilder.build());
2693 // Add the IPv4 tunnel dst to the set_field value
2694 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2696 ab.setKey(new ActionKey(0));
2697 actionList.add(ab.build());
2698 // Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_dst)
2699 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2700 aab.setAction(actionList);
2701 // Add the action to the ordered list of Instructions
2702 InstructionBuilder ib = new InstructionBuilder();
2704 ib.setKey(new InstructionKey(0));
2705 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2706 // Add the Instruction in a list of Instructions
2707 InstructionsBuilder isb = new InstructionsBuilder();
2708 List<Instruction> instructions = new ArrayList<Instruction>();
2709 instructions.add(ib.build());
2710 isb.setInstruction(instructions);
2714 private static InstructionsBuilder createTunnelIpv4SrcInstructions() {
2716 List<Action> actionList = new ArrayList<Action>();
2717 ActionBuilder ab = new ActionBuilder();
2718 // Build the tunnel endpoint source IPv4 address
2719 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2720 Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.200");
2721 // Add the new IPv4 object as the tunnel destination
2722 TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
2723 tunnelIpv4MatchBuilder.setTunnelIpv4Source(dstIp);
2724 setFieldBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
2725 // Add the IPv4 tunnel src to the set_field value
2726 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2728 ab.setKey(new ActionKey(0));
2729 actionList.add(ab.build());
2730 // Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_src)
2731 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2732 aab.setAction(actionList);
2733 // Add the action to the ordered list of Instructions
2734 InstructionBuilder ib = new InstructionBuilder();
2736 ib.setKey(new InstructionKey(0));
2737 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2738 // Put our Instruction in a list of Instructions
2739 InstructionsBuilder isb = new InstructionsBuilder();
2740 List<Instruction> instructions = new ArrayList<Instruction>();
2741 instructions.add(ib.build());
2742 isb.setInstruction(instructions);
2746 private static MatchBuilder createLLDPMatch() {
2747 MatchBuilder match = new MatchBuilder();
2748 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2749 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2750 ethTypeBuilder.setType(new EtherType(0x88ccL));
2751 eth.setEthernetType(ethTypeBuilder.build());
2752 match.setEthernetMatch(eth.build());
2759 private static MatchBuilder createMatch1() {
2760 MatchBuilder match = new MatchBuilder();
2761 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2762 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
2763 ipv4Match.setIpv4Destination(prefix);
2764 Ipv4Match i4m = ipv4Match.build();
2765 match.setLayer3Match(i4m);
2767 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2768 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2769 ethTypeBuilder.setType(new EtherType(0x0800L));
2770 eth.setEthernetType(ethTypeBuilder.build());
2771 match.setEthernetMatch(eth.build());
2778 private static MatchBuilder createIPv4DstMatch() {
2779 MatchBuilder match = new MatchBuilder();
2780 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2781 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
2782 ipv4Match.setIpv4Destination(prefix);
2783 Ipv4Match i4m = ipv4Match.build();
2784 match.setLayer3Match(i4m);
2792 private static MatchBuilder createIPv4SrcMatch() {
2793 MatchBuilder match = new MatchBuilder();
2794 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2795 Ipv4Prefix prefix = new Ipv4Prefix("10.20.30.40/24");
2796 ipv4Match.setIpv4Source(prefix);
2797 Ipv4Match i4m = ipv4Match.build();
2798 match.setLayer3Match(i4m);
2800 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2801 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2802 ethTypeBuilder.setType(new EtherType(0x0800L));
2803 eth.setEthernetType(ethTypeBuilder.build());
2804 match.setEthernetMatch(eth.build());
2811 private static MatchBuilder createMatch2() {
2812 MatchBuilder match = new MatchBuilder();
2813 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2814 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
2815 ipv4Match.setIpv4Source(prefix);
2816 Ipv4Match i4m = ipv4Match.build();
2817 match.setLayer3Match(i4m);
2819 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2820 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2821 ethTypeBuilder.setType(new EtherType(0x0800L));
2822 eth.setEthernetType(ethTypeBuilder.build());
2823 match.setEthernetMatch(eth.build());
2830 private static MatchBuilder createMatch3() {
2831 MatchBuilder match = new MatchBuilder();
2832 EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2833 EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2834 ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2835 ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2836 match.setEthernetMatch(ethernetMatch.build());
2844 private static MatchBuilder createICMPv6Match1() {
2846 MatchBuilder match = new MatchBuilder();
2847 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2848 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2849 ethTypeBuilder.setType(new EtherType(0x86ddL));
2850 eth.setEthernetType(ethTypeBuilder.build());
2851 match.setEthernetMatch(eth.build());
2853 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2854 ipmatch.setIpProtocol((short) 256);
2855 match.setIpMatch(ipmatch.build());
2857 Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2859 icmpv6match.setIcmpv6Type((short) 135);
2860 icmpv6match.setIcmpv6Code((short) 1);
2861 match.setIcmpv6Match(icmpv6match.build());
2866 private static MatchBuilder createMatch33() {
2868 MatchBuilder match = new MatchBuilder();
2869 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2870 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
2871 ipv4Match.setIpv4Source(prefix);
2872 Ipv4Match i4m = ipv4Match.build();
2873 match.setLayer3Match(i4m);
2875 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2876 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2877 ethTypeBuilder.setType(new EtherType(0xfffeL));
2878 eth.setEthernetType(ethTypeBuilder.build());
2879 match.setEthernetMatch(eth.build());
2883 private static MatchBuilder createInphyportMatch(NodeId nodeId) {
2884 MatchBuilder match = new MatchBuilder();
2885 match.setInPort(new NodeConnectorId(nodeId + ":202"));
2886 match.setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
2890 private static MatchBuilder createEthernetMatch() {
2891 MatchBuilder match = new MatchBuilder();
2893 byte[] mask1 = new byte[]{(byte) -1, (byte) -1, 0, 0, 0, 0};
2894 byte[] mask2 = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0};
2896 EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
2898 EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2899 EtherType type = new EtherType(0x0800L);
2900 ethmatch.setEthernetType(ethtype.setType(type).build());
2902 EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
2905 MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2906 ethdest.setAddress(macdest);
2907 ethdest.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2909 ethmatch.setEthernetDestination(ethdest.build());
2911 EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
2912 MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2913 ethsrc.setAddress(macsrc);
2914 ethsrc.setMask(new MacAddress("ff:ff:00:00:00:00"));
2916 ethmatch.setEthernetSource(ethsrc.build());
2917 match.setEthernetMatch(ethmatch.build());
2926 private static MatchBuilder createVlanMatch() {
2927 MatchBuilder match = new MatchBuilder();
2928 VlanMatchBuilder vlanBuilder = new VlanMatchBuilder(); // vlan match
2929 VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2930 VlanId vlanId = new VlanId(10);
2931 VlanPcp vpcp = new VlanPcp((short) 3);
2932 vlanBuilder.setVlanPcp(vpcp);
2933 vlanIdBuilder.setVlanId(vlanId);
2934 vlanIdBuilder.setVlanIdPresent(true);
2935 vlanBuilder.setVlanId(vlanIdBuilder.build());
2936 match.setVlanMatch(vlanBuilder.build());
2943 private static MatchBuilder createArpMatch() {
2944 MatchBuilder match = new MatchBuilder();
2946 EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2947 MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2948 MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2950 byte[] mask = new byte[]{(byte) -1, (byte) -1, 0, 0, 0, 0};
2951 byte[] mask2 = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0};
2953 EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2954 EtherType type = new EtherType(0x0806L);
2955 ethmatch.setEthernetType(ethtype.setType(type).build());
2957 Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
2958 Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2960 ArpMatchBuilder arpmatch = new ArpMatchBuilder(); // arp match
2961 ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2962 arpsrc.setAddress(macsrc);
2963 arpsrc.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2964 ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2965 arpdst.setAddress(macdest);
2966 arpdst.setMask(new MacAddress("ff:ff:00:00:00:00"));
2967 arpmatch.setArpOp(2);
2968 arpmatch.setArpSourceHardwareAddress(arpsrc.build());
2969 arpmatch.setArpTargetHardwareAddress(arpdst.build());
2970 arpmatch.setArpSourceTransportAddress(srcip);
2971 arpmatch.setArpTargetTransportAddress(dstip);
2973 match.setEthernetMatch(ethmatch.build());
2974 match.setLayer3Match(arpmatch.build());
2982 private static MatchBuilder createIPMatch() {
2983 MatchBuilder match = new MatchBuilder();
2984 EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2985 EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2986 EtherType type = new EtherType(0x0800L);
2987 ethmatch.setEthernetType(ethtype.setType(type).build());
2988 match.setEthernetMatch(ethmatch.build());
2990 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2991 ipmatch.setIpProtocol((short) 1);
2992 Dscp dscp = new Dscp((short) 3);
2993 ipmatch.setIpDscp(dscp);
2994 ipmatch.setIpEcn((short) 2);
2995 match.setIpMatch(ipmatch.build());
3002 private static MatchBuilder createL3IPv4Match() {
3003 MatchBuilder match = new MatchBuilder();
3005 EthernetMatchBuilder eth = new EthernetMatchBuilder();
3006 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3007 ethTypeBuilder.setType(new EtherType(0x0800L));
3008 eth.setEthernetType(ethTypeBuilder.build());
3009 match.setEthernetMatch(eth.build());
3011 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
3012 Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
3013 Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
3014 Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
3015 ipv4match.setIpv4Destination(dstip);
3016 ipv4match.setIpv4Source(srcip);
3017 match.setLayer3Match(ipv4match.build());
3026 private static MatchBuilder createL3IPv6Match() {
3027 MatchBuilder match = new MatchBuilder();
3029 EthernetMatchBuilder eth = new EthernetMatchBuilder();
3030 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3031 ethTypeBuilder.setType(new EtherType(0x86ddL));
3032 eth.setEthernetType(ethTypeBuilder.build());
3033 match.setEthernetMatch(eth.build());
3035 Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
3036 Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
3037 Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
3038 MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
3039 MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
3040 Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
3041 nextheader.setIpv6Exthdr(58);
3042 Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
3043 Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
3044 ipv6label.setIpv6Flabel(label);
3045 ipv6label.setFlabelMask(new Ipv6FlowLabel(1L));
3047 Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
3049 icmpv6match.setIcmpv6Type((short) 135);
3050 icmpv6match.setIcmpv6Code((short) 0);
3051 match.setIcmpv6Match(icmpv6match.build());
3053 Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
3054 // ipv6match.setIpv6Source(srcip6);
3055 // ipv6match.setIpv6Destination(dstip6);
3056 // ipv6match.setIpv6ExtHeader(nextheader.build());
3057 ipv6match.setIpv6NdSll(ndsll);
3058 ipv6match.setIpv6NdTll(ndtll);
3059 // ipv6match.setIpv6NdTarget(ndtarget);
3060 ipv6match.setIpv6Label(ipv6label.build());
3062 match.setLayer3Match(ipv6match.build());
3071 private static MatchBuilder createICMPv4Match() {
3072 MatchBuilder match = new MatchBuilder();
3073 EthernetMatchBuilder eth = new EthernetMatchBuilder();
3074 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3075 ethTypeBuilder.setType(new EtherType(0x0800L));
3076 eth.setEthernetType(ethTypeBuilder.build());
3077 match.setEthernetMatch(eth.build());
3079 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3080 ipmatch.setIpProtocol((short) 1);
3081 match.setIpMatch(ipmatch.build());
3083 Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
3085 icmpv4match.setIcmpv4Type((short) 8);
3086 icmpv4match.setIcmpv4Code((short) 0);
3087 match.setIcmpv4Match(icmpv4match.build());
3094 private static MatchBuilder createICMPv6Match() {
3096 MatchBuilder match = new MatchBuilder();
3097 EthernetMatchBuilder eth = new EthernetMatchBuilder();
3098 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3099 ethTypeBuilder.setType(new EtherType(0x86ddL));
3100 eth.setEthernetType(ethTypeBuilder.build());
3101 match.setEthernetMatch(eth.build());
3103 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3104 ipmatch.setIpProtocol((short) 58);
3105 match.setIpMatch(ipmatch.build());
3107 Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
3109 icmpv6match.setIcmpv6Type((short) 135);
3110 icmpv6match.setIcmpv6Code((short) 1);
3111 match.setIcmpv6Match(icmpv6match.build());
3119 private static MatchBuilder createToSMatch() {
3120 MatchBuilder match = new MatchBuilder();
3121 EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
3122 EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
3123 EtherType type = new EtherType(0x0800L);
3124 ethmatch.setEthernetType(ethtype.setType(type).build());
3125 match.setEthernetMatch(ethmatch.build());
3127 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3128 ipmatch.setIpProtocol((short) 6);
3129 Dscp dscp = new Dscp((short) 8);
3130 ipmatch.setIpDscp(dscp);
3131 match.setIpMatch(ipmatch.build());
3139 private static MatchBuilder createL4TCPMatch() {
3140 MatchBuilder match = new MatchBuilder();
3142 EthernetMatchBuilder eth = new EthernetMatchBuilder();
3143 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3144 ethTypeBuilder.setType(new EtherType(0x0800L));
3145 eth.setEthernetType(ethTypeBuilder.build());
3146 match.setEthernetMatch(eth.build());
3148 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3149 ipmatch.setIpProtocol((short) 6);
3150 match.setIpMatch(ipmatch.build());
3152 PortNumber srcport = new PortNumber(1213);
3153 PortNumber dstport = new PortNumber(646);
3154 TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
3155 tcpmatch.setTcpSourcePort(srcport);
3156 tcpmatch.setTcpDestinationPort(dstport);
3157 match.setLayer4Match(tcpmatch.build());
3165 private static MatchBuilder createL4UDPMatch() {
3166 MatchBuilder match = new MatchBuilder();
3168 EthernetMatchBuilder eth = new EthernetMatchBuilder();
3169 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3170 ethTypeBuilder.setType(new EtherType(0x0800L));
3171 eth.setEthernetType(ethTypeBuilder.build());
3172 match.setEthernetMatch(eth.build());
3174 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3175 ipmatch.setIpProtocol((short) 17);
3176 match.setIpMatch(ipmatch.build());
3178 PortNumber srcport = new PortNumber(1325);
3179 PortNumber dstport = new PortNumber(42);
3180 UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
3181 udpmatch.setUdpDestinationPort(dstport);
3182 udpmatch.setUdpSourcePort(srcport);
3183 match.setLayer4Match(udpmatch.build());
3191 private static MatchBuilder createL4SCTPMatch() {
3192 MatchBuilder match = new MatchBuilder();
3194 EthernetMatchBuilder eth = new EthernetMatchBuilder();
3195 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3196 ethTypeBuilder.setType(new EtherType(0x0800L));
3197 eth.setEthernetType(ethTypeBuilder.build());
3198 match.setEthernetMatch(eth.build());
3200 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3201 ipmatch.setIpProtocol((short) 132);
3202 match.setIpMatch(ipmatch.build());
3204 SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
3205 PortNumber srcport = new PortNumber(1435);
3206 PortNumber dstport = new PortNumber(22);
3207 sctpmatch.setSctpSourcePort(srcport);
3208 sctpmatch.setSctpDestinationPort(dstport);
3209 match.setLayer4Match(sctpmatch.build());
3217 private static MatchBuilder createMetadataMatch() {
3218 MatchBuilder match = new MatchBuilder();
3219 byte[] metamask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
3220 MetadataBuilder metadata = new MetadataBuilder(); // metadata match
3221 metadata.setMetadata(BigInteger.valueOf(500L));
3222 metadata.setMetadataMask(new BigInteger(1, metamask));
3223 match.setMetadata(metadata.build());
3231 private static MatchBuilder createMplsMatch() {
3232 MatchBuilder match = new MatchBuilder();
3234 EthernetMatchBuilder eth = new EthernetMatchBuilder();
3235 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3236 ethTypeBuilder.setType(new EtherType(0x8847L));
3237 eth.setEthernetType(ethTypeBuilder.build());
3238 match.setEthernetMatch(eth.build());
3240 ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
3242 protomatch.setMplsLabel((long) 36008);
3243 protomatch.setMplsTc((short) 4);
3244 protomatch.setMplsBos((short) 1);
3245 match.setProtocolMatchFields(protomatch.build());
3254 private static MatchBuilder createPbbMatch() {
3255 MatchBuilder match = new MatchBuilder();
3257 EthernetMatchBuilder eth = new EthernetMatchBuilder();
3258 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3259 ethTypeBuilder.setType(new EtherType(0x88E7L));
3260 eth.setEthernetType(ethTypeBuilder.build());
3261 match.setEthernetMatch(eth.build());
3263 ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
3265 protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new BigInteger(new byte[]{0, 1, 0, 0}).longValue()).build());
3266 match.setProtocolMatchFields(protomatch.build());
3275 private static MatchBuilder createTunnelIDMatch() {
3276 MatchBuilder match = new MatchBuilder();
3277 TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
3278 tunnel.setTunnelId(BigInteger.valueOf(10668));
3279 byte[] mask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
3280 tunnel.setTunnelMask(new BigInteger(1, mask));
3281 match.setTunnel(tunnel.build());
3287 * Test match for TCP_Flags
3289 * @return match containing Ethertype (0x0800), IP Protocol (TCP), TCP_Flag (SYN)
3291 //FIXME: move to extensible support
3292 private static MatchBuilder createTcpFlagMatch() {
3293 MatchBuilder match = new MatchBuilder();
3296 EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
3297 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3298 ethTypeBuilder.setType(new EtherType(0x0800L));
3299 ethernetType.setEthernetType(ethTypeBuilder.build());
3300 match.setEthernetMatch(ethernetType.build());
3302 // TCP Protocol Match
3303 IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
3304 ipMatch.setIpProtocol((short) 6);
3305 match.setIpMatch(ipMatch.build());
3308 PortNumber dstPort = new PortNumber(80);
3309 TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
3310 tcpMatch.setTcpDestinationPort(dstPort);
3311 match.setLayer4Match(tcpMatch.build());
3313 * Defined TCP Flag values in OVS v2.1+
3314 * TCP_FIN 0x001 / TCP_SYN 0x002 / TCP_RST 0x004
3315 * TCP_PSH 0x008 / TCP_ACK 0x010 / TCP_URG 0x020
3316 * TCP_ECE 0x040 / TCP_CWR 0x080 / TCP_NS 0x100
3318 TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
3319 tcpFlagMatch.setTcpFlag(0x002);
3320 match.setTcpFlagMatch(tcpFlagMatch.build());
3325 public void _removeMDFlow(final CommandInterpreter ci) {
3326 ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
3327 NodeBuilder tn = createTestNode(ci.nextArgument());
3328 String flowtype = ci.nextArgument();
3330 if (flowtype.equals("fTM")) {
3331 tf = createtablemiss(tn, flowtype, ci.nextArgument());
3333 tf = createTestFlow(tn, flowtype, ci.nextArgument());
3335 InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey())
3336 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
3337 .child(Flow.class, tf.getKey());
3338 modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
3339 CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
3340 Futures.addCallback(commitFuture, new FutureCallback<Void>() {
3342 public void onSuccess(Void aVoid) {
3343 ci.println("Status of Group Data Loaded Transaction: success.");
3347 public void onFailure(Throwable throwable) {
3348 LOG.error(throwable.getMessage(), throwable);
3349 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
3355 * @param ci arguments: switchId flowType tableNum
3358 * e.g.: addMDFlow openflow:1 f1 42
3361 public void _addMDFlow(CommandInterpreter ci) {
3362 NodeBuilder tn = createTestNode(ci.nextArgument());
3363 String flowtype = ci.nextArgument();
3365 if (flowtype.equals("fTM")) {
3366 tf = createtablemiss(tn, flowtype, ci.nextArgument());
3368 tf = createTestFlow(tn, flowtype, ci.nextArgument());
3370 writeFlow(ci, tf, tn);
3373 private void writeFlow(final CommandInterpreter ci, FlowBuilder flow, NodeBuilder nodeBuilder) {
3374 ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
3375 InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
3376 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
3377 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey());
3378 modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
3379 modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
3380 CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
3381 Futures.addCallback(commitFuture, new FutureCallback<Void>() {
3383 public void onSuccess(Void aVoid) {
3384 ci.println("Status of Group Data Loaded Transaction: success.");
3388 public void onFailure(Throwable throwable) {
3389 LOG.error(throwable.getMessage(), throwable);
3390 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
3395 public void _modifyMDFlow(CommandInterpreter ci) {
3396 NodeBuilder tn = createTestNode(ci.nextArgument());
3397 FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
3398 tf.setFlowName(updatedFlowName);
3399 writeFlow(ci, tf, tn);
3400 tf.setFlowName(originalFlowName);
3401 writeFlow(ci, tf, tn);
3404 private static NodeRef createNodeRef(String string) {
3405 NodeKey key = new NodeKey(new NodeId(string));
3406 InstanceIdentifier<Node> path = InstanceIdentifier.create(Nodes.class).child(Node.class, key);
3408 return new NodeRef(path);
3412 public String getHelp() {
3417 * usage testSwitchFlows <numberOfSwitches> <numberOfFlows> <warmup iterations> <Number Of Threads>
3418 * ex: _perfFlowTest 10 5 1 2
3420 public void _perfFlowTest(CommandInterpreter ci) {
3422 String numberOfSwtichesStr = ci.nextArgument();
3423 String numberOfFlowsStr = ci.nextArgument();
3424 String warmupIterationsStr = ci.nextArgument();
3425 String threadCountStr = ci.nextArgument();
3426 String warmUpStr = ci.nextArgument();
3428 Collection<String> testResults = null;
3429 if (testResults == null) {
3430 testResults = new ArrayList<String>();
3433 int numberOfSwtiches = 0;
3434 int numberOfFlows = 0;
3435 int warmupIterations = 0;
3436 boolean warmUpIterations = false;
3438 int threadCount = 0;
3439 if (numberOfSwtichesStr != null && !numberOfSwtichesStr.trim().equals("")) {
3440 numberOfSwtiches = new Integer(numberOfSwtichesStr).intValue();
3442 numberOfSwtiches = 2;
3445 if (numberOfFlowsStr != null && !numberOfFlowsStr.trim().equals("")) {
3446 numberOfFlows = new Integer(numberOfFlowsStr).intValue();
3451 if (warmupIterationsStr != null && !warmupIterationsStr.trim().equals("")) {
3452 warmupIterations = new Integer(warmupIterationsStr).intValue();
3454 warmupIterations = 2;
3457 if (threadCountStr != null && !threadCountStr.trim().equals("")) {
3458 threadCount = new Integer(threadCountStr).intValue();
3462 if (warmUpStr != null && !warmUpStr.trim().equals("") && warmUpStr.trim().equals("true")) {
3463 warmUpIterations = true;
3465 warmUpIterations = false;
3467 ci.println("* Test Configurations*");
3468 ci.println("* numberOfSwtiches:::" + numberOfSwtiches + "");
3469 ci.println("* numberOfFlows:::" + numberOfFlows + "");
3470 ci.println("* warmupIterations:::" + warmupIterations + "");
3471 ci.println("* Number of Threads :::" + threadCount + "");
3472 ci.println("* Warmup Required? :::" + warmUpIterations + "");
3474 String dataPath = "openflow:1";
3475 String flowType = "fTM";
3478 String tableId = "0";
3479 if (warmUpIterations) {
3480 ci.println("----Warmup Started-----");
3481 for (int j = 1; j <= warmupIterations; j++) {
3482 for (int i = 1; i <= numberOfSwtiches; i++) {
3483 dataPath = "openflow:" + i;
3484 tn = createTestNode(dataPath);
3485 for (int flow = 1; flow < numberOfFlows; flow++) {
3486 tf = createTestFlow_perfTest(tn, "f1", tableId, flow);
3487 writeFlow(ci, tf, tn);
3492 ci.println("----Warmup Done-----");
3495 ExecutorService executor = Executors.newFixedThreadPool(threadCount);
3498 for (int t = 0; t < threadCount; t++) {
3500 Runnable tRunnable = new TestFlowThread(numberOfSwtiches, numberOfFlows, ci, t, tableID);
3501 executor.execute(tRunnable);
3503 executor.shutdown();
3504 executor.awaitTermination(1, TimeUnit.SECONDS);
3505 } catch (Exception e) {
3506 ci.println("Exception:" + e.getMessage());
3510 public class TestFlowThread implements Runnable {
3512 int numberOfSwitches;
3515 CommandInterpreter ci;
3518 Collection<String> testResults = null;
3521 TestFlowThread(int numberOfSwtiches, int numberOfFlows, CommandInterpreter ci, int t, int tableID) {
3522 this.numberOfSwitches = numberOfSwtiches;
3523 this.numberOfFlows = numberOfFlows;
3525 this.theadNumber = t;
3526 this.tableID = tableID;
3534 public void executeFlow() {
3536 String dataPath = "openflow:1";
3539 //String tableId = "0";
3541 ci.println("New Thread started with id: ID_"
3542 + this.theadNumber);
3543 int totalNumberOfFlows = 0;
3544 long startTime = System.currentTimeMillis();
3546 for (int i = 1; i <= this.numberOfSwitches; i++) {
3547 dataPath = "openflow:" + i;
3548 tn = createTestNode(dataPath);
3549 for (int flow2 = 1; flow2 <= this.numberOfFlows; flow2++) {
3550 tf = createTestFlow_perfTest(tn, "f1", "" + this.tableID, flow2);
3551 writeFlow(this.ci, tf, tn);
3552 totalNumberOfFlows++;
3555 long endTime = System.currentTimeMillis();
3556 long timeInSeconds = Math.round((endTime - startTime) / 1000);
3557 if (timeInSeconds > 0) {
3558 ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::" + Math.round(totalNumberOfFlows / timeInSeconds));
3560 ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::" + totalNumberOfFlows);
3567 * usage testAllFlows <dp>
3568 * ex: _perfFlowTest 1
3570 public void _testAllFlows(CommandInterpreter ci) {
3571 String dataPathID = ci.nextArgument();
3572 int numberOfFlows = 82;
3573 int threadCount = 0;
3574 if (dataPathID == null || dataPathID.trim().equals("")) {
3577 ci.println("* Test All Flows *");
3578 ci.println("* dataPathID:::" + dataPathID + "");
3579 String dataPath = "openflow:" + dataPathID;
3580 String tableId = "0";
3581 NodeBuilder tn = createTestNode(dataPath);
3583 for (int flow = 1; flow < numberOfFlows; flow++) {
3584 String flowID = "f" + flow;
3586 tf = createTestFlow(tn, flowID, tableId);
3587 writeFlow(ci, tf, tn);
3588 } catch (Exception e) {
3589 ci.println("--Test Failed--Issue found while adding flow" + flow);