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 java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.List;
14 import java.util.concurrent.ExecutionException;
15 import java.util.concurrent.Future;
17 import org.eclipse.osgi.framework.console.CommandInterpreter;
18 import org.eclipse.osgi.framework.console.CommandProvider;
19 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
20 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
21 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
22 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCaseBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCaseBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCaseBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCaseBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.action._case.FloodActionBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.hw.path.action._case.HwPathActionBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.loopback.action._case.LoopbackActionBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.type.action._case.SetDlTypeActionBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.next.hop.action._case.SetNextHopActionBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.cfi.action._case.SetVlanCfiActionBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
158 import org.opendaylight.yangtools.yang.binding.DataObject;
159 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
160 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
161 import org.opendaylight.yangtools.yang.common.RpcResult;
162 import org.osgi.framework.BundleContext;
163 import org.slf4j.Logger;
164 import org.slf4j.LoggerFactory;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
168 public class OpenflowpluginTestCommandProvider implements CommandProvider {
170 private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
172 private DataBrokerService dataBrokerService;
173 private ProviderContext pc;
174 private final BundleContext ctx;
175 private FlowBuilder testFlow;
176 private NodeBuilder testNode;
177 private final String originalFlowName = "Foo";
178 private final String updatedFlowName = "Bar";
180 public OpenflowpluginTestCommandProvider(BundleContext ctx) {
184 public void onSessionInitiated(ProviderContext session) {
186 dataBrokerService = session.getSALService(DataBrokerService.class);
187 ctx.registerService(CommandProvider.class.getName(), this, null);
188 createTestFlow(createTestNode(null), null);
191 private NodeBuilder createTestNode(String nodeId) {
192 if (nodeId == null) {
193 nodeId = OpenflowpluginTestActivator.NODE_ID;
195 NodeRef nodeOne = createNodeRef(nodeId);
196 NodeBuilder builder = new NodeBuilder();
197 builder.setId(new NodeId(nodeId));
198 builder.setKey(new NodeKey(builder.getId()));
203 private InstanceIdentifier<Node> nodeBuilderToInstanceId(NodeBuilder node) {
204 return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
207 private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg) {
209 FlowBuilder flow = new FlowBuilder();
212 String flowType = flowTypeArg;
213 if (flowType == null) {
220 flow.setMatch(createMatch1().build());
221 flow.setInstructions(createDecNwTtlInstructions().build());
225 flow.setMatch(createMatch2().build());
226 flow.setInstructions(createDropInstructions().build());
230 flow.setMatch(createMatch3().build());
231 flow.setInstructions(createDropInstructions().build());
235 flow.setMatch(createEthernetMatch().build());
236 flow.setInstructions(createDropInstructions().build());
240 flow.setMatch(createMatch1().build());
241 flow.setInstructions(createAppyActionInstruction().build());
245 flow.setMatch(createMatch1().build());
246 flow.setInstructions(createGotoTableInstructions().build());
250 flow.setMatch(createMatch1().build());
251 flow.setInstructions(createMeterInstructions().build());
255 flow.setMatch(createMatch1().build());
256 flow.setInstructions(createAppyActionInstruction1().build());
260 flow.setMatch(createMatch1().build());
261 flow.setInstructions(createAppyActionInstruction2().build());
265 flow.setMatch(createMatch1().build());
266 flow.setInstructions(createAppyActionInstruction3().build());
270 flow.setMatch(createMatch1().build());
271 flow.setInstructions(createAppyActionInstruction4().build());
275 flow.setMatch(createMatch1().build());
276 flow.setInstructions(createAppyActionInstruction5().build());
280 flow.setMatch(createMatch1().build());
281 flow.setInstructions(createAppyActionInstruction6().build());
285 flow.setMatch(createMatch1().build());
286 flow.setInstructions(createAppyActionInstruction7().build());
290 flow.setMatch(createMatch1().build());
291 flow.setInstructions(createAppyActionInstruction8().build());
295 flow.setMatch(createMatch1().build());
296 flow.setInstructions(createAppyActionInstruction9().build());
300 flow.setMatch(createMatch1().build());
301 flow.setInstructions(createAppyActionInstruction10().build());
305 flow.setMatch(createMatch1().build());
306 flow.setInstructions(createAppyActionInstruction11().build());
310 flow.setMatch(createMatch1().build());
311 flow.setInstructions(createAppyActionInstruction12().build());
315 flow.setMatch(createMatch1().build());
316 flow.setInstructions(createAppyActionInstruction13().build());
320 flow.setMatch(createMatch1().build());
321 flow.setInstructions(createAppyActionInstruction14().build());
325 flow.setMatch(createMatch1().build());
326 flow.setInstructions(createAppyActionInstruction15().build());
330 flow.setMatch(createMatch1().build());
331 flow.setInstructions(createAppyActionInstruction16().build());
335 flow.setMatch(createMatch1().build());
336 flow.setInstructions(createAppyActionInstruction17().build());
340 flow.setMatch(createMatch1().build());
341 flow.setInstructions(createAppyActionInstruction18().build());
345 flow.setMatch(createMatch1().build());
346 flow.setInstructions(createAppyActionInstruction19().build());
350 flow.setMatch(createMatch1().build());
351 flow.setInstructions(createMetadataInstructions().build());
355 flow.setMatch(createMatch1().build());
356 flow.setInstructions(createAppyActionInstruction20().build());
360 flow.setMatch(createMatch1().build());
361 flow.setInstructions(createAppyActionInstruction21().build());
365 flow.setMatch(createMatch1().build());
366 flow.setInstructions(createAppyActionInstruction22().build());
370 flow.setMatch(createMatch1().build());
371 flow.setInstructions(createAppyActionInstruction23().build());
375 flow.setMatch(createMatch1().build());
376 flow.setInstructions(createAppyActionInstruction24().build());
380 flow.setMatch(createMatch1().build());
381 flow.setInstructions(createAppyActionInstruction25().build());
385 flow.setMatch(createMatch1().build());
386 flow.setInstructions(createAppyActionInstruction26().build());
390 flow.setMatch(createMatch1().build());
391 flow.setInstructions(createAppyActionInstruction27().build());
395 flow.setMatch(createMatch1().build());
396 flow.setInstructions(createAppyActionInstruction28().build());
400 flow.setMatch(createMatch1().build());
401 flow.setInstructions(createAppyActionInstruction29().build());
405 flow.setMatch(createMatch1().build());
406 flow.setInstructions(createAppyActionInstruction30().build());
410 flow.setMatch(createMatch1().build());
411 flow.setInstructions(createAppyActionInstruction31().build());
415 flow.setMatch(createMatch1().build());
416 flow.setInstructions(createAppyActionInstruction32().build());
420 flow.setMatch(createMatch1().build());
421 flow.setInstructions(createAppyActionInstruction33().build());
425 flow.setMatch(createMatch1().build());
426 flow.setInstructions(createAppyActionInstruction34().build());
430 flow.setMatch(createICMPv6Match().build());
431 flow.setInstructions(createDecNwTtlInstructions().build());
435 flow.setMatch(createInphyportMatch().build());
436 flow.setInstructions(createDropInstructions().build());
440 flow.setMatch(createMetadataMatch().build());
441 flow.setInstructions(createDropInstructions().build());
445 flow.setMatch(createL3IPv6Match().build());
446 flow.setInstructions(createDecNwTtlInstructions().build());
450 flow.setMatch(createL4SCTPMatch().build());
451 flow.setInstructions(createAppyActionInstruction().build());
455 flow.setMatch(createTunnelIDMatch().build());
456 flow.setInstructions(createGotoTableInstructions().build());
460 flow.setMatch(createVlanMatch().build());
461 flow.setInstructions(createMeterInstructions().build());
465 LOG.warn("flow type not understood: {}", flowType);
468 FlowKey key = new FlowKey(new FlowId(id));
469 flow.setBarrier(false);
470 // flow.setBufferId(new Long(12));
471 BigInteger value = new BigInteger("10", 10);
472 flow.setCookie(value);
473 flow.setCookieMask(value);
474 flow.setHardTimeout(12);
475 flow.setIdleTimeout(34);
476 flow.setInstallHw(false);
477 flow.setStrict(false);
478 flow.setContainerName(null);
479 flow.setFlags(new FlowModFlags(false, false, false, false, false));
480 flow.setId(new FlowId(new Long(12)));
481 flow.setTableId((short) 2);
482 flow.setOutGroup(new Long(2));
483 flow.setOutPort(value);
487 flow.setFlowName(originalFlowName + "X" + flowType);
495 private static InstructionsBuilder createDecNwTtlInstructions() {
496 DecNwTtlBuilder ta = new DecNwTtlBuilder();
497 DecNwTtl decNwTtl = ta.build();
498 ActionBuilder ab = new ActionBuilder();
499 ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
501 // Add our drop action to a list
502 List<Action> actionList = new ArrayList<Action>();
503 actionList.add(ab.build());
505 // Create an Apply Action
506 ApplyActionsBuilder aab = new ApplyActionsBuilder();
507 aab.setAction(actionList);
509 // Wrap our Apply Action in an Instruction
510 InstructionBuilder ib = new InstructionBuilder();
511 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
513 // Put our Instruction in a list of Instructions
514 InstructionsBuilder isb = new InstructionsBuilder();
515 List<Instruction> instructions = new ArrayList<Instruction>();
516 instructions.add(ib.build());
517 isb.setInstruction(instructions);
524 private static InstructionsBuilder createMeterInstructions() {
526 MeterBuilder aab = new MeterBuilder();
527 aab.setMeterId(new MeterId(new Long(1)));
529 InstructionBuilder ib = new InstructionBuilder();
530 ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
532 // Put our Instruction in a list of Instructions
533 InstructionsBuilder isb = new InstructionsBuilder();
534 List<Instruction> instructions = new ArrayList<Instruction>();
535 instructions.add(ib.build());
536 isb.setInstruction(instructions);
540 private static InstructionsBuilder createMetadataInstructions() {
542 WriteMetadataBuilder aab = new WriteMetadataBuilder();
543 aab.setMetadata(new BigInteger("10", 10));
544 aab.setMetadataMask(new BigInteger("12", 10));
546 InstructionBuilder ib = new InstructionBuilder();
547 ib.setInstruction(new WriteMetadataCaseBuilder().setWriteMetadata(aab.build()).build());
549 // Put our Instruction in a list of Instructions
550 InstructionsBuilder isb = new InstructionsBuilder();
551 List<Instruction> instructions = new ArrayList<Instruction>();
552 instructions.add(ib.build());
553 isb.setInstruction(instructions);
557 private static InstructionsBuilder createGotoTableInstructions() {
559 GoToTableBuilder aab = new GoToTableBuilder();
560 aab.setTableId((short) 2);
562 InstructionBuilder ib = new InstructionBuilder();
563 ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
565 // Put our Instruction in a list of Instructions
566 InstructionsBuilder isb = new InstructionsBuilder();
567 List<Instruction> instructions = new ArrayList<Instruction>();
568 instructions.add(ib.build());
569 isb.setInstruction(instructions);
573 private static InstructionsBuilder createDropInstructions() {
574 DropActionBuilder dab = new DropActionBuilder();
575 DropAction dropAction = dab.build();
576 ActionBuilder ab = new ActionBuilder();
577 ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
579 // Add our drop action to a list
580 List<Action> actionList = new ArrayList<Action>();
581 actionList.add(ab.build());
583 // Create an Apply Action
584 ApplyActionsBuilder aab = new ApplyActionsBuilder();
585 aab.setAction(actionList);
587 // Wrap our Apply Action in an Instruction
588 InstructionBuilder ib = new InstructionBuilder();
589 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
591 // Put our Instruction in a list of Instructions
592 InstructionsBuilder isb = new InstructionsBuilder();
593 List<Instruction> instructions = new ArrayList<Instruction>();
594 instructions.add(ib.build());
595 isb.setInstruction(instructions);
599 private static InstructionsBuilder createAppyActionInstruction() {
601 List<Action> actionList = new ArrayList<Action>();
602 ActionBuilder ab = new ActionBuilder();
603 ControllerActionBuilder controller = new ControllerActionBuilder();
604 controller.setMaxLength(5);
605 ab.setAction(new ControllerActionCaseBuilder().setControllerAction(controller.build()).build());
606 actionList.add(ab.build());
607 // Create an Apply Action
608 ApplyActionsBuilder aab = new ApplyActionsBuilder();
609 aab.setAction(actionList);
611 // Wrap our Apply Action in an Instruction
612 InstructionBuilder ib = new InstructionBuilder();
613 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
615 // Put our Instruction in a list of Instructions
616 InstructionsBuilder isb = new InstructionsBuilder();
617 List<Instruction> instructions = new ArrayList<Instruction>();
618 instructions.add(ib.build());
619 isb.setInstruction(instructions);
623 private static InstructionsBuilder createAppyActionInstruction1() {
625 List<Action> actionList = new ArrayList<Action>();
626 ActionBuilder ab = new ActionBuilder();
628 OutputActionBuilder output = new OutputActionBuilder();
629 output.setMaxLength(56);
630 Uri value = new Uri("PCEP");
631 output.setOutputNodeConnector(value);
632 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
633 actionList.add(ab.build());
634 // Create an Apply Action
635 ApplyActionsBuilder aab = new ApplyActionsBuilder();
636 aab.setAction(actionList);
638 // Wrap our Apply Action in an Instruction
639 InstructionBuilder ib = new InstructionBuilder();
640 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
642 // Put our Instruction in a list of Instructions
643 InstructionsBuilder isb = new InstructionsBuilder();
644 List<Instruction> instructions = new ArrayList<Instruction>();
645 instructions.add(ib.build());
646 isb.setInstruction(instructions);
650 private static InstructionsBuilder createAppyActionInstruction2() {
652 List<Action> actionList = new ArrayList<Action>();
653 ActionBuilder ab = new ActionBuilder();
655 PushMplsActionBuilder push = new PushMplsActionBuilder();
656 push.setEthernetType(new Integer(0x8847));
657 ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
658 actionList.add(ab.build());
659 // Create an Apply Action
660 ApplyActionsBuilder aab = new ApplyActionsBuilder();
661 aab.setAction(actionList);
663 // Wrap our Apply Action in an Instruction
664 InstructionBuilder ib = new InstructionBuilder();
665 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
667 // Put our Instruction in a list of Instructions
668 InstructionsBuilder isb = new InstructionsBuilder();
669 List<Instruction> instructions = new ArrayList<Instruction>();
670 instructions.add(ib.build());
671 isb.setInstruction(instructions);
675 private static InstructionsBuilder createAppyActionInstruction3() {
677 List<Action> actionList = new ArrayList<Action>();
678 ActionBuilder ab = new ActionBuilder();
680 PushPbbActionBuilder pbb = new PushPbbActionBuilder();
681 pbb.setEthernetType(new Integer(0x88E7));
682 ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
683 actionList.add(ab.build());
684 // Create an Apply Action
685 ApplyActionsBuilder aab = new ApplyActionsBuilder();
686 aab.setAction(actionList);
688 // Wrap our Apply Action in an Instruction
689 InstructionBuilder ib = new InstructionBuilder();
690 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
692 // Put our Instruction in a list of Instructions
693 InstructionsBuilder isb = new InstructionsBuilder();
694 List<Instruction> instructions = new ArrayList<Instruction>();
695 instructions.add(ib.build());
696 isb.setInstruction(instructions);
700 private static InstructionsBuilder createAppyActionInstruction4() {
702 List<Action> actionList = new ArrayList<Action>();
703 ActionBuilder ab = new ActionBuilder();
705 PushVlanActionBuilder vlan = new PushVlanActionBuilder();
706 vlan.setEthernetType(new Integer(0x8100));
707 ab.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
708 actionList.add(ab.build());
710 // Create an Apply Action
711 ApplyActionsBuilder aab = new ApplyActionsBuilder();
712 aab.setAction(actionList);
714 // Wrap our Apply Action in an Instruction
715 InstructionBuilder ib = new InstructionBuilder();
716 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
718 // Put our Instruction in a list of Instructions
719 InstructionsBuilder isb = new InstructionsBuilder();
720 List<Instruction> instructions = new ArrayList<Instruction>();
721 instructions.add(ib.build());
722 isb.setInstruction(instructions);
726 private static InstructionsBuilder createAppyActionInstruction5() {
728 List<Action> actionList = new ArrayList<Action>();
729 ActionBuilder ab = new ActionBuilder();
731 SetDlDstActionBuilder setdl = new SetDlDstActionBuilder();
732 setdl.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
733 ab.setAction(new SetDlDstActionCaseBuilder().setSetDlDstAction(setdl.build()).build());
734 actionList.add(ab.build());
735 // Create an Apply Action
736 ApplyActionsBuilder aab = new ApplyActionsBuilder();
737 aab.setAction(actionList);
739 // Wrap our Apply Action in an Instruction
740 InstructionBuilder ib = new InstructionBuilder();
741 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
743 // Put our Instruction in a list of Instructions
744 InstructionsBuilder isb = new InstructionsBuilder();
745 List<Instruction> instructions = new ArrayList<Instruction>();
746 instructions.add(ib.build());
747 isb.setInstruction(instructions);
751 private static InstructionsBuilder createAppyActionInstruction6() {
753 List<Action> actionList = new ArrayList<Action>();
754 ActionBuilder ab = new ActionBuilder();
756 SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
757 src.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
758 ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(src.build()).build());
759 actionList.add(ab.build());
761 // Create an Apply Action
762 ApplyActionsBuilder aab = new ApplyActionsBuilder();
763 aab.setAction(actionList);
765 // Wrap our Apply Action in an Instruction
766 InstructionBuilder ib = new InstructionBuilder();
767 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
769 // Put our Instruction in a list of Instructions
770 InstructionsBuilder isb = new InstructionsBuilder();
771 List<Instruction> instructions = new ArrayList<Instruction>();
772 instructions.add(ib.build());
773 isb.setInstruction(instructions);
777 private static InstructionsBuilder createAppyActionInstruction7() {
779 List<Action> actionList = new ArrayList<Action>();
780 ActionBuilder ab = new ActionBuilder();
782 SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
783 VlanId a = new VlanId(4000);
785 ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
786 actionList.add(ab.build());
787 // Create an Apply Action
788 ApplyActionsBuilder aab = new ApplyActionsBuilder();
789 aab.setAction(actionList);
791 // Wrap our Apply Action in an Instruction
792 InstructionBuilder ib = new InstructionBuilder();
793 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
795 // Put our Instruction in a list of Instructions
796 InstructionsBuilder isb = new InstructionsBuilder();
797 List<Instruction> instructions = new ArrayList<Instruction>();
798 instructions.add(ib.build());
799 isb.setInstruction(instructions);
803 private static InstructionsBuilder createAppyActionInstruction8() {
805 List<Action> actionList = new ArrayList<Action>();
806 ActionBuilder ab = new ActionBuilder();
808 SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
809 VlanPcp pcp1 = new VlanPcp((short) 2);
810 pcp.setVlanPcp(pcp1);
811 ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
812 actionList.add(ab.build());
813 // Create an Apply Action
814 ApplyActionsBuilder aab = new ApplyActionsBuilder();
815 aab.setAction(actionList);
817 // Wrap our Apply Action in an Instruction
818 InstructionBuilder ib = new InstructionBuilder();
819 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
821 // Put our Instruction in a list of Instructions
822 InstructionsBuilder isb = new InstructionsBuilder();
823 List<Instruction> instructions = new ArrayList<Instruction>();
824 instructions.add(ib.build());
825 isb.setInstruction(instructions);
829 private static InstructionsBuilder createAppyActionInstruction9() {
831 List<Action> actionList = new ArrayList<Action>();
832 ActionBuilder ab = new ActionBuilder();
834 CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
835 ab.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
836 actionList.add(ab.build());
837 // Create an Apply Action
838 ApplyActionsBuilder aab = new ApplyActionsBuilder();
839 aab.setAction(actionList);
841 // Wrap our Apply Action in an Instruction
842 InstructionBuilder ib = new InstructionBuilder();
843 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
845 // Put our Instruction in a list of Instructions
846 InstructionsBuilder isb = new InstructionsBuilder();
847 List<Instruction> instructions = new ArrayList<Instruction>();
848 instructions.add(ib.build());
849 isb.setInstruction(instructions);
853 private static InstructionsBuilder createAppyActionInstruction10() {
855 List<Action> actionList = new ArrayList<Action>();
856 ActionBuilder ab = new ActionBuilder();
858 CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
859 ab.setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(ttlout.build()).build());
860 actionList.add(ab.build());
861 // Create an Apply Action
862 ApplyActionsBuilder aab = new ApplyActionsBuilder();
863 aab.setAction(actionList);
865 // Wrap our Apply Action in an Instruction
866 InstructionBuilder ib = new InstructionBuilder();
867 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
869 // Put our Instruction in a list of Instructions
870 InstructionsBuilder isb = new InstructionsBuilder();
871 List<Instruction> instructions = new ArrayList<Instruction>();
872 instructions.add(ib.build());
873 isb.setInstruction(instructions);
877 private static InstructionsBuilder createAppyActionInstruction11() {
879 List<Action> actionList = new ArrayList<Action>();
880 ActionBuilder ab = new ActionBuilder();
882 DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
883 ab.setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(mpls.build()).build());
884 actionList.add(ab.build());
885 // Create an Apply Action
886 ApplyActionsBuilder aab = new ApplyActionsBuilder();
887 aab.setAction(actionList);
889 // Wrap our Apply Action in an Instruction
890 InstructionBuilder ib = new InstructionBuilder();
891 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
893 // Put our Instruction in a list of Instructions
894 InstructionsBuilder isb = new InstructionsBuilder();
895 List<Instruction> instructions = new ArrayList<Instruction>();
896 instructions.add(ib.build());
897 isb.setInstruction(instructions);
901 private static InstructionsBuilder createAppyActionInstruction12() {
903 List<Action> actionList = new ArrayList<Action>();
904 ActionBuilder ab = new ActionBuilder();
906 DecNwTtlBuilder nwttl = new DecNwTtlBuilder();
907 ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(nwttl.build()).build());
908 actionList.add(ab.build());
910 // Create an Apply Action
911 ApplyActionsBuilder aab = new ApplyActionsBuilder();
912 aab.setAction(actionList);
914 // Wrap our Apply Action in an Instruction
915 InstructionBuilder ib = new InstructionBuilder();
916 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
918 // Put our Instruction in a list of Instructions
919 InstructionsBuilder isb = new InstructionsBuilder();
920 List<Instruction> instructions = new ArrayList<Instruction>();
921 instructions.add(ib.build());
922 isb.setInstruction(instructions);
926 private static InstructionsBuilder createAppyActionInstruction13() {
928 List<Action> actionList = new ArrayList<Action>();
929 ActionBuilder ab = new ActionBuilder();
931 DropActionBuilder drop = new DropActionBuilder();
932 ab.setAction(new DropActionCaseBuilder().setDropAction(drop.build()).build());
933 actionList.add(ab.build());
935 // Create an Apply Action
936 ApplyActionsBuilder aab = new ApplyActionsBuilder();
937 aab.setAction(actionList);
939 // Wrap our Apply Action in an Instruction
940 InstructionBuilder ib = new InstructionBuilder();
941 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
943 // Put our Instruction in a list of Instructions
944 InstructionsBuilder isb = new InstructionsBuilder();
945 List<Instruction> instructions = new ArrayList<Instruction>();
946 instructions.add(ib.build());
947 isb.setInstruction(instructions);
951 private static InstructionsBuilder createAppyActionInstruction14() {
953 List<Action> actionList = new ArrayList<Action>();
954 ActionBuilder ab = new ActionBuilder();
956 FloodActionBuilder fld = new FloodActionBuilder();
957 ab.setAction(new FloodActionCaseBuilder().setFloodAction(fld.build()).build());
958 actionList.add(ab.build());
959 // Create an Apply Action
960 ApplyActionsBuilder aab = new ApplyActionsBuilder();
961 aab.setAction(actionList);
963 // Wrap our Apply Action in an Instruction
964 InstructionBuilder ib = new InstructionBuilder();
965 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
967 // Put our Instruction in a list of Instructions
968 InstructionsBuilder isb = new InstructionsBuilder();
969 List<Instruction> instructions = new ArrayList<Instruction>();
970 instructions.add(ib.build());
971 isb.setInstruction(instructions);
975 private static InstructionsBuilder createAppyActionInstruction15() {
977 List<Action> actionList = new ArrayList<Action>();
978 ActionBuilder ab = new ActionBuilder();
980 FloodAllActionBuilder fldall = new FloodAllActionBuilder();
981 ab.setAction(new FloodAllActionCaseBuilder().setFloodAllAction(fldall.build()).build());
982 actionList.add(ab.build());
983 // Create an Apply Action
984 ApplyActionsBuilder aab = new ApplyActionsBuilder();
985 aab.setAction(actionList);
987 // Wrap our Apply Action in an Instruction
988 InstructionBuilder ib = new InstructionBuilder();
989 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
991 // Put our Instruction in a list of Instructions
992 InstructionsBuilder isb = new InstructionsBuilder();
993 List<Instruction> instructions = new ArrayList<Instruction>();
994 instructions.add(ib.build());
995 isb.setInstruction(instructions);
999 private static InstructionsBuilder createAppyActionInstruction16() {
1001 List<Action> actionList = new ArrayList<Action>();
1002 ActionBuilder ab = new ActionBuilder();
1004 GroupActionBuilder groupActionB = new GroupActionBuilder();
1005 groupActionB.setGroupId(1L);
1006 groupActionB.setGroup("0");
1007 ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
1008 actionList.add(ab.build());
1010 // Create an Apply Action
1011 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1012 aab.setAction(actionList);
1014 // Wrap our Apply Action in an Instruction
1015 InstructionBuilder ib = new InstructionBuilder();
1016 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1018 // Put our Instruction in a list of Instructions
1019 InstructionsBuilder isb = new InstructionsBuilder();
1020 List<Instruction> instructions = new ArrayList<Instruction>();
1021 instructions.add(ib.build());
1022 isb.setInstruction(instructions);
1026 private static InstructionsBuilder createAppyActionInstruction17() {
1028 List<Action> actionList = new ArrayList<Action>();
1029 ActionBuilder ab = new ActionBuilder();
1031 HwPathActionBuilder hwPathB = new HwPathActionBuilder();
1032 ab.setAction(new HwPathActionCaseBuilder().setHwPathAction(hwPathB.build()).build());
1033 actionList.add(ab.build());
1034 // Create an Apply Action
1035 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1036 aab.setAction(actionList);
1038 // Wrap our Apply Action in an Instruction
1039 InstructionBuilder ib = new InstructionBuilder();
1040 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1042 // Put our Instruction in a list of Instructions
1043 InstructionsBuilder isb = new InstructionsBuilder();
1044 List<Instruction> instructions = new ArrayList<Instruction>();
1045 instructions.add(ib.build());
1046 isb.setInstruction(instructions);
1050 private static InstructionsBuilder createAppyActionInstruction18() {
1052 List<Action> actionList = new ArrayList<Action>();
1053 ActionBuilder ab = new ActionBuilder();
1055 LoopbackActionBuilder loopbackActionBuilder = new LoopbackActionBuilder();
1056 ab.setAction(new LoopbackActionCaseBuilder().setLoopbackAction(loopbackActionBuilder.build()).build());
1057 actionList.add(ab.build());
1059 // Create an Apply Action
1060 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1061 aab.setAction(actionList);
1063 // Wrap our Apply Action in an Instruction
1064 InstructionBuilder ib = new InstructionBuilder();
1065 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1067 // Put our Instruction in a list of Instructions
1068 InstructionsBuilder isb = new InstructionsBuilder();
1069 List<Instruction> instructions = new ArrayList<Instruction>();
1070 instructions.add(ib.build());
1071 isb.setInstruction(instructions);
1075 private static InstructionsBuilder createAppyActionInstruction19() {
1077 List<Action> actionList = new ArrayList<Action>();
1078 ActionBuilder ab = new ActionBuilder();
1080 PopMplsActionBuilder popMplsActionBuilder = new PopMplsActionBuilder();
1081 popMplsActionBuilder.setEthernetType(0XB);
1082 ab.setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsActionBuilder.build()).build());
1083 actionList.add(ab.build());
1084 // Create an Apply Action
1085 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1086 aab.setAction(actionList);
1088 // Wrap our Apply Action in an Instruction
1089 InstructionBuilder ib = new InstructionBuilder();
1090 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1092 // Put our Instruction in a list of Instructions
1093 InstructionsBuilder isb = new InstructionsBuilder();
1094 List<Instruction> instructions = new ArrayList<Instruction>();
1095 instructions.add(ib.build());
1096 isb.setInstruction(instructions);
1100 private static InstructionsBuilder createAppyActionInstruction20() {
1102 List<Action> actionList = new ArrayList<Action>();
1103 ActionBuilder ab = new ActionBuilder();
1105 PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
1106 ab.setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPbbActionBuilder.build()).build());
1107 actionList.add(ab.build());
1108 // Create an Apply Action
1109 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1110 aab.setAction(actionList);
1112 // Wrap our Apply Action in an Instruction
1113 InstructionBuilder ib = new InstructionBuilder();
1114 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1116 // Put our Instruction in a list of Instructions
1117 InstructionsBuilder isb = new InstructionsBuilder();
1118 List<Instruction> instructions = new ArrayList<Instruction>();
1119 instructions.add(ib.build());
1120 isb.setInstruction(instructions);
1124 private static InstructionsBuilder createAppyActionInstruction21() {
1126 List<Action> actionList = new ArrayList<Action>();
1127 ActionBuilder ab = new ActionBuilder();
1129 PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
1130 ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
1131 actionList.add(ab.build());
1133 // Create an Apply Action
1134 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1135 aab.setAction(actionList);
1137 // Wrap our Apply Action in an Instruction
1138 InstructionBuilder ib = new InstructionBuilder();
1139 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1141 // Put our Instruction in a list of Instructions
1142 InstructionsBuilder isb = new InstructionsBuilder();
1143 List<Instruction> instructions = new ArrayList<Instruction>();
1144 instructions.add(ib.build());
1145 isb.setInstruction(instructions);
1149 private static InstructionsBuilder createAppyActionInstruction22() {
1151 List<Action> actionList = new ArrayList<Action>();
1152 ActionBuilder ab = new ActionBuilder();
1154 SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
1155 setDlTypeActionBuilder.setDlType(new EtherType(8L));
1156 ab.setAction(new SetDlTypeActionCaseBuilder().setSetDlTypeAction(setDlTypeActionBuilder.build()).build());
1157 actionList.add(ab.build());
1159 // Create an Apply Action
1160 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1161 aab.setAction(actionList);
1163 // Wrap our Apply Action in an Instruction
1164 InstructionBuilder ib = new InstructionBuilder();
1165 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1167 // Put our Instruction in a list of Instructions
1168 InstructionsBuilder isb = new InstructionsBuilder();
1169 List<Instruction> instructions = new ArrayList<Instruction>();
1170 instructions.add(ib.build());
1171 isb.setInstruction(instructions);
1175 private static InstructionsBuilder createAppyActionInstruction23() {
1177 List<Action> actionList = new ArrayList<Action>();
1178 ActionBuilder ab = new ActionBuilder();
1180 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1181 setFieldBuilder.setInPort(new Long(2));
1182 actionList.add(ab.build());
1184 // Create an Apply Action
1185 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1186 aab.setAction(actionList);
1188 // Wrap our Apply Action in an Instruction
1189 InstructionBuilder ib = new InstructionBuilder();
1190 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1192 // Put our Instruction in a list of Instructions
1193 InstructionsBuilder isb = new InstructionsBuilder();
1194 List<Instruction> instructions = new ArrayList<Instruction>();
1195 instructions.add(ib.build());
1196 isb.setInstruction(instructions);
1200 private static InstructionsBuilder createAppyActionInstruction24() {
1202 List<Action> actionList = new ArrayList<Action>();
1203 ActionBuilder ab = new ActionBuilder();
1205 SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
1206 setMplsTtlActionBuilder.setMplsTtl((short) 0X1);
1207 ab.setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMplsTtlActionBuilder.build()).build());
1208 actionList.add(ab.build());
1210 // Create an Apply Action
1211 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1212 aab.setAction(actionList);
1214 // Wrap our Apply Action in an Instruction
1215 InstructionBuilder ib = new InstructionBuilder();
1216 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1218 // Put our Instruction in a list of Instructions
1219 InstructionsBuilder isb = new InstructionsBuilder();
1220 List<Instruction> instructions = new ArrayList<Instruction>();
1221 instructions.add(ib.build());
1222 isb.setInstruction(instructions);
1226 private static InstructionsBuilder createAppyActionInstruction25() {
1228 List<Action> actionList = new ArrayList<Action>();
1229 ActionBuilder ab = new ActionBuilder();
1231 SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
1232 Ipv4Builder ipnext = new Ipv4Builder();
1233 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
1234 ipnext.setIpv4Address(prefix);
1235 setNextHopActionBuilder.setAddress(ipnext.build());
1236 ab.setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilder.build()).build());
1237 actionList.add(ab.build());
1239 // Create an Apply Action
1240 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1241 aab.setAction(actionList);
1243 // Wrap our Apply Action in an Instruction
1244 InstructionBuilder ib = new InstructionBuilder();
1245 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1247 // Put our Instruction in a list of Instructions
1248 InstructionsBuilder isb = new InstructionsBuilder();
1249 List<Instruction> instructions = new ArrayList<Instruction>();
1250 instructions.add(ib.build());
1251 isb.setInstruction(instructions);
1255 private static InstructionsBuilder createAppyActionInstruction26() {
1257 List<Action> actionList = new ArrayList<Action>();
1258 ActionBuilder ab = new ActionBuilder();
1260 SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
1261 Ipv4Builder ipdst = new Ipv4Builder();
1262 Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
1263 ipdst.setIpv4Address(prefixdst);
1264 setNwDstActionBuilder.setAddress(ipdst.build());
1265 ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
1266 actionList.add(ab.build());
1268 // Create an Apply Action
1269 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1270 aab.setAction(actionList);
1272 // Wrap our Apply Action in an Instruction
1273 InstructionBuilder ib = new InstructionBuilder();
1274 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1276 // Put our Instruction in a list of Instructions
1277 InstructionsBuilder isb = new InstructionsBuilder();
1278 List<Instruction> instructions = new ArrayList<Instruction>();
1279 instructions.add(ib.build());
1280 isb.setInstruction(instructions);
1284 private static InstructionsBuilder createAppyActionInstruction27() {
1286 List<Action> actionList = new ArrayList<Action>();
1287 ActionBuilder ab = new ActionBuilder();
1289 SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
1290 Ipv4Builder ipsrc = new Ipv4Builder();
1291 Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
1292 ipsrc.setIpv4Address(prefixsrc);
1293 setNwsrcActionBuilder.setAddress(ipsrc.build());
1294 ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
1295 actionList.add(ab.build());
1297 // Create an Apply Action
1298 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1299 aab.setAction(actionList);
1301 // Wrap our Apply Action in an Instruction
1302 InstructionBuilder ib = new InstructionBuilder();
1303 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1305 // Put our Instruction in a list of Instructions
1306 InstructionsBuilder isb = new InstructionsBuilder();
1307 List<Instruction> instructions = new ArrayList<Instruction>();
1308 instructions.add(ib.build());
1309 isb.setInstruction(instructions);
1313 private static InstructionsBuilder createAppyActionInstruction28() {
1315 List<Action> actionList = new ArrayList<Action>();
1316 ActionBuilder ab = new ActionBuilder();
1318 SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
1319 setNwTosActionBuilder.setTos(1);
1320 ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.build()).build());
1321 actionList.add(ab.build());
1322 // Create an Apply Action
1323 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1324 aab.setAction(actionList);
1326 // Wrap our Apply Action in an Instruction
1327 InstructionBuilder ib = new InstructionBuilder();
1328 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1330 // Put our Instruction in a list of Instructions
1331 InstructionsBuilder isb = new InstructionsBuilder();
1332 List<Instruction> instructions = new ArrayList<Instruction>();
1333 instructions.add(ib.build());
1334 isb.setInstruction(instructions);
1338 private static InstructionsBuilder createAppyActionInstruction29() {
1340 List<Action> actionList = new ArrayList<Action>();
1341 ActionBuilder ab = new ActionBuilder();
1343 SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
1344 setNwTtlActionBuilder.setNwTtl((short) 1);
1345 ab.setAction(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
1346 actionList.add(ab.build());
1348 // Create an Apply Action
1349 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1350 aab.setAction(actionList);
1352 // Wrap our Apply Action in an Instruction
1353 InstructionBuilder ib = new InstructionBuilder();
1354 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1356 // Put our Instruction in a list of Instructions
1357 InstructionsBuilder isb = new InstructionsBuilder();
1358 List<Instruction> instructions = new ArrayList<Instruction>();
1359 instructions.add(ib.build());
1360 isb.setInstruction(instructions);
1364 private static InstructionsBuilder createAppyActionInstruction30() {
1366 List<Action> actionList = new ArrayList<Action>();
1367 ActionBuilder ab = new ActionBuilder();
1369 SetQueueActionBuilder setQueueActionBuilder = new SetQueueActionBuilder();
1370 setQueueActionBuilder.setQueueId(1L);
1371 ab.setAction(new SetQueueActionCaseBuilder().setSetQueueAction(setQueueActionBuilder.build()).build());
1372 actionList.add(ab.build());
1373 // Create an Apply Action
1374 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1375 aab.setAction(actionList);
1377 // Wrap our Apply Action in an Instruction
1378 InstructionBuilder ib = new InstructionBuilder();
1379 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1381 // Put our Instruction in a list of Instructions
1382 InstructionsBuilder isb = new InstructionsBuilder();
1383 List<Instruction> instructions = new ArrayList<Instruction>();
1384 instructions.add(ib.build());
1385 isb.setInstruction(instructions);
1389 private static InstructionsBuilder createAppyActionInstruction31() {
1391 List<Action> actionList = new ArrayList<Action>();
1392 ActionBuilder ab = new ActionBuilder();
1394 SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
1395 setTpDstActionBuilder.setPort(new PortNumber(109));
1397 ab.setAction(new SetTpDstActionCaseBuilder().setSetTpDstAction(setTpDstActionBuilder.build()).build());
1398 actionList.add(ab.build());
1399 // Create an Apply Action
1400 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1401 aab.setAction(actionList);
1403 // Wrap our Apply Action in an Instruction
1404 InstructionBuilder ib = new InstructionBuilder();
1405 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1407 // Put our Instruction in a list of Instructions
1408 InstructionsBuilder isb = new InstructionsBuilder();
1409 List<Instruction> instructions = new ArrayList<Instruction>();
1410 instructions.add(ib.build());
1411 isb.setInstruction(instructions);
1415 private static InstructionsBuilder createAppyActionInstruction32() {
1417 List<Action> actionList = new ArrayList<Action>();
1418 ActionBuilder ab = new ActionBuilder();
1420 SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
1421 setTpSrcActionBuilder.setPort(new PortNumber(109));
1422 ab.setAction(new SetTpSrcActionCaseBuilder().setSetTpSrcAction(setTpSrcActionBuilder.build()).build());
1423 actionList.add(ab.build());
1425 // Create an Apply Action
1426 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1427 aab.setAction(actionList);
1429 // Wrap our Apply Action in an Instruction
1430 InstructionBuilder ib = new InstructionBuilder();
1431 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1433 // Put our Instruction in a list of Instructions
1434 InstructionsBuilder isb = new InstructionsBuilder();
1435 List<Instruction> instructions = new ArrayList<Instruction>();
1436 instructions.add(ib.build());
1437 isb.setInstruction(instructions);
1441 private static InstructionsBuilder createAppyActionInstruction33() {
1443 List<Action> actionList = new ArrayList<Action>();
1444 ActionBuilder ab = new ActionBuilder();
1446 SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
1447 setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(2));
1448 ab.setAction(new SetVlanCfiActionCaseBuilder().setSetVlanCfiAction(setVlanCfiActionBuilder.build()).build());
1449 actionList.add(ab.build());
1451 // Create an Apply Action
1452 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1453 aab.setAction(actionList);
1455 // Wrap our Apply Action in an Instruction
1456 InstructionBuilder ib = new InstructionBuilder();
1457 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1459 // Put our Instruction in a list of Instructions
1460 InstructionsBuilder isb = new InstructionsBuilder();
1461 List<Instruction> instructions = new ArrayList<Instruction>();
1462 instructions.add(ib.build());
1463 isb.setInstruction(instructions);
1467 private static InstructionsBuilder createAppyActionInstruction34() {
1469 List<Action> actionList = new ArrayList<Action>();
1470 ActionBuilder ab = new ActionBuilder();
1472 SwPathActionBuilder swPathAction = new SwPathActionBuilder();
1473 ab.setAction(new SwPathActionCaseBuilder().setSwPathAction(swPathAction.build()).build());
1474 actionList.add(ab.build());
1476 // Create an Apply Action
1477 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1478 aab.setAction(actionList);
1480 // Wrap our Apply Action in an Instruction
1481 InstructionBuilder ib = new InstructionBuilder();
1482 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1484 // Put our Instruction in a list of Instructions
1485 InstructionsBuilder isb = new InstructionsBuilder();
1486 List<Instruction> instructions = new ArrayList<Instruction>();
1487 instructions.add(ib.build());
1488 isb.setInstruction(instructions);
1495 private static MatchBuilder createMatch1() {
1496 MatchBuilder match = new MatchBuilder();
1497 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
1498 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
1499 ipv4Match.setIpv4Destination(prefix);
1500 Ipv4Match i4m = ipv4Match.build();
1501 match.setLayer3Match(i4m);
1503 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1504 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1505 ethTypeBuilder.setType(new EtherType(0x0800L));
1506 eth.setEthernetType(ethTypeBuilder.build());
1507 match.setEthernetMatch(eth.build());
1514 private static MatchBuilder createMatch2() {
1515 MatchBuilder match = new MatchBuilder();
1516 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
1517 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
1518 ipv4Match.setIpv4Source(prefix);
1519 Ipv4Match i4m = ipv4Match.build();
1520 match.setLayer3Match(i4m);
1522 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1523 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1524 ethTypeBuilder.setType(new EtherType(0x0800L));
1525 eth.setEthernetType(ethTypeBuilder.build());
1526 match.setEthernetMatch(eth.build());
1533 private static MatchBuilder createMatch3() {
1534 MatchBuilder match = new MatchBuilder();
1535 EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
1536 EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
1537 ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
1538 ethernetMatch.setEthernetSource(ethSourceBuilder.build());
1539 match.setEthernetMatch(ethernetMatch.build());
1544 private static MatchBuilder createInphyportMatch() {
1545 MatchBuilder match = new MatchBuilder();
1546 match.setInPort(202L);
1547 match.setInPhyPort(10122L);
1551 private static MatchBuilder createEthernetMatch() {
1552 MatchBuilder match = new MatchBuilder();
1554 byte[] mask1 = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
1555 byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
1557 EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
1559 EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
1560 EtherType type = new EtherType(0x0800L);
1561 ethmatch.setEthernetType(ethtype.setType(type).build());
1563 EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
1566 MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
1567 ethdest.setAddress(macdest);
1568 ethdest.setMask(mask1);
1570 ethmatch.setEthernetDestination(ethdest.build());
1572 EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
1573 MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
1574 ethsrc.setAddress(macsrc);
1575 ethsrc.setMask(mask2);
1577 ethmatch.setEthernetSource(ethsrc.build());
1578 match.setEthernetMatch(ethmatch.build());
1587 private static MatchBuilder createVlanMatch() {
1588 MatchBuilder match = new MatchBuilder();
1589 VlanMatchBuilder vlanBuilder = new VlanMatchBuilder(); // vlan match
1590 VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
1591 VlanId vlanId = new VlanId(10);
1592 VlanPcp vpcp = new VlanPcp((short) 3);
1593 vlanBuilder.setVlanPcp(vpcp);
1594 vlanBuilder.setVlanId(vlanIdBuilder.setVlanId(vlanId).build());
1595 match.setVlanMatch(vlanBuilder.build());
1602 private static MatchBuilder createArpMatch() {
1603 MatchBuilder match = new MatchBuilder();
1605 EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
1606 MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
1607 MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
1609 byte[] mask = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
1610 byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
1612 EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
1613 EtherType type = new EtherType(0x0806L);
1614 ethmatch.setEthernetType(ethtype.setType(type).build());
1616 Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
1617 Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
1619 ArpMatchBuilder arpmatch = new ArpMatchBuilder(); // arp match
1620 ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
1621 arpsrc.setAddress(macsrc);
1622 arpsrc.setMask(mask);
1623 ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
1624 arpdst.setAddress(macdest);
1625 arpdst.setMask(mask2);
1626 arpmatch.setArpOp(2);
1627 arpmatch.setArpSourceHardwareAddress(arpsrc.build());
1628 arpmatch.setArpTargetHardwareAddress(arpdst.build());
1629 arpmatch.setArpSourceTransportAddress(srcip);
1630 arpmatch.setArpTargetTransportAddress(dstip);
1632 match.setEthernetMatch(ethmatch.build());
1633 match.setLayer3Match(arpmatch.build());
1641 private static MatchBuilder createIPMatch() {
1642 MatchBuilder match = new MatchBuilder();
1643 EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
1644 EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
1645 EtherType type = new EtherType(0x0800L);
1646 ethmatch.setEthernetType(ethtype.setType(type).build());
1647 match.setEthernetMatch(ethmatch.build());
1649 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
1650 ipmatch.setIpProtocol((short) 1);
1651 Dscp dscp = new Dscp((short) 3);
1652 ipmatch.setIpDscp(dscp);
1653 ipmatch.setIpEcn((short) 2);
1654 match.setIpMatch(ipmatch.build());
1661 private static MatchBuilder createL3IPv4Match() {
1662 MatchBuilder match = new MatchBuilder();
1664 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1665 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1666 ethTypeBuilder.setType(new EtherType(0x0800L));
1667 eth.setEthernetType(ethTypeBuilder.build());
1668 match.setEthernetMatch(eth.build());
1670 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
1671 Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
1672 Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
1673 Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
1674 ipv4match.setIpv4Destination(dstip);
1675 ipv4match.setIpv4Source(srcip);
1676 match.setLayer3Match(ipv4match.build());
1685 private static MatchBuilder createL3IPv6Match() {
1686 MatchBuilder match = new MatchBuilder();
1688 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1689 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1690 ethTypeBuilder.setType(new EtherType(0x86ddL));
1691 eth.setEthernetType(ethTypeBuilder.build());
1692 match.setEthernetMatch(eth.build());
1694 Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
1695 Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
1696 Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
1697 MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
1698 MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
1699 Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
1700 nextheader.setIpv6Exthdr(58);
1701 Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
1702 Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
1703 ipv6label.setIpv6Flabel(label);
1705 Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
1707 icmpv6match.setIcmpv6Type((short) 135);
1708 icmpv6match.setIcmpv6Code((short) 0);
1709 match.setIcmpv6Match(icmpv6match.build());
1711 Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
1712 // ipv6match.setIpv6Source(srcip6);
1713 // ipv6match.setIpv6Destination(dstip6);
1714 // ipv6match.setIpv6ExtHeader(nextheader.build());
1715 ipv6match.setIpv6NdSll(ndsll);
1716 ipv6match.setIpv6NdTll(ndtll);
1717 // ipv6match.setIpv6NdTarget(ndtarget);
1718 ipv6match.setIpv6Label(ipv6label.build());
1720 match.setLayer3Match(ipv6match.build());
1729 private static MatchBuilder createICMPv4Match() {
1730 MatchBuilder match = new MatchBuilder();
1731 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1732 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1733 ethTypeBuilder.setType(new EtherType(0x0800L));
1734 eth.setEthernetType(ethTypeBuilder.build());
1735 match.setEthernetMatch(eth.build());
1737 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
1738 ipmatch.setIpProtocol((short) 1);
1739 match.setIpMatch(ipmatch.build());
1741 Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
1743 icmpv4match.setIcmpv4Type((short) 8);
1744 icmpv4match.setIcmpv4Code((short) 0);
1745 match.setIcmpv4Match(icmpv4match.build());
1752 private static MatchBuilder createICMPv6Match() {
1754 MatchBuilder match = new MatchBuilder();
1755 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1756 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1757 ethTypeBuilder.setType(new EtherType(0x86ddL));
1758 eth.setEthernetType(ethTypeBuilder.build());
1759 match.setEthernetMatch(eth.build());
1761 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
1762 ipmatch.setIpProtocol((short) 58);
1763 match.setIpMatch(ipmatch.build());
1765 Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
1767 icmpv6match.setIcmpv6Type((short) 135);
1768 icmpv6match.setIcmpv6Code((short) 1);
1769 match.setIcmpv6Match(icmpv6match.build());
1778 private static MatchBuilder createL4TCPMatch() {
1779 MatchBuilder match = new MatchBuilder();
1781 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1782 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1783 ethTypeBuilder.setType(new EtherType(0x0800L));
1784 eth.setEthernetType(ethTypeBuilder.build());
1785 match.setEthernetMatch(eth.build());
1787 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
1788 ipmatch.setIpProtocol((short) 6);
1789 match.setIpMatch(ipmatch.build());
1791 PortNumber srcport = new PortNumber(1213);
1792 PortNumber dstport = new PortNumber(646);
1793 TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
1794 tcpmatch.setTcpSourcePort(srcport);
1795 tcpmatch.setTcpDestinationPort(dstport);
1796 match.setLayer4Match(tcpmatch.build());
1804 private static MatchBuilder createL4UDPMatch() {
1805 MatchBuilder match = new MatchBuilder();
1807 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1808 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1809 ethTypeBuilder.setType(new EtherType(0x0800L));
1810 eth.setEthernetType(ethTypeBuilder.build());
1811 match.setEthernetMatch(eth.build());
1813 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
1814 ipmatch.setIpProtocol((short) 17);
1815 match.setIpMatch(ipmatch.build());
1817 PortNumber srcport = new PortNumber(1325);
1818 PortNumber dstport = new PortNumber(42);
1819 UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
1820 udpmatch.setUdpDestinationPort(dstport);
1821 udpmatch.setUdpSourcePort(srcport);
1822 match.setLayer4Match(udpmatch.build());
1830 private static MatchBuilder createL4SCTPMatch() {
1831 MatchBuilder match = new MatchBuilder();
1833 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1834 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1835 ethTypeBuilder.setType(new EtherType(0x0800L));
1836 eth.setEthernetType(ethTypeBuilder.build());
1837 match.setEthernetMatch(eth.build());
1839 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
1840 ipmatch.setIpProtocol((short) 132);
1841 match.setIpMatch(ipmatch.build());
1843 SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
1844 PortNumber srcport = new PortNumber(1435);
1845 PortNumber dstport = new PortNumber(22);
1846 sctpmatch.setSctpSourcePort(srcport);
1847 sctpmatch.setSctpDestinationPort(dstport);
1848 match.setLayer4Match(sctpmatch.build());
1856 private static MatchBuilder createMetadataMatch() {
1857 MatchBuilder match = new MatchBuilder();
1858 byte[] metamask = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1 };
1859 MetadataBuilder metadata = new MetadataBuilder(); // metadata match
1860 metadata.setMetadata(BigInteger.valueOf(500L));
1861 metadata.setMetadataMask(metamask);
1862 match.setMetadata(metadata.build());
1870 private static MatchBuilder createMplsMatch() {
1871 MatchBuilder match = new MatchBuilder();
1873 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1874 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1875 ethTypeBuilder.setType(new EtherType(0x8847L));
1876 eth.setEthernetType(ethTypeBuilder.build());
1877 match.setEthernetMatch(eth.build());
1879 ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
1881 protomatch.setMplsLabel((long) 36008);
1882 protomatch.setMplsTc((short) 4);
1883 protomatch.setMplsBos((short) 1);
1884 match.setProtocolMatchFields(protomatch.build());
1893 private static MatchBuilder createTunnelIDMatch() {
1894 MatchBuilder match = new MatchBuilder();
1895 TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
1896 tunnel.setTunnelId(BigInteger.valueOf(10668));
1897 byte[] mask = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1 };
1898 tunnel.setTunnelMask(mask);
1899 match.setTunnel(tunnel.build());
1904 public void _removeMDFlow(CommandInterpreter ci) {
1905 DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
1906 NodeBuilder tn = createTestNode(ci.nextArgument());
1907 FlowBuilder tf = createTestFlow(tn, ci.nextArgument());
1908 InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class)
1909 .child(Node.class, tn.getKey()).augmentation(FlowCapableNode.class)
1910 .child(Table.class, new TableKey(tf.getTableId())).child(Flow.class, tf.getKey())
1912 modification.removeOperationalData(nodeBuilderToInstanceId(tn));
1913 modification.removeOperationalData(path1);
1914 modification.removeConfigurationData(nodeBuilderToInstanceId(tn));
1915 modification.removeConfigurationData(path1);
1916 Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
1918 RpcResult<TransactionStatus> result = commitFuture.get();
1919 TransactionStatus status = result.getResult();
1920 ci.println("Status of Flow Data Loaded Transaction: " + status);
1922 } catch (InterruptedException e) {
1923 // TODO Auto-generated catch block
1924 e.printStackTrace();
1925 } catch (ExecutionException e) {
1926 // TODO Auto-generated catch block
1927 e.printStackTrace();
1931 public void _addMDFlow(CommandInterpreter ci) {
1932 NodeBuilder tn = createTestNode(ci.nextArgument());
1933 FlowBuilder tf = createTestFlow(tn, ci.nextArgument());
1934 writeFlow(ci, tf, tn);
1937 private void writeFlow(CommandInterpreter ci, FlowBuilder flow, NodeBuilder nodeBuilder) {
1938 DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
1939 InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class)
1940 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
1941 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey())
1943 modification.putOperationalData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
1944 modification.putOperationalData(path1, flow.build());
1945 modification.putConfigurationData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
1946 modification.putConfigurationData(path1, flow.build());
1947 Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
1949 RpcResult<TransactionStatus> result = commitFuture.get();
1950 TransactionStatus status = result.getResult();
1951 ci.println("Status of Flow Data Loaded Transaction: " + status);
1953 } catch (InterruptedException e) {
1954 // TODO Auto-generated catch block
1955 e.printStackTrace();
1956 } catch (ExecutionException e) {
1957 // TODO Auto-generated catch block
1958 e.printStackTrace();
1962 public void _modifyMDFlow(CommandInterpreter ci) {
1963 NodeBuilder tn = createTestNode(ci.nextArgument());
1964 FlowBuilder tf = createTestFlow(tn, ci.nextArgument());
1965 tf.setFlowName(updatedFlowName);
1966 writeFlow(ci, tf, tn);
1967 tf.setFlowName(originalFlowName);
1968 writeFlow(ci, tf, tn);
1971 private static NodeRef createNodeRef(String string) {
1972 NodeKey key = new NodeKey(new NodeId(string));
1973 InstanceIdentifier<Node> path = InstanceIdentifier.builder().node(Nodes.class).node(Node.class, key)
1976 return new NodeRef(path);
1980 public String getHelp() {