stress test related improvement
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTestCommandProvider.java
1 /*
2  * Copyright (c) 2013 Ericsson , Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowplugin.test;
10
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;
16
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.NotificationService;
23 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCaseBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCaseBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCaseBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.action._case.FloodActionBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.hw.path.action._case.HwPathActionBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.loopback.action._case.LoopbackActionBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.type.action._case.SetDlTypeActionBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.next.hop.action._case.SetNextHopActionBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.cfi.action._case.SetVlanCfiActionBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
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.TunnelBuilder;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
167 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
168 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
169 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
170 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
171 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
172 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
173 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
174 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
175 import org.opendaylight.yangtools.concepts.Registration;
176 import org.opendaylight.yangtools.yang.binding.DataObject;
177 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
178 import org.opendaylight.yangtools.yang.common.RpcResult;
179 import org.osgi.framework.BundleContext;
180 import org.slf4j.Logger;
181 import org.slf4j.LoggerFactory;
182
183 public class OpenflowpluginTestCommandProvider implements CommandProvider {
184
185     private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
186
187     private DataBrokerService dataBrokerService;
188     private ProviderContext pc;
189     private final BundleContext ctx;
190     private FlowBuilder testFlow;
191     private NodeBuilder testNode;
192     private final String originalFlowName = "Foo";
193     private final String updatedFlowName = "Bar";
194     private final FlowEventListener flowEventListener = new FlowEventListener();
195     private static NotificationService notificationService;
196     private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listener1Reg;
197
198     public OpenflowpluginTestCommandProvider(BundleContext ctx) {
199         this.ctx = ctx;
200     }
201
202     public void onSessionInitiated(ProviderContext session) {
203         pc = session;
204         notificationService = session.getSALService(NotificationService.class);
205         // For switch events
206         listener1Reg = notificationService.registerNotificationListener(flowEventListener);
207         dataBrokerService = session.getSALService(DataBrokerService.class);
208         ctx.registerService(CommandProvider.class.getName(), this, null);
209         createTestFlow(createTestNode(null), null, null);
210     }
211
212     private NodeBuilder createTestNode(String nodeId) {
213         if (nodeId == null) {
214             nodeId = OpenflowpluginTestActivator.NODE_ID;
215         }
216         NodeRef nodeOne = createNodeRef(nodeId);
217         NodeBuilder builder = new NodeBuilder();
218         builder.setId(new NodeId(nodeId));
219         builder.setKey(new NodeKey(builder.getId()));
220         testNode = builder;
221         return builder;
222     }
223
224     final class FlowEventListener implements SalFlowListener {
225
226         @Override
227         public void onFlowAdded(FlowAdded notification) {
228             LOG.info("flow to be added.........................." + notification.toString());
229             LOG.info("added flow Xid........................." + notification.getTransactionId().getValue());
230             LOG.info("-----------------------------------------------------------------------------------");
231         }
232
233         @Override
234         public void onFlowRemoved(FlowRemoved notification) {
235             LOG.debug("removed flow.........................." + notification.toString());
236             LOG.debug("remove flow Xid........................." + notification.getTransactionId().getValue());
237             LOG.debug("-----------------------------------------------------------------------------------");
238         }
239
240         @Override
241         public void onFlowUpdated(FlowUpdated notification) {
242             LOG.debug("updated flow.........................." + notification.toString());
243             LOG.debug("updated flow Xid........................." + notification.getTransactionId().getValue());
244             LOG.debug("-----------------------------------------------------------------------------------");
245         }
246
247         @Override
248         public void onNodeErrorNotification(NodeErrorNotification notification) {
249             LOG.error("Error notification  flow Xid........................."
250                     + notification.getTransactionId().getValue());
251             LOG.debug("-----------------------------------------------------------------------------------");
252         }
253
254         @Override
255         public void onNodeExperimenterErrorNotification(NodeExperimenterErrorNotification notification) {
256             // TODO Auto-generated method stub
257
258         }
259
260         @Override
261         public void onSwitchFlowRemoved(SwitchFlowRemoved notification) {
262             LOG.debug("Switch flow removed : Cookies..................." + notification.getCookie().toString());
263             LOG.debug("-----------------------------------------------------------------------------------");
264         }
265     }
266
267     private InstanceIdentifier<Node> nodeBuilderToInstanceId(NodeBuilder node) {
268         return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
269     }
270
271     private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
272
273         FlowBuilder flow = new FlowBuilder();
274         long id = 123;
275
276         String flowType = flowTypeArg;
277         if (flowType == null) {
278             flowType = "f1";
279         }
280
281         switch (flowType) {
282         case "f1":
283             id += 1;
284             flow.setMatch(createMatch1().build());
285             flow.setInstructions(createDecNwTtlInstructions().build());
286             break;
287         case "f2":
288             id += 2;
289             flow.setMatch(createMatch2().build());
290             flow.setInstructions(createDropInstructions().build());
291             break;
292         case "f3":
293             id += 3;
294             flow.setMatch(createMatch3().build());
295             flow.setInstructions(createDropInstructions().build());
296             break;
297         case "f4":
298             id += 4;
299             flow.setMatch(createEthernetMatch().build());
300             flow.setInstructions(createDropInstructions().build());
301             break;
302         case "f5":
303             id += 5;
304             flow.setMatch(createMatch1().build());
305             flow.setInstructions(createAppyActionInstruction().build());
306             break;
307         case "f6":
308             id += 6;
309             flow.setMatch(createMatch1().build());
310             flow.setInstructions(createGotoTableInstructions().build());
311             break;
312         case "f7":
313             id += 7;
314             flow.setMatch(createMatch1().build());
315             flow.setInstructions(createMeterInstructions().build());
316             break;
317         case "f8":
318             id += 8;
319             flow.setMatch(createMatch1().build());
320             flow.setInstructions(createAppyActionInstruction1().build());
321             break;
322         case "f9":
323             id += 9;
324             flow.setMatch(createMatch1().build());
325             flow.setInstructions(createAppyActionInstruction2().build());
326             break;
327         case "f10":
328             id += 10;
329             flow.setMatch(createMatch1().build());
330             flow.setInstructions(createAppyActionInstruction3().build());
331             break;
332         case "f11":
333             id += 11;
334             flow.setMatch(createMatch1().build());
335             flow.setInstructions(createAppyActionInstruction4().build());
336             break;
337         case "f12":
338             id += 12;
339             flow.setMatch(createMatch1().build());
340             flow.setInstructions(createAppyActionInstruction5().build());
341             break;
342         case "f13":
343             id += 13;
344             flow.setMatch(createMatch1().build());
345             flow.setInstructions(createAppyActionInstruction6().build());
346             break;
347         case "f14":
348             id += 14;
349             flow.setMatch(createMatch1().build());
350             flow.setInstructions(createAppyActionInstruction7().build());
351             break;
352         case "f15":
353             id += 15;
354             flow.setMatch(createMatch1().build());
355             flow.setInstructions(createAppyActionInstruction8().build());
356             break;
357         case "f16":
358             id += 16;
359             flow.setMatch(createMatch1().build());
360             flow.setInstructions(createAppyActionInstruction9().build());
361             break;
362         case "f17":
363             id += 17;
364             flow.setMatch(createMatch1().build());
365             flow.setInstructions(createAppyActionInstruction10().build());
366             break;
367         case "f18":
368             id += 18;
369             flow.setMatch(createMatch1().build());
370             flow.setInstructions(createAppyActionInstruction11().build());
371             break;
372         case "f19":
373             id += 19;
374             flow.setMatch(createMatch1().build());
375             flow.setInstructions(createAppyActionInstruction12().build());
376             break;
377         case "f20":
378             id += 20;
379             flow.setMatch(createMatch1().build());
380             flow.setInstructions(createAppyActionInstruction13().build());
381             break;
382         case "f21":
383             id += 21;
384             flow.setMatch(createMatch1().build());
385             flow.setInstructions(createAppyActionInstruction14().build());
386             break;
387         case "f22":
388             id += 22;
389             flow.setMatch(createMatch1().build());
390             flow.setInstructions(createAppyActionInstruction15().build());
391             break;
392         case "f23":
393             id += 23;
394             // f23 can be used as test-case for generating error notification
395             // if the particular group is not configured - tested
396             flow.setMatch(createMatch1().build());
397             flow.setInstructions(createAppyActionInstruction16().build());
398             break;
399         case "f24":
400             id += 24;
401             flow.setMatch(createMatch1().build());
402             flow.setInstructions(createAppyActionInstruction17().build());
403             break;
404         case "f25":
405             id += 25;
406             flow.setMatch(createMatch1().build());
407             flow.setInstructions(createAppyActionInstruction18().build());
408             break;
409         case "f26":
410             id += 26;
411             flow.setMatch(createMatch1().build());
412             flow.setInstructions(createAppyActionInstruction19().build());
413             break;
414         case "f27":
415             id += 27;
416             flow.setMatch(createMatch1().build());
417             flow.setInstructions(createMetadataInstructions().build());
418             break;
419         case "f28":
420             id += 28;
421             flow.setMatch(createMatch1().build());
422             flow.setInstructions(createAppyActionInstruction20().build());
423             break;
424         case "f29":
425             id += 29;
426             flow.setMatch(createMatch1().build());
427             flow.setInstructions(createAppyActionInstruction21().build());
428             break;
429         case "f30":
430             id += 30;
431             flow.setMatch(createMatch1().build());
432             flow.setInstructions(createAppyActionInstruction22().build());
433             break;
434         case "f31":
435             id += 31;
436             flow.setMatch(createMatch1().build());
437             flow.setInstructions(createAppyActionInstruction23(nodeBuilder.getId()).build());
438             break;
439         case "f32":
440             id += 32;
441             flow.setMatch(createMatch1().build());
442             flow.setInstructions(createAppyActionInstruction24().build());
443             break;
444         case "f33":
445             id += 33;
446             flow.setMatch(createMatch1().build());
447             flow.setInstructions(createAppyActionInstruction25().build());
448             break;
449         case "f34":
450             id += 34;
451             flow.setMatch(createMatch1().build());
452             flow.setInstructions(createAppyActionInstruction26().build());
453             break;
454         case "f35":
455             id += 35;
456             flow.setMatch(createMatch1().build());
457             flow.setInstructions(createAppyActionInstruction27().build());
458             break;
459         case "f36":
460             id += 36;
461             flow.setMatch(createMatch1().build());
462             flow.setInstructions(createAppyActionInstruction28().build());
463             break;
464         case "f37":
465             id += 37;
466             flow.setMatch(createMatch1().build());
467             flow.setInstructions(createAppyActionInstruction29().build());
468             break;
469         case "f38":
470             id += 38;
471             flow.setMatch(createMatch1().build());
472             flow.setInstructions(createAppyActionInstruction30().build());
473             break;
474         case "f39":
475             id += 39;
476             flow.setMatch(createMatch1().build());
477             flow.setInstructions(createAppyActionInstruction31().build());
478             break;
479         case "f40":
480             id += 40;
481             flow.setMatch(createMatch1().build());
482             flow.setInstructions(createAppyActionInstruction32().build());
483             break;
484         case "f41":
485             id += 41;
486             flow.setMatch(createMatch1().build());
487             flow.setInstructions(createAppyActionInstruction33().build());
488             break;
489         case "f42":
490             id += 42;
491             flow.setMatch(createMatch1().build());
492             flow.setInstructions(createAppyActionInstruction34().build());
493             break;
494         case "f43":
495             id += 43;
496             flow.setMatch(createICMPv6Match().build());
497             flow.setInstructions(createDecNwTtlInstructions().build());
498             break;
499         case "f44":
500             id += 44;
501             flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
502             flow.setInstructions(createDropInstructions().build());
503             break;
504         case "f45":
505             id += 45;
506             flow.setMatch(createMetadataMatch().build());
507             flow.setInstructions(createDropInstructions().build());
508             break;
509         case "f46":
510             id += 46;
511             flow.setMatch(createL3IPv6Match().build());
512             flow.setInstructions(createDecNwTtlInstructions().build());
513             break;
514         case "f47":
515             id += 47;
516             flow.setMatch(createL4SCTPMatch().build());
517             flow.setInstructions(createAppyActionInstruction().build());
518             break;
519         case "f48":
520             id += 48;
521             flow.setMatch(createTunnelIDMatch().build());
522             flow.setInstructions(createGotoTableInstructions().build());
523             break;
524         case "f49":
525             id += 49;
526             flow.setMatch(createVlanMatch().build());
527             flow.setInstructions(createMeterInstructions().build());
528             break;
529         case "f50":
530             id += 50;
531             flow.setMatch(createPbbMatch().build());
532             flow.setInstructions(createMeterInstructions().build());
533             break;
534         case "f51":
535             id += 51;
536             flow.setMatch(createVlanMatch().build());
537             flow.setInstructions(createDropInstructions().build());
538             break;
539         case "f52":
540             id += 52;
541             flow.setMatch(createL4TCPMatch().build());
542             flow.setInstructions(createDropInstructions().build());
543             break;
544
545         case "f53":
546             id += 53;
547             flow.setMatch(createL4UDPMatch().build());
548             flow.setInstructions(createDropInstructions().build());
549             break;
550         case "f54":
551             id += 54;
552             flow.setMatch(new MatchBuilder().build());
553             flow.setInstructions(createSentToControllerInstructions().build());
554             break;
555         case "f55":
556             id += 55;
557             flow.setMatch(createToSMatch().build());
558             flow.setInstructions(createDropInstructions().build());
559             break;
560         case "f56":
561             id += 56;
562             flow.setMatch(createToSMatch().build());
563             flow.setInstructions(createOutputInstructions("INPORT", 10).build());
564             break;
565         case "f57":
566             id += 57;
567             flow.setMatch(createToSMatch().build());
568             flow.setInstructions(createOutputInstructions("FLOOD", 20).build());
569             break;
570         case "f58":
571             id += 58;
572             flow.setMatch(createToSMatch().build());
573             flow.setInstructions(createOutputInstructions("ALL", 30).build());
574             break;
575         case "f59":
576             id += 59;
577             flow.setMatch(createToSMatch().build());
578             flow.setInstructions(createOutputInstructions("NORMAL", 40).build());
579             break;
580         case "f60":
581             id += 60;
582             flow.setMatch(createToSMatch().build());
583             flow.setInstructions(createOutputInstructions("LOCAL", 50).build());
584             break;
585         case "f61":
586             id += 61;
587             flow.setMatch(createToSMatch().build());
588             flow.setInstructions(createOutputInstructions("TABLE", 60).build());
589             break;
590         case "f62":
591             id += 62;
592             flow.setMatch(createToSMatch().build());
593             flow.setInstructions(createOutputInstructions("NONE", 70).build());
594             break;
595         case "f63":
596             id += 63;
597             flow.setMatch(createToSMatch().build());
598             flow.setInstructions(createStripVlanInstructions().build());
599             flow.setBarrier(Boolean.TRUE);
600             break;
601         case "f64":
602             id += 64;
603             flow.setMatch(createMatch1().build());
604             flow.setInstructions(createAppyActionInstruction35().build());
605             break;
606         case "f65":
607             id += 65;
608             flow.setMatch(createMatch1().build());
609             flow.setInstructions(createAppyActionInstruction36().build());
610             break;
611         case "f66":
612             id += 66;
613             flow.setMatch(createMatch1().build());
614             flow.setInstructions(createAppyActionInstruction37().build());
615             break;
616         case "f67":
617             id += 67;
618             flow.setMatch(createMatch1().build());
619             flow.setInstructions(createAppyActionInstruction38().build());
620             break;
621         case "f68":
622             id += 68;
623             flow.setMatch(createL4TCPMatch().build());
624             flow.setInstructions(createAppyActionInstruction39().build());
625             break;
626         case "f69":
627             id += 69;
628             flow.setMatch(createL4UDPMatch().build());
629             flow.setInstructions(createAppyActionInstruction40().build());
630             break;
631         case "f70":
632             id += 70;
633             flow.setMatch(createL4SCTPMatch().build());
634             flow.setInstructions(createAppyActionInstruction41().build());
635             break;
636         case "f71":
637             id += 71;
638             flow.setMatch(createICMPv4Match().build());
639             flow.setInstructions(createAppyActionInstruction42().build());
640             break;
641         case "f72":
642             id += 72;
643             flow.setMatch(createArpMatch().build());
644             flow.setInstructions(createAppyActionInstruction43().build());
645             break;
646         case "f73":
647             id += 73;
648             flow.setMatch(createL3IPv6Match().build());
649             flow.setInstructions(createAppyActionInstruction44().build());
650             break;
651         case "f74":
652             id += 74;
653             flow.setMatch(createICMPv6Match().build());
654             flow.setInstructions(createAppyActionInstruction45().build());
655             break;
656         case "f75":
657             id += 75;
658             flow.setMatch(createMplsMatch().build());
659             flow.setInstructions(createAppyActionInstruction46().build());
660             break;
661         case "f76":
662             id += 76;
663             flow.setMatch(createPbbMatch().build());
664             flow.setInstructions(createAppyActionInstruction47().build());
665             break;
666         case "f77":
667             id += 77;
668             flow.setMatch(createTunnelIDMatch().build());
669             flow.setInstructions(createAppyActionInstruction48().build());
670             break;
671         case "f78":
672             id += 78;
673             flow.setMatch(createMatch33().build());
674             flow.setInstructions(createDropInstructions().build());
675             break;
676         case "f79":
677             id += 79;
678             flow.setMatch(createICMPv6Match1().build());
679             flow.setInstructions(createDecNwTtlInstructions().build());
680             break;
681         case "f80":
682             id += 80;
683             flow.setMatch(createMatch1().build());
684             flow.setInstructions(createAppyActionInstruction88().build());
685             break;
686         case "f81":
687             id += 81;
688             flow.setMatch(createLLDPMatch().build());
689             flow.setInstructions(createSentToControllerInstructions().build());
690             break;
691         case "f82":
692             id += 82;
693             flow.setMatch(createToSMatch().build());
694             flow.setInstructions(createOutputInstructions().build());
695             break;
696         default:
697             LOG.warn("flow type not understood: {}", flowType);
698         }
699
700         FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
701         if (null == flow.isBarrier()) {
702             flow.setBarrier(Boolean.FALSE);
703         }
704         // flow.setBufferId(new Long(12));
705         BigInteger value = new BigInteger("10", 10);
706         // BigInteger outputPort = new BigInteger("65535", 10);
707         flow.setCookie(value);
708         flow.setCookieMask(value);
709         flow.setHardTimeout(0);
710         flow.setIdleTimeout(0);
711         flow.setInstallHw(false);
712         flow.setStrict(false);
713         flow.setContainerName(null);
714         flow.setFlags(new FlowModFlags(false, false, false, false, true));
715         flow.setId(new FlowId("12"));
716         flow.setTableId(getTableId(tableId));
717         // commenting setOutGroup and setOutPort, as by default
718         // OFPG_ANY is send
719         // enable setOutGroup and setOutPort to enable output filtering
720         // flow.setOutGroup(new Long(2));
721         // set outport to OFPP_NONE (65535) to disable remove restriction for
722         // flow
723         // flow.setOutPort(outputPort);
724
725         flow.setKey(key);
726         flow.setPriority(2);
727         flow.setFlowName(originalFlowName + "X" + flowType);
728         testFlow = flow;
729         return flow;
730     }
731
732     private FlowBuilder createtablemiss(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
733         FlowBuilder flow = new FlowBuilder();
734         long id = 456;
735         MatchBuilder matchBuilder = new MatchBuilder();
736         flow.setMatch(matchBuilder.build());
737         flow.setInstructions(createSentToControllerInstructions().build());
738         flow.setPriority(0);
739         flow.setTableId((short) 0);
740         FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
741         flow.setKey(key);
742         testFlow = flow;
743         return flow;
744     }
745
746     private short getTableId(String tableId) {
747         short table = 2;
748         try {
749             table = Short.parseShort(tableId);
750         } catch (Exception ex) {
751             // ignore exception and continue with default value
752         }
753
754         return table;
755
756     }
757
758     /**
759      * @return
760      */
761     private static InstructionsBuilder createDecNwTtlInstructions() {
762         DecNwTtlBuilder ta = new DecNwTtlBuilder();
763         DecNwTtl decNwTtl = ta.build();
764         ActionBuilder ab = new ActionBuilder();
765         ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
766
767         // Add our drop action to a list
768         List<Action> actionList = new ArrayList<Action>();
769         actionList.add(ab.build());
770
771         // Create an Apply Action
772         ApplyActionsBuilder aab = new ApplyActionsBuilder();
773         aab.setAction(actionList);
774
775         // Wrap our Apply Action in an Instruction
776         InstructionBuilder ib = new InstructionBuilder();
777         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
778         ib.setKey(new InstructionKey(0));
779         ib.setOrder(0);
780
781         // Put our Instruction in a list of Instructions
782         InstructionsBuilder isb = new InstructionsBuilder();
783         List<Instruction> instructions = new ArrayList<Instruction>();
784         instructions.add(ib.build());
785         isb.setInstruction(instructions);
786         return isb;
787     }
788
789     /**
790      * @return
791      */
792     private static InstructionsBuilder createMeterInstructions() {
793
794         MeterBuilder aab = new MeterBuilder();
795         aab.setMeterId(new MeterId(new Long(1)));
796
797         InstructionBuilder ib = new InstructionBuilder();
798         ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
799
800         // Put our Instruction in a list of Instructions
801         InstructionsBuilder isb = new InstructionsBuilder();
802         List<Instruction> instructions = new ArrayList<Instruction>();
803         instructions.add(ib.build());
804         isb.setInstruction(instructions);
805         return isb;
806     }
807
808     private static InstructionsBuilder createMetadataInstructions() {
809
810         WriteMetadataBuilder aab = new WriteMetadataBuilder();
811         aab.setMetadata(new BigInteger("10", 10));
812         aab.setMetadataMask(new BigInteger("12", 10));
813
814         InstructionBuilder ib = new InstructionBuilder();
815         ib.setInstruction(new WriteMetadataCaseBuilder().setWriteMetadata(aab.build()).build());
816
817         // Put our Instruction in a list of Instructions
818         InstructionsBuilder isb = new InstructionsBuilder();
819         List<Instruction> instructions = new ArrayList<Instruction>();
820         instructions.add(ib.build());
821         isb.setInstruction(instructions);
822         return isb;
823     }
824
825     private static InstructionsBuilder createGotoTableInstructions() {
826
827         GoToTableBuilder aab = new GoToTableBuilder();
828         aab.setTableId((short) 2);
829
830         InstructionBuilder ib = new InstructionBuilder();
831         ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
832
833         // Put our Instruction in a list of Instructions
834         InstructionsBuilder isb = new InstructionsBuilder();
835         List<Instruction> instructions = new ArrayList<Instruction>();
836         instructions.add(ib.build());
837         isb.setInstruction(instructions);
838         return isb;
839     }
840
841     private static InstructionsBuilder createDropInstructions() {
842         DropActionBuilder dab = new DropActionBuilder();
843         DropAction dropAction = dab.build();
844         ActionBuilder ab = new ActionBuilder();
845         ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
846
847         // Add our drop action to a list
848         List<Action> actionList = new ArrayList<Action>();
849         actionList.add(ab.build());
850
851         // Create an Apply Action
852         ApplyActionsBuilder aab = new ApplyActionsBuilder();
853         aab.setAction(actionList);
854
855         // Wrap our Apply Action in an Instruction
856         InstructionBuilder ib = new InstructionBuilder();
857         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
858
859         // Put our Instruction in a list of Instructions
860         InstructionsBuilder isb = new InstructionsBuilder();
861         List<Instruction> instructions = new ArrayList<Instruction>();
862         instructions.add(ib.build());
863         isb.setInstruction(instructions);
864         return isb;
865     }
866
867     private static InstructionsBuilder createAppyActionInstruction() {
868
869         List<Action> actionList = new ArrayList<Action>();
870         ActionBuilder ab = new ActionBuilder();
871         ControllerActionBuilder controller = new ControllerActionBuilder();
872         controller.setMaxLength(5);
873         ab.setAction(new ControllerActionCaseBuilder().setControllerAction(controller.build()).build());
874         actionList.add(ab.build());
875         // Create an Apply Action
876         ApplyActionsBuilder aab = new ApplyActionsBuilder();
877         aab.setAction(actionList);
878
879         // Wrap our Apply Action in an Instruction
880         InstructionBuilder ib = new InstructionBuilder();
881         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
882
883         // Put our Instruction in a list of Instructions
884         InstructionsBuilder isb = new InstructionsBuilder();
885         List<Instruction> instructions = new ArrayList<Instruction>();
886         instructions.add(ib.build());
887         isb.setInstruction(instructions);
888         return isb;
889     }
890
891     private static InstructionsBuilder createAppyActionInstruction1() {
892
893         List<Action> actionList = new ArrayList<Action>();
894         ActionBuilder ab = new ActionBuilder();
895
896         OutputActionBuilder output = new OutputActionBuilder();
897         output.setMaxLength(56);
898         Uri value = new Uri("PCEP");
899         output.setOutputNodeConnector(value);
900         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
901         actionList.add(ab.build());
902         // Create an Apply Action
903         ApplyActionsBuilder aab = new ApplyActionsBuilder();
904         aab.setAction(actionList);
905
906         // Wrap our Apply Action in an Instruction
907         InstructionBuilder ib = new InstructionBuilder();
908         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
909
910         // Put our Instruction in a list of Instructions
911         InstructionsBuilder isb = new InstructionsBuilder();
912         List<Instruction> instructions = new ArrayList<Instruction>();
913         instructions.add(ib.build());
914         isb.setInstruction(instructions);
915         return isb;
916     }
917
918     private static InstructionsBuilder createOutputInstructions() {
919
920         // test case for Output Port works if the particular port exists
921         // this particular test-case is for Port : 1
922         // tested as (addMDFlow openflow:<dpid> f82)
923         List<Action> actionList = new ArrayList<Action>();
924         ActionBuilder ab = new ActionBuilder();
925         OutputActionBuilder output = new OutputActionBuilder();
926
927         Uri value = new Uri("1");
928         output.setOutputNodeConnector(value);
929         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
930         ab.setOrder(0);
931         ab.setKey(new ActionKey(0));
932         actionList.add(ab.build());
933         // Create an Apply Action
934         ApplyActionsBuilder aab = new ApplyActionsBuilder();
935         aab.setAction(actionList);
936
937         // Wrap our Apply Action in an Instruction
938         InstructionBuilder ib = new InstructionBuilder();
939         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
940         ib.setOrder(0);
941         ib.setKey(new InstructionKey(0));
942
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);
948         return isb;
949     }
950
951     private static InstructionsBuilder createSentToControllerInstructions() {
952         List<Action> actionList = new ArrayList<Action>();
953         ActionBuilder ab = new ActionBuilder();
954
955         OutputActionBuilder output = new OutputActionBuilder();
956         output.setMaxLength(new Integer(0xffff));
957         Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
958         output.setOutputNodeConnector(value);
959         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
960         ab.setOrder(0);
961         ab.setKey(new ActionKey(0));
962         actionList.add(ab.build());
963         // Create an Apply Action
964         ApplyActionsBuilder aab = new ApplyActionsBuilder();
965         aab.setAction(actionList);
966
967         // Wrap our Apply Action in an Instruction
968         InstructionBuilder ib = new InstructionBuilder();
969         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
970         ib.setOrder(0);
971         ib.setKey(new InstructionKey(0));
972
973         // Put our Instruction in a list of Instructions
974         InstructionsBuilder isb = new InstructionsBuilder();
975         List<Instruction> instructions = new ArrayList<Instruction>();
976         instructions.add(ib.build());
977         isb.setInstruction(instructions);
978         return isb;
979     }
980
981     private static InstructionsBuilder createOutputInstructions(String outputType, int outputValue) {
982         List<Action> actionList = new ArrayList<Action>();
983         ActionBuilder ab = new ActionBuilder();
984
985         OutputActionBuilder output = new OutputActionBuilder();
986         output.setMaxLength(outputValue);
987         Uri value = new Uri(outputType);
988         output.setOutputNodeConnector(value);
989         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
990         ab.setOrder(0);
991         ab.setKey(new ActionKey(0));
992         actionList.add(ab.build());
993         // Create an Apply Action
994         ApplyActionsBuilder aab = new ApplyActionsBuilder();
995         aab.setAction(actionList);
996
997         // Wrap our Apply Action in an Instruction
998         InstructionBuilder ib = new InstructionBuilder();
999         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1000         ib.setOrder(0);
1001         ib.setKey(new InstructionKey(0));
1002
1003         // Put our Instruction in a list of Instructions
1004         InstructionsBuilder isb = new InstructionsBuilder();
1005         List<Instruction> instructions = new ArrayList<Instruction>();
1006         instructions.add(ib.build());
1007         isb.setInstruction(instructions);
1008         return isb;
1009     }
1010
1011     private static InstructionsBuilder createStripVlanInstructions() {
1012         List<Action> actionList = new ArrayList<Action>();
1013         ActionBuilder ab = new ActionBuilder();
1014
1015         StripVlanActionBuilder stripActionBuilder = new StripVlanActionBuilder();
1016         ab.setAction(new StripVlanActionCaseBuilder().setStripVlanAction(stripActionBuilder.build()).build());
1017         ab.setOrder(0);
1018         ab.setKey(new ActionKey(0));
1019         actionList.add(ab.build());
1020         // Create an Apply Action
1021         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1022         aab.setAction(actionList);
1023
1024         // Wrap our Apply Action in an Instruction
1025         InstructionBuilder ib = new InstructionBuilder();
1026         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1027         ib.setOrder(0);
1028         ib.setKey(new InstructionKey(0));
1029
1030         // Put our Instruction in a list of Instructions
1031         InstructionsBuilder isb = new InstructionsBuilder();
1032         List<Instruction> instructions = new ArrayList<Instruction>();
1033         instructions.add(ib.build());
1034         isb.setInstruction(instructions);
1035         return isb;
1036     }
1037
1038     private static InstructionsBuilder createAppyActionInstruction2() {
1039
1040         List<Action> actionList = new ArrayList<Action>();
1041         ActionBuilder ab = new ActionBuilder();
1042
1043         PushMplsActionBuilder push = new PushMplsActionBuilder();
1044         push.setEthernetType(new Integer(0x8847));
1045         ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
1046         actionList.add(ab.build());
1047         // Create an Apply Action
1048         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1049         aab.setAction(actionList);
1050
1051         // Wrap our Apply Action in an Instruction
1052         InstructionBuilder ib = new InstructionBuilder();
1053         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1054
1055         // Put our Instruction in a list of Instructions
1056         InstructionsBuilder isb = new InstructionsBuilder();
1057         List<Instruction> instructions = new ArrayList<Instruction>();
1058         instructions.add(ib.build());
1059         isb.setInstruction(instructions);
1060         return isb;
1061     }
1062
1063     private static InstructionsBuilder createAppyActionInstruction3() {
1064
1065         List<Action> actionList = new ArrayList<Action>();
1066         ActionBuilder ab = new ActionBuilder();
1067
1068         PushPbbActionBuilder pbb = new PushPbbActionBuilder();
1069         pbb.setEthernetType(new Integer(0x88E7));
1070         ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
1071         actionList.add(ab.build());
1072         // Create an Apply Action
1073         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1074         aab.setAction(actionList);
1075
1076         // Wrap our Apply Action in an Instruction
1077         InstructionBuilder ib = new InstructionBuilder();
1078         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1079
1080         // Put our Instruction in a list of Instructions
1081         InstructionsBuilder isb = new InstructionsBuilder();
1082         List<Instruction> instructions = new ArrayList<Instruction>();
1083         instructions.add(ib.build());
1084         isb.setInstruction(instructions);
1085         return isb;
1086     }
1087
1088     private static InstructionsBuilder createAppyActionInstruction4() {
1089
1090         List<Action> actionList = new ArrayList<Action>();
1091         ActionBuilder ab = new ActionBuilder();
1092
1093         PushVlanActionBuilder vlan = new PushVlanActionBuilder();
1094         vlan.setEthernetType(new Integer(0x8100));
1095         ab.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
1096         actionList.add(ab.build());
1097
1098         // Create an Apply Action
1099         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1100         aab.setAction(actionList);
1101
1102         // Wrap our Apply Action in an Instruction
1103         InstructionBuilder ib = new InstructionBuilder();
1104         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1105
1106         // Put our Instruction in a list of Instructions
1107         InstructionsBuilder isb = new InstructionsBuilder();
1108         List<Instruction> instructions = new ArrayList<Instruction>();
1109         instructions.add(ib.build());
1110         isb.setInstruction(instructions);
1111         return isb;
1112     }
1113
1114     private static InstructionsBuilder createAppyActionInstruction5() {
1115
1116         List<Action> actionList = new ArrayList<Action>();
1117         ActionBuilder ab = new ActionBuilder();
1118
1119         SetDlDstActionBuilder setdl = new SetDlDstActionBuilder();
1120         setdl.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1121         ab.setAction(new SetDlDstActionCaseBuilder().setSetDlDstAction(setdl.build()).build());
1122         actionList.add(ab.build());
1123         // Create an Apply Action
1124         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1125         aab.setAction(actionList);
1126
1127         // Wrap our Apply Action in an Instruction
1128         InstructionBuilder ib = new InstructionBuilder();
1129         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1130
1131         // Put our Instruction in a list of Instructions
1132         InstructionsBuilder isb = new InstructionsBuilder();
1133         List<Instruction> instructions = new ArrayList<Instruction>();
1134         instructions.add(ib.build());
1135         isb.setInstruction(instructions);
1136         return isb;
1137     }
1138
1139     private static InstructionsBuilder createAppyActionInstruction6() {
1140
1141         List<Action> actionList = new ArrayList<Action>();
1142         ActionBuilder ab = new ActionBuilder();
1143
1144         SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
1145         src.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1146         ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(src.build()).build());
1147         actionList.add(ab.build());
1148
1149         // Create an Apply Action
1150         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1151         aab.setAction(actionList);
1152
1153         // Wrap our Apply Action in an Instruction
1154         InstructionBuilder ib = new InstructionBuilder();
1155         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1156
1157         // Put our Instruction in a list of Instructions
1158         InstructionsBuilder isb = new InstructionsBuilder();
1159         List<Instruction> instructions = new ArrayList<Instruction>();
1160         instructions.add(ib.build());
1161         isb.setInstruction(instructions);
1162         return isb;
1163     }
1164
1165     private static InstructionsBuilder createAppyActionInstruction7() {
1166
1167         List<Action> actionList = new ArrayList<Action>();
1168         ActionBuilder ab = new ActionBuilder();
1169
1170         SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
1171         VlanId a = new VlanId(4000);
1172         vl.setVlanId(a);
1173         ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
1174         actionList.add(ab.build());
1175         // Create an Apply Action
1176         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1177         aab.setAction(actionList);
1178
1179         // Wrap our Apply Action in an Instruction
1180         InstructionBuilder ib = new InstructionBuilder();
1181         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1182
1183         // Put our Instruction in a list of Instructions
1184         InstructionsBuilder isb = new InstructionsBuilder();
1185         List<Instruction> instructions = new ArrayList<Instruction>();
1186         instructions.add(ib.build());
1187         isb.setInstruction(instructions);
1188         return isb;
1189     }
1190
1191     private static InstructionsBuilder createAppyActionInstruction8() {
1192
1193         List<Action> actionList = new ArrayList<Action>();
1194         ActionBuilder ab = new ActionBuilder();
1195
1196         SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
1197         VlanPcp pcp1 = new VlanPcp((short) 2);
1198         pcp.setVlanPcp(pcp1);
1199         ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
1200         actionList.add(ab.build());
1201         // Create an Apply Action
1202         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1203         aab.setAction(actionList);
1204
1205         // Wrap our Apply Action in an Instruction
1206         InstructionBuilder ib = new InstructionBuilder();
1207         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1208
1209         // Put our Instruction in a list of Instructions
1210         InstructionsBuilder isb = new InstructionsBuilder();
1211         List<Instruction> instructions = new ArrayList<Instruction>();
1212         instructions.add(ib.build());
1213         isb.setInstruction(instructions);
1214         return isb;
1215     }
1216
1217     private static InstructionsBuilder createAppyActionInstruction88() {
1218
1219         List<Action> actionList = new ArrayList<Action>();
1220         ActionBuilder ab = new ActionBuilder();
1221
1222         SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
1223         VlanPcp pcp1 = new VlanPcp((short) 9);
1224         pcp.setVlanPcp(pcp1);
1225         ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
1226         actionList.add(ab.build());
1227         // Create an Apply Action
1228         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1229         aab.setAction(actionList);
1230
1231         // Wrap our Apply Action in an Instruction
1232         InstructionBuilder ib = new InstructionBuilder();
1233         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1234
1235         // Put our Instruction in a list of Instructions
1236         InstructionsBuilder isb = new InstructionsBuilder();
1237         List<Instruction> instructions = new ArrayList<Instruction>();
1238         instructions.add(ib.build());
1239         isb.setInstruction(instructions);
1240         return isb;
1241     }
1242
1243     private static InstructionsBuilder createAppyActionInstruction9() {
1244
1245         List<Action> actionList = new ArrayList<Action>();
1246         ActionBuilder ab = new ActionBuilder();
1247
1248         CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
1249         ab.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
1250         actionList.add(ab.build());
1251         // Create an Apply Action
1252         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1253         aab.setAction(actionList);
1254
1255         // Wrap our Apply Action in an Instruction
1256         InstructionBuilder ib = new InstructionBuilder();
1257         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1258
1259         // Put our Instruction in a list of Instructions
1260         InstructionsBuilder isb = new InstructionsBuilder();
1261         List<Instruction> instructions = new ArrayList<Instruction>();
1262         instructions.add(ib.build());
1263         isb.setInstruction(instructions);
1264         return isb;
1265     }
1266
1267     private static InstructionsBuilder createAppyActionInstruction10() {
1268
1269         List<Action> actionList = new ArrayList<Action>();
1270         ActionBuilder ab = new ActionBuilder();
1271
1272         CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
1273         ab.setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(ttlout.build()).build());
1274         actionList.add(ab.build());
1275         // Create an Apply Action
1276         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1277         aab.setAction(actionList);
1278
1279         // Wrap our Apply Action in an Instruction
1280         InstructionBuilder ib = new InstructionBuilder();
1281         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1282
1283         // Put our Instruction in a list of Instructions
1284         InstructionsBuilder isb = new InstructionsBuilder();
1285         List<Instruction> instructions = new ArrayList<Instruction>();
1286         instructions.add(ib.build());
1287         isb.setInstruction(instructions);
1288         return isb;
1289     }
1290
1291     private static InstructionsBuilder createAppyActionInstruction11() {
1292
1293         List<Action> actionList = new ArrayList<Action>();
1294         ActionBuilder ab = new ActionBuilder();
1295
1296         DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
1297         ab.setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(mpls.build()).build());
1298         actionList.add(ab.build());
1299         // Create an Apply Action
1300         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1301         aab.setAction(actionList);
1302
1303         // Wrap our Apply Action in an Instruction
1304         InstructionBuilder ib = new InstructionBuilder();
1305         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1306         ib.setKey(new InstructionKey(0));
1307         ib.setOrder(0);
1308
1309         // Put our Instruction in a list of Instruction
1310         InstructionsBuilder isb = new InstructionsBuilder();
1311         List<Instruction> instructions = new ArrayList<Instruction>();
1312         instructions.add(ib.build());
1313         isb.setInstruction(instructions);
1314         return isb;
1315     }
1316
1317     private static InstructionsBuilder createAppyActionInstruction12() {
1318
1319         List<Action> actionList = new ArrayList<Action>();
1320         ActionBuilder ab = new ActionBuilder();
1321
1322         DecNwTtlBuilder nwttl = new DecNwTtlBuilder();
1323         ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(nwttl.build()).build());
1324         actionList.add(ab.build());
1325
1326         // Create an Apply Action
1327         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1328         aab.setAction(actionList);
1329
1330         // Wrap our Apply Action in an Instruction
1331         InstructionBuilder ib = new InstructionBuilder();
1332         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1333
1334         // Put our Instruction in a list of Instructions
1335         InstructionsBuilder isb = new InstructionsBuilder();
1336         List<Instruction> instructions = new ArrayList<Instruction>();
1337         instructions.add(ib.build());
1338         isb.setInstruction(instructions);
1339         return isb;
1340     }
1341
1342     private static InstructionsBuilder createAppyActionInstruction13() {
1343
1344         List<Action> actionList = new ArrayList<Action>();
1345         ActionBuilder ab = new ActionBuilder();
1346
1347         DropActionBuilder drop = new DropActionBuilder();
1348         ab.setAction(new DropActionCaseBuilder().setDropAction(drop.build()).build());
1349         actionList.add(ab.build());
1350
1351         // Create an Apply Action
1352         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1353         aab.setAction(actionList);
1354
1355         // Wrap our Apply Action in an Instruction
1356         InstructionBuilder ib = new InstructionBuilder();
1357         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1358
1359         // Put our Instruction in a list of Instructions
1360         InstructionsBuilder isb = new InstructionsBuilder();
1361         List<Instruction> instructions = new ArrayList<Instruction>();
1362         instructions.add(ib.build());
1363         isb.setInstruction(instructions);
1364         return isb;
1365     }
1366
1367     private static InstructionsBuilder createAppyActionInstruction14() {
1368
1369         List<Action> actionList = new ArrayList<Action>();
1370         ActionBuilder ab = new ActionBuilder();
1371
1372         FloodActionBuilder fld = new FloodActionBuilder();
1373         ab.setAction(new FloodActionCaseBuilder().setFloodAction(fld.build()).build());
1374         actionList.add(ab.build());
1375         // Create an Apply Action
1376         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1377         aab.setAction(actionList);
1378
1379         // Wrap our Apply Action in an Instruction
1380         InstructionBuilder ib = new InstructionBuilder();
1381         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1382
1383         // Put our Instruction in a list of Instructions
1384         InstructionsBuilder isb = new InstructionsBuilder();
1385         List<Instruction> instructions = new ArrayList<Instruction>();
1386         instructions.add(ib.build());
1387         isb.setInstruction(instructions);
1388         return isb;
1389     }
1390
1391     private static InstructionsBuilder createAppyActionInstruction15() {
1392
1393         List<Action> actionList = new ArrayList<Action>();
1394         ActionBuilder ab = new ActionBuilder();
1395
1396         FloodAllActionBuilder fldall = new FloodAllActionBuilder();
1397         ab.setAction(new FloodAllActionCaseBuilder().setFloodAllAction(fldall.build()).build());
1398         actionList.add(ab.build());
1399         // Create an Apply Action
1400         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1401         aab.setAction(actionList);
1402
1403         // Wrap our Apply Action in an Instruction
1404         InstructionBuilder ib = new InstructionBuilder();
1405         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1406
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);
1412         return isb;
1413     }
1414
1415     private static InstructionsBuilder createAppyActionInstruction16() {
1416
1417         List<Action> actionList = new ArrayList<Action>();
1418         ActionBuilder ab = new ActionBuilder();
1419
1420         GroupActionBuilder groupActionB = new GroupActionBuilder();
1421         groupActionB.setGroupId(1L);
1422         groupActionB.setGroup("0");
1423         ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
1424         actionList.add(ab.build());
1425
1426         // Create an Apply Action
1427         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1428         aab.setAction(actionList);
1429
1430         // Wrap our Apply Action in an Instruction
1431         InstructionBuilder ib = new InstructionBuilder();
1432         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1433
1434         // Put our Instruction in a list of Instructions
1435         InstructionsBuilder isb = new InstructionsBuilder();
1436         List<Instruction> instructions = new ArrayList<Instruction>();
1437         instructions.add(ib.build());
1438         isb.setInstruction(instructions);
1439         return isb;
1440     }
1441
1442     private static InstructionsBuilder createAppyActionInstruction17() {
1443
1444         List<Action> actionList = new ArrayList<Action>();
1445         ActionBuilder ab = new ActionBuilder();
1446
1447         HwPathActionBuilder hwPathB = new HwPathActionBuilder();
1448         ab.setAction(new HwPathActionCaseBuilder().setHwPathAction(hwPathB.build()).build());
1449         actionList.add(ab.build());
1450         // Create an Apply Action
1451         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1452         aab.setAction(actionList);
1453
1454         // Wrap our Apply Action in an Instruction
1455         InstructionBuilder ib = new InstructionBuilder();
1456         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1457
1458         // Put our Instruction in a list of Instructions
1459         InstructionsBuilder isb = new InstructionsBuilder();
1460         List<Instruction> instructions = new ArrayList<Instruction>();
1461         instructions.add(ib.build());
1462         isb.setInstruction(instructions);
1463         return isb;
1464     }
1465
1466     private static InstructionsBuilder createAppyActionInstruction18() {
1467
1468         List<Action> actionList = new ArrayList<Action>();
1469         ActionBuilder ab = new ActionBuilder();
1470
1471         LoopbackActionBuilder loopbackActionBuilder = new LoopbackActionBuilder();
1472         ab.setAction(new LoopbackActionCaseBuilder().setLoopbackAction(loopbackActionBuilder.build()).build());
1473         actionList.add(ab.build());
1474
1475         // Create an Apply Action
1476         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1477         aab.setAction(actionList);
1478
1479         // Wrap our Apply Action in an Instruction
1480         InstructionBuilder ib = new InstructionBuilder();
1481         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1482
1483         // Put our Instruction in a list of Instructions
1484         InstructionsBuilder isb = new InstructionsBuilder();
1485         List<Instruction> instructions = new ArrayList<Instruction>();
1486         instructions.add(ib.build());
1487         isb.setInstruction(instructions);
1488         return isb;
1489     }
1490
1491     private static InstructionsBuilder createAppyActionInstruction19() {
1492
1493         List<Action> actionList = new ArrayList<Action>();
1494         ActionBuilder ab = new ActionBuilder();
1495
1496         PopMplsActionBuilder popMplsActionBuilder = new PopMplsActionBuilder();
1497         popMplsActionBuilder.setEthernetType(0XB);
1498         ab.setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsActionBuilder.build()).build());
1499         actionList.add(ab.build());
1500         // Create an Apply Action
1501         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1502         aab.setAction(actionList);
1503
1504         // Wrap our Apply Action in an Instruction
1505         InstructionBuilder ib = new InstructionBuilder();
1506         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1507
1508         // Put our Instruction in a list of Instructions
1509         InstructionsBuilder isb = new InstructionsBuilder();
1510         List<Instruction> instructions = new ArrayList<Instruction>();
1511         instructions.add(ib.build());
1512         isb.setInstruction(instructions);
1513         return isb;
1514     }
1515
1516     private static InstructionsBuilder createAppyActionInstruction20() {
1517
1518         List<Action> actionList = new ArrayList<Action>();
1519         ActionBuilder ab = new ActionBuilder();
1520
1521         PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
1522         ab.setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPbbActionBuilder.build()).build());
1523         actionList.add(ab.build());
1524         // Create an Apply Action
1525         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1526         aab.setAction(actionList);
1527
1528         // Wrap our Apply Action in an Instruction
1529         InstructionBuilder ib = new InstructionBuilder();
1530         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1531
1532         // Put our Instruction in a list of Instructions
1533         InstructionsBuilder isb = new InstructionsBuilder();
1534         List<Instruction> instructions = new ArrayList<Instruction>();
1535         instructions.add(ib.build());
1536         isb.setInstruction(instructions);
1537         return isb;
1538     }
1539
1540     private static InstructionsBuilder createAppyActionInstruction21() {
1541
1542         List<Action> actionList = new ArrayList<Action>();
1543         ActionBuilder ab = new ActionBuilder();
1544
1545         PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
1546         ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
1547         actionList.add(ab.build());
1548
1549         // Create an Apply Action
1550         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1551         aab.setAction(actionList);
1552
1553         // Wrap our Apply Action in an Instruction
1554         InstructionBuilder ib = new InstructionBuilder();
1555         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1556
1557         // Put our Instruction in a list of Instructions
1558         InstructionsBuilder isb = new InstructionsBuilder();
1559         List<Instruction> instructions = new ArrayList<Instruction>();
1560         instructions.add(ib.build());
1561         isb.setInstruction(instructions);
1562         return isb;
1563     }
1564
1565     private static InstructionsBuilder createAppyActionInstruction22() {
1566
1567         List<Action> actionList = new ArrayList<Action>();
1568         ActionBuilder ab = new ActionBuilder();
1569
1570         SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
1571         setDlTypeActionBuilder.setDlType(new EtherType(8L));
1572         ab.setAction(new SetDlTypeActionCaseBuilder().setSetDlTypeAction(setDlTypeActionBuilder.build()).build());
1573         actionList.add(ab.build());
1574
1575         // Create an Apply Action
1576         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1577         aab.setAction(actionList);
1578
1579         // Wrap our Apply Action in an Instruction
1580         InstructionBuilder ib = new InstructionBuilder();
1581         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1582
1583         // Put our Instruction in a list of Instructions
1584         InstructionsBuilder isb = new InstructionsBuilder();
1585         List<Instruction> instructions = new ArrayList<Instruction>();
1586         instructions.add(ib.build());
1587         isb.setInstruction(instructions);
1588         return isb;
1589     }
1590
1591     private static InstructionsBuilder createAppyActionInstruction23(NodeId nodeId) {
1592
1593         List<Action> actionList = new ArrayList<Action>();
1594         ActionBuilder ab = new ActionBuilder();
1595
1596         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1597         setFieldBuilder.setInPort(new NodeConnectorId(nodeId + ":2"));
1598         actionList.add(ab.build());
1599
1600         // Create an Apply Action
1601         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1602         aab.setAction(actionList);
1603
1604         // Wrap our Apply Action in an Instruction
1605         InstructionBuilder ib = new InstructionBuilder();
1606         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1607
1608         // Put our Instruction in a list of Instructions
1609         InstructionsBuilder isb = new InstructionsBuilder();
1610         List<Instruction> instructions = new ArrayList<Instruction>();
1611         instructions.add(ib.build());
1612         isb.setInstruction(instructions);
1613         return isb;
1614     }
1615
1616     private static InstructionsBuilder createAppyActionInstruction24() {
1617
1618         List<Action> actionList = new ArrayList<Action>();
1619         ActionBuilder ab = new ActionBuilder();
1620
1621         SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
1622         setMplsTtlActionBuilder.setMplsTtl((short) 0X1);
1623         ab.setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMplsTtlActionBuilder.build()).build());
1624         actionList.add(ab.build());
1625
1626         // Create an Apply Action
1627         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1628         aab.setAction(actionList);
1629
1630         // Wrap our Apply Action in an Instruction
1631         InstructionBuilder ib = new InstructionBuilder();
1632         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1633
1634         // Put our Instruction in a list of Instructions
1635         InstructionsBuilder isb = new InstructionsBuilder();
1636         List<Instruction> instructions = new ArrayList<Instruction>();
1637         instructions.add(ib.build());
1638         isb.setInstruction(instructions);
1639         return isb;
1640     }
1641
1642     private static InstructionsBuilder createAppyActionInstruction25() {
1643
1644         List<Action> actionList = new ArrayList<Action>();
1645         ActionBuilder ab = new ActionBuilder();
1646
1647         SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
1648         Ipv4Builder ipnext = new Ipv4Builder();
1649         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
1650         ipnext.setIpv4Address(prefix);
1651         setNextHopActionBuilder.setAddress(ipnext.build());
1652         ab.setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilder.build()).build());
1653         actionList.add(ab.build());
1654
1655         // Create an Apply Action
1656         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1657         aab.setAction(actionList);
1658
1659         // Wrap our Apply Action in an Instruction
1660         InstructionBuilder ib = new InstructionBuilder();
1661         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1662
1663         // Put our Instruction in a list of Instructions
1664         InstructionsBuilder isb = new InstructionsBuilder();
1665         List<Instruction> instructions = new ArrayList<Instruction>();
1666         instructions.add(ib.build());
1667         isb.setInstruction(instructions);
1668         return isb;
1669     }
1670
1671     private static InstructionsBuilder createAppyActionInstruction26() {
1672
1673         List<Action> actionList = new ArrayList<Action>();
1674         ActionBuilder ab = new ActionBuilder();
1675
1676         SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
1677         Ipv4Builder ipdst = new Ipv4Builder();
1678         Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
1679         ipdst.setIpv4Address(prefixdst);
1680         setNwDstActionBuilder.setAddress(ipdst.build());
1681         ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
1682         actionList.add(ab.build());
1683
1684         // Create an Apply Action
1685         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1686         aab.setAction(actionList);
1687
1688         // Wrap our Apply Action in an Instruction
1689         InstructionBuilder ib = new InstructionBuilder();
1690         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1691
1692         // Put our Instruction in a list of Instructions
1693         InstructionsBuilder isb = new InstructionsBuilder();
1694         List<Instruction> instructions = new ArrayList<Instruction>();
1695         instructions.add(ib.build());
1696         isb.setInstruction(instructions);
1697         return isb;
1698     }
1699
1700     private static InstructionsBuilder createAppyActionInstruction27() {
1701
1702         List<Action> actionList = new ArrayList<Action>();
1703         ActionBuilder ab = new ActionBuilder();
1704
1705         SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
1706         Ipv4Builder ipsrc = new Ipv4Builder();
1707         Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
1708         ipsrc.setIpv4Address(prefixsrc);
1709         setNwsrcActionBuilder.setAddress(ipsrc.build());
1710         ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
1711         actionList.add(ab.build());
1712
1713         // Create an Apply Action
1714         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1715         aab.setAction(actionList);
1716
1717         // Wrap our Apply Action in an Instruction
1718         InstructionBuilder ib = new InstructionBuilder();
1719         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1720
1721         // Put our Instruction in a list of Instructions
1722         InstructionsBuilder isb = new InstructionsBuilder();
1723         List<Instruction> instructions = new ArrayList<Instruction>();
1724         instructions.add(ib.build());
1725         isb.setInstruction(instructions);
1726         return isb;
1727     }
1728
1729     private static InstructionsBuilder createAppyActionInstruction28() {
1730
1731         List<Action> actionList = new ArrayList<Action>();
1732         ActionBuilder ab = new ActionBuilder();
1733
1734         SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
1735         setNwTosActionBuilder.setTos(8);
1736         ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.build()).build());
1737         actionList.add(ab.build());
1738         // Create an Apply Action
1739         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1740         aab.setAction(actionList);
1741
1742         // Wrap our Apply Action in an Instruction
1743         InstructionBuilder ib = new InstructionBuilder();
1744         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1745
1746         // Put our Instruction in a list of Instructions
1747         InstructionsBuilder isb = new InstructionsBuilder();
1748         List<Instruction> instructions = new ArrayList<Instruction>();
1749         instructions.add(ib.build());
1750         isb.setInstruction(instructions);
1751         return isb;
1752     }
1753
1754     private static InstructionsBuilder createAppyActionInstruction29() {
1755
1756         List<Action> actionList = new ArrayList<Action>();
1757         ActionBuilder ab = new ActionBuilder();
1758
1759         SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
1760         setNwTtlActionBuilder.setNwTtl((short) 1);
1761         ab.setAction(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
1762         actionList.add(ab.build());
1763
1764         // Create an Apply Action
1765         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1766         aab.setAction(actionList);
1767
1768         // Wrap our Apply Action in an Instruction
1769         InstructionBuilder ib = new InstructionBuilder();
1770         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1771
1772         // Put our Instruction in a list of Instructions
1773         InstructionsBuilder isb = new InstructionsBuilder();
1774         List<Instruction> instructions = new ArrayList<Instruction>();
1775         instructions.add(ib.build());
1776         isb.setInstruction(instructions);
1777         return isb;
1778     }
1779
1780     private static InstructionsBuilder createAppyActionInstruction30() {
1781
1782         List<Action> actionList = new ArrayList<Action>();
1783         ActionBuilder ab = new ActionBuilder();
1784
1785         SetQueueActionBuilder setQueueActionBuilder = new SetQueueActionBuilder();
1786         setQueueActionBuilder.setQueueId(1L);
1787         ab.setAction(new SetQueueActionCaseBuilder().setSetQueueAction(setQueueActionBuilder.build()).build());
1788         actionList.add(ab.build());
1789         // Create an Apply Action
1790         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1791         aab.setAction(actionList);
1792
1793         // Wrap our Apply Action in an Instruction
1794         InstructionBuilder ib = new InstructionBuilder();
1795         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1796
1797         // Put our Instruction in a list of Instructions
1798         InstructionsBuilder isb = new InstructionsBuilder();
1799         List<Instruction> instructions = new ArrayList<Instruction>();
1800         instructions.add(ib.build());
1801         isb.setInstruction(instructions);
1802         return isb;
1803     }
1804
1805     private static InstructionsBuilder createAppyActionInstruction31() {
1806
1807         List<Action> actionList = new ArrayList<Action>();
1808         ActionBuilder ab = new ActionBuilder();
1809
1810         SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
1811         setTpDstActionBuilder.setPort(new PortNumber(109));
1812
1813         ab.setAction(new SetTpDstActionCaseBuilder().setSetTpDstAction(setTpDstActionBuilder.build()).build());
1814         actionList.add(ab.build());
1815         // Create an Apply Action
1816         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1817         aab.setAction(actionList);
1818
1819         // Wrap our Apply Action in an Instruction
1820         InstructionBuilder ib = new InstructionBuilder();
1821         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1822
1823         // Put our Instruction in a list of Instructions
1824         InstructionsBuilder isb = new InstructionsBuilder();
1825         List<Instruction> instructions = new ArrayList<Instruction>();
1826         instructions.add(ib.build());
1827         isb.setInstruction(instructions);
1828         return isb;
1829     }
1830
1831     private static InstructionsBuilder createAppyActionInstruction32() {
1832
1833         List<Action> actionList = new ArrayList<Action>();
1834         ActionBuilder ab = new ActionBuilder();
1835
1836         SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
1837         setTpSrcActionBuilder.setPort(new PortNumber(109));
1838         ab.setAction(new SetTpSrcActionCaseBuilder().setSetTpSrcAction(setTpSrcActionBuilder.build()).build());
1839         actionList.add(ab.build());
1840
1841         // Create an Apply Action
1842         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1843         aab.setAction(actionList);
1844
1845         // Wrap our Apply Action in an Instruction
1846         InstructionBuilder ib = new InstructionBuilder();
1847         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1848
1849         // Put our Instruction in a list of Instructions
1850         InstructionsBuilder isb = new InstructionsBuilder();
1851         List<Instruction> instructions = new ArrayList<Instruction>();
1852         instructions.add(ib.build());
1853         isb.setInstruction(instructions);
1854         return isb;
1855     }
1856
1857     private static InstructionsBuilder createAppyActionInstruction33() {
1858
1859         List<Action> actionList = new ArrayList<Action>();
1860         ActionBuilder ab = new ActionBuilder();
1861
1862         SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
1863         setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(2));
1864         ab.setAction(new SetVlanCfiActionCaseBuilder().setSetVlanCfiAction(setVlanCfiActionBuilder.build()).build());
1865         actionList.add(ab.build());
1866
1867         // Create an Apply Action
1868         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1869         aab.setAction(actionList);
1870
1871         // Wrap our Apply Action in an Instruction
1872         InstructionBuilder ib = new InstructionBuilder();
1873         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1874
1875         // Put our Instruction in a list of Instructions
1876         InstructionsBuilder isb = new InstructionsBuilder();
1877         List<Instruction> instructions = new ArrayList<Instruction>();
1878         instructions.add(ib.build());
1879         isb.setInstruction(instructions);
1880         return isb;
1881     }
1882
1883     private static InstructionsBuilder createAppyActionInstruction34() {
1884
1885         List<Action> actionList = new ArrayList<Action>();
1886         ActionBuilder ab = new ActionBuilder();
1887
1888         SwPathActionBuilder swPathAction = new SwPathActionBuilder();
1889         ab.setAction(new SwPathActionCaseBuilder().setSwPathAction(swPathAction.build()).build());
1890         actionList.add(ab.build());
1891
1892         // Create an Apply Action
1893         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1894         aab.setAction(actionList);
1895
1896         // Wrap our Apply Action in an Instruction
1897         InstructionBuilder ib = new InstructionBuilder();
1898         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1899
1900         // Put our Instruction in a list of Instructions
1901         InstructionsBuilder isb = new InstructionsBuilder();
1902         List<Instruction> instructions = new ArrayList<Instruction>();
1903         instructions.add(ib.build());
1904         isb.setInstruction(instructions);
1905         return isb;
1906     }
1907
1908     private static InstructionsBuilder createAppyActionInstruction35() {
1909
1910         List<Action> actionList = new ArrayList<Action>();
1911         ActionBuilder ab = new ActionBuilder();
1912         ActionBuilder ab1 = new ActionBuilder();
1913         ActionBuilder ab2 = new ActionBuilder();
1914
1915         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1916         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1917         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
1918
1919         // Ethernet
1920         EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
1921         EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
1922         ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
1923         EthernetMatchBuilder ethernetMatch1 = new EthernetMatchBuilder();
1924         EthernetDestinationBuilder ethDestBuilder = new EthernetDestinationBuilder();
1925         ethDestBuilder.setAddress(new MacAddress("00:00:00:00:00:02"));
1926         EthernetMatchBuilder ethernetMatch2 = new EthernetMatchBuilder();
1927         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1928         ethTypeBuilder.setType(new EtherType(0x86ddL));
1929
1930         ethernetMatch.setEthernetSource(ethSourceBuilder.build());
1931         ethernetMatch1.setEthernetDestination(ethDestBuilder.build());
1932         ethernetMatch2.setEthernetType(ethTypeBuilder.build());
1933         setFieldBuilder.setEthernetMatch(ethernetMatch.build());
1934         setFieldBuilder1.setEthernetMatch(ethernetMatch1.build());
1935         setFieldBuilder2.setEthernetMatch(ethernetMatch2.build());
1936         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1937         ab.setKey(new ActionKey(0));
1938         actionList.add(ab.build());
1939
1940         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1941         ab1.setKey(new ActionKey(1));
1942         actionList.add(ab1.build());
1943
1944         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
1945         ab2.setKey(new ActionKey(2));
1946         actionList.add(ab2.build());
1947
1948         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1949         aab.setAction(actionList);
1950
1951         InstructionBuilder ib = new InstructionBuilder();
1952         ib.setKey(new InstructionKey(0));
1953         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1954
1955         // Put our Instruction in a list of Instructions
1956         InstructionsBuilder isb = new InstructionsBuilder();
1957         List<Instruction> instructions = new ArrayList<Instruction>();
1958         instructions.add(ib.build());
1959         isb.setInstruction(instructions);
1960         return isb;
1961     }
1962
1963     private static InstructionsBuilder createAppyActionInstruction36() {
1964
1965         List<Action> actionList = new ArrayList<Action>();
1966         ActionBuilder ab = new ActionBuilder();
1967         ActionBuilder ab1 = new ActionBuilder();
1968
1969         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1970         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1971
1972         // Vlan
1973         VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
1974         VlanMatchBuilder vlanBuilder1 = new VlanMatchBuilder();
1975         VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
1976         VlanId vlanId = new VlanId(10);
1977         VlanPcp vpcp = new VlanPcp((short) 3);
1978         vlanBuilder.setVlanPcp(vpcp);
1979         vlanBuilder1.setVlanId(vlanIdBuilder.setVlanId(vlanId).setVlanIdPresent(true).build());
1980         setFieldBuilder.setVlanMatch(vlanBuilder.build());
1981         setFieldBuilder1.setVlanMatch(vlanBuilder1.build());
1982         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1983         ab.setKey(new ActionKey(0));
1984         actionList.add(ab.build());
1985         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1986         ab1.setKey(new ActionKey(1));
1987         actionList.add(ab1.build());
1988
1989         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1990         aab.setAction(actionList);
1991
1992         InstructionBuilder ib = new InstructionBuilder();
1993         ib.setKey(new InstructionKey(0));
1994         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1995
1996         // Put our Instruction in a list of Instructions
1997         InstructionsBuilder isb = new InstructionsBuilder();
1998         List<Instruction> instructions = new ArrayList<Instruction>();
1999         instructions.add(ib.build());
2000         isb.setInstruction(instructions);
2001         return isb;
2002     }
2003
2004     private static InstructionsBuilder createAppyActionInstruction37() {
2005
2006         List<Action> actionList = new ArrayList<Action>();
2007         ActionBuilder ab = new ActionBuilder();
2008         ActionBuilder ab1 = new ActionBuilder();
2009         ActionBuilder ab2 = new ActionBuilder();
2010
2011         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2012         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2013         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2014         // Ip
2015         IpMatchBuilder ipmatch = new IpMatchBuilder();
2016         IpMatchBuilder ipmatch1 = new IpMatchBuilder();
2017         IpMatchBuilder ipmatch2 = new IpMatchBuilder();
2018         Dscp dscp = new Dscp((short) 3);
2019         ipmatch.setIpDscp(dscp);
2020         ipmatch1.setIpEcn((short) 2);
2021         ipmatch2.setIpProtocol((short) 120);
2022         setFieldBuilder.setIpMatch(ipmatch.build());
2023         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2024         ab.setKey(new ActionKey(0));
2025         actionList.add(ab.build());
2026
2027         setFieldBuilder1.setIpMatch(ipmatch1.build());
2028         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2029         ab1.setKey(new ActionKey(1));
2030         actionList.add(ab1.build());
2031
2032         setFieldBuilder2.setIpMatch(ipmatch2.build());
2033         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2034         ab2.setKey(new ActionKey(2));
2035         actionList.add(ab2.build());
2036
2037         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2038         aab.setAction(actionList);
2039
2040         InstructionBuilder ib = new InstructionBuilder();
2041         ib.setKey(new InstructionKey(0));
2042         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2043
2044         // Put our Instruction in a list of Instructions
2045         InstructionsBuilder isb = new InstructionsBuilder();
2046         List<Instruction> instructions = new ArrayList<Instruction>();
2047         instructions.add(ib.build());
2048         isb.setInstruction(instructions);
2049         return isb;
2050     }
2051
2052     private static InstructionsBuilder createAppyActionInstruction38() {
2053
2054         List<Action> actionList = new ArrayList<Action>();
2055         ActionBuilder ab = new ActionBuilder();
2056         ActionBuilder ab1 = new ActionBuilder();
2057
2058         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2059         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2060         // IPv4
2061         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2062         Ipv4MatchBuilder ipv4Match1 = new Ipv4MatchBuilder();
2063         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.5210");
2064         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1");
2065         ipv4Match1.setIpv4Destination(dstip);
2066         ipv4Match.setIpv4Source(srcip);
2067         setFieldBuilder.setLayer3Match(ipv4Match.build());
2068         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2069         ab.setKey(new ActionKey(0));
2070         actionList.add(ab.build());
2071
2072         setFieldBuilder1.setLayer3Match(ipv4Match1.build());
2073         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2074         ab1.setKey(new ActionKey(1));
2075         actionList.add(ab1.build());
2076
2077         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2078         aab.setAction(actionList);
2079
2080         InstructionBuilder ib = new InstructionBuilder();
2081         ib.setKey(new InstructionKey(0));
2082         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2083
2084         // Put our Instruction in a list of Instructions
2085         InstructionsBuilder isb = new InstructionsBuilder();
2086         List<Instruction> instructions = new ArrayList<Instruction>();
2087         instructions.add(ib.build());
2088         isb.setInstruction(instructions);
2089         return isb;
2090     }
2091
2092     private static InstructionsBuilder createAppyActionInstruction39() {
2093
2094         List<Action> actionList = new ArrayList<Action>();
2095         ActionBuilder ab = new ActionBuilder();
2096         ActionBuilder ab1 = new ActionBuilder();
2097
2098         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2099         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2100
2101         // Tcp
2102         PortNumber tcpsrcport = new PortNumber(1213);
2103         PortNumber tcpdstport = new PortNumber(646);
2104         TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
2105         TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder();
2106         tcpmatch.setTcpSourcePort(tcpsrcport);
2107         tcpmatch1.setTcpDestinationPort(tcpdstport);
2108         setFieldBuilder.setLayer4Match(tcpmatch.build());
2109         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2110         ab.setKey(new ActionKey(0));
2111         actionList.add(ab.build());
2112
2113         setFieldBuilder1.setLayer4Match(tcpmatch1.build());
2114         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2115         ab1.setKey(new ActionKey(1));
2116         actionList.add(ab.build());
2117
2118         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2119         aab.setAction(actionList);
2120
2121         InstructionBuilder ib = new InstructionBuilder();
2122         ib.setKey(new InstructionKey(0));
2123         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2124
2125         // Put our Instruction in a list of Instructions
2126         InstructionsBuilder isb = new InstructionsBuilder();
2127         List<Instruction> instructions = new ArrayList<Instruction>();
2128         instructions.add(ib.build());
2129         isb.setInstruction(instructions);
2130         return isb;
2131     }
2132
2133     private static InstructionsBuilder createAppyActionInstruction40() {
2134
2135         List<Action> actionList = new ArrayList<Action>();
2136         ActionBuilder ab = new ActionBuilder();
2137         ActionBuilder ab1 = new ActionBuilder();
2138
2139         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2140         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2141
2142         // Udp
2143         PortNumber udpsrcport = new PortNumber(1325);
2144         PortNumber udpdstport = new PortNumber(42);
2145         UdpMatchBuilder udpmatch = new UdpMatchBuilder();
2146         UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
2147         udpmatch.setUdpDestinationPort(udpdstport);
2148         udpmatch1.setUdpSourcePort(udpsrcport);
2149         setFieldBuilder.setLayer4Match(udpmatch.build());
2150         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2151         ab.setKey(new ActionKey(0));
2152         actionList.add(ab.build());
2153
2154         setFieldBuilder1.setLayer4Match(udpmatch1.build());
2155         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2156         ab1.setKey(new ActionKey(1));
2157         actionList.add(ab1.build());
2158
2159         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2160         aab.setAction(actionList);
2161
2162         InstructionBuilder ib = new InstructionBuilder();
2163         ib.setKey(new InstructionKey(0));
2164         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2165
2166         // Put our Instruction in a list of Instructions
2167         InstructionsBuilder isb = new InstructionsBuilder();
2168         List<Instruction> instructions = new ArrayList<Instruction>();
2169         instructions.add(ib.build());
2170         isb.setInstruction(instructions);
2171         return isb;
2172     }
2173
2174     private static InstructionsBuilder createAppyActionInstruction41() {
2175
2176         List<Action> actionList = new ArrayList<Action>();
2177         ActionBuilder ab = new ActionBuilder();
2178         ActionBuilder ab1 = new ActionBuilder();
2179
2180         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2181         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2182
2183         // Sctp
2184         SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
2185         SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
2186         PortNumber srcport = new PortNumber(1435);
2187         PortNumber dstport = new PortNumber(22);
2188         sctpmatch.setSctpSourcePort(srcport);
2189         sctpmatch1.setSctpDestinationPort(dstport);
2190         setFieldBuilder.setLayer4Match(sctpmatch.build());
2191         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2192         ab.setKey(new ActionKey(0));
2193         actionList.add(ab.build());
2194
2195         setFieldBuilder1.setLayer4Match(sctpmatch1.build());
2196         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2197         ab1.setKey(new ActionKey(1));
2198         actionList.add(ab1.build());
2199
2200         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2201         aab.setAction(actionList);
2202
2203         InstructionBuilder ib = new InstructionBuilder();
2204         ib.setKey(new InstructionKey(0));
2205         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2206
2207         // Put our Instruction in a list of Instructions
2208         InstructionsBuilder isb = new InstructionsBuilder();
2209         List<Instruction> instructions = new ArrayList<Instruction>();
2210         instructions.add(ib.build());
2211         isb.setInstruction(instructions);
2212         return isb;
2213     }
2214
2215     private static InstructionsBuilder createAppyActionInstruction42() {
2216
2217         List<Action> actionList = new ArrayList<Action>();
2218         ActionBuilder ab = new ActionBuilder();
2219         ActionBuilder ab1 = new ActionBuilder();
2220         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2221         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2222
2223         // Icmpv4
2224         Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
2225         Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
2226         icmpv4match.setIcmpv4Type((short) 8);
2227         icmpv4match1.setIcmpv4Code((short) 0);
2228         setFieldBuilder.setIcmpv4Match(icmpv4match.build());
2229         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2230         ab.setKey(new ActionKey(0));
2231         actionList.add(ab.build());
2232
2233         setFieldBuilder1.setIcmpv4Match(icmpv4match1.build());
2234         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2235         ab1.setKey(new ActionKey(1));
2236         actionList.add(ab1.build());
2237
2238         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2239         aab.setAction(actionList);
2240
2241         InstructionBuilder ib = new InstructionBuilder();
2242         ib.setKey(new InstructionKey(0));
2243         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2244
2245         // Put our Instruction in a list of Instructions
2246         InstructionsBuilder isb = new InstructionsBuilder();
2247         List<Instruction> instructions = new ArrayList<Instruction>();
2248         instructions.add(ib.build());
2249         isb.setInstruction(instructions);
2250         return isb;
2251     }
2252
2253     private static InstructionsBuilder createAppyActionInstruction43() {
2254
2255         List<Action> actionList = new ArrayList<Action>();
2256         ActionBuilder ab = new ActionBuilder();
2257         ActionBuilder ab1 = new ActionBuilder();
2258         ActionBuilder ab2 = new ActionBuilder();
2259         ActionBuilder ab3 = new ActionBuilder();
2260         ActionBuilder ab4 = new ActionBuilder();
2261
2262         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2263         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2264         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2265         SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
2266         SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
2267
2268         // setting the values of ARP
2269         MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2270         MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2271         Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52");
2272         Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1");
2273         // create ARP match action
2274         ArpMatchBuilder arpmatch = new ArpMatchBuilder();
2275         ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
2276         ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
2277         ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
2278         ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
2279         ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2280         arpsrc.setAddress(macsrc);
2281         ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2282         arpdst.setAddress(macdest);
2283         arpmatch.setArpOp(2);
2284         arpmatch1.setArpSourceHardwareAddress(arpsrc.build());
2285         arpmatch2.setArpTargetHardwareAddress(arpdst.build());
2286         arpmatch3.setArpSourceTransportAddress(srciparp);
2287         arpmatch4.setArpTargetTransportAddress(dstiparp);
2288         setFieldBuilder.setLayer3Match(arpmatch.build());
2289         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2290         ab.setKey(new ActionKey(0));
2291         actionList.add(ab.build());
2292
2293         setFieldBuilder1.setLayer3Match(arpmatch1.build());
2294         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2295         ab1.setKey(new ActionKey(1));
2296         actionList.add(ab1.build());
2297
2298         setFieldBuilder2.setLayer3Match(arpmatch2.build());
2299         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2300         ab2.setKey(new ActionKey(2));
2301         actionList.add(ab2.build());
2302
2303         setFieldBuilder3.setLayer3Match(arpmatch3.build());
2304         ab3.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
2305         ab3.setKey(new ActionKey(3));
2306         actionList.add(ab3.build());
2307
2308         setFieldBuilder4.setLayer3Match(arpmatch4.build());
2309         ab4.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
2310         ab4.setKey(new ActionKey(4));
2311         actionList.add(ab4.build());
2312
2313         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2314         aab.setAction(actionList);
2315
2316         InstructionBuilder ib = new InstructionBuilder();
2317         ib.setKey(new InstructionKey(0));
2318         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2319
2320         // Put our Instruction in a list of Instructions
2321         InstructionsBuilder isb = new InstructionsBuilder();
2322         List<Instruction> instructions = new ArrayList<Instruction>();
2323         instructions.add(ib.build());
2324         isb.setInstruction(instructions);
2325         return isb;
2326     }
2327
2328     private static InstructionsBuilder createAppyActionInstruction44() {
2329
2330         List<Action> actionLists = new ArrayList<Action>();
2331         ActionBuilder ab = new ActionBuilder();
2332         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2333         ActionBuilder ab1 = new ActionBuilder();
2334         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2335         /*
2336          * ActionBuilder ab2 = new ActionBuilder(); SetFieldBuilder
2337          * setFieldBuilder2 = new SetFieldBuilder(); ActionBuilder ab3 = new
2338          * ActionBuilder(); SetFieldBuilder setFieldBuilder3 = new
2339          * SetFieldBuilder(); ActionBuilder ab4 = new ActionBuilder();
2340          * SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
2341          */
2342         ActionBuilder ab5 = new ActionBuilder();
2343         SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
2344         ActionBuilder ab6 = new ActionBuilder();
2345         SetFieldBuilder setFieldBuilder6 = new SetFieldBuilder();
2346
2347         // IPv6
2348         Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
2349         Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
2350         // Ipv6MatchBuilder ipv6Builder2 = new Ipv6MatchBuilder();
2351         // Ipv6MatchBuilder ipv6Builder3 = new Ipv6MatchBuilder();
2352         // Ipv6MatchBuilder ipv6Builder4 = new Ipv6MatchBuilder();
2353         Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
2354         Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
2355
2356         Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2");
2357         Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1");
2358         // Ipv6Address ndtarget = new
2359         // Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
2360         // MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
2361         // MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
2362         Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
2363         nextheader.setIpv6Exthdr(58);
2364         Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2365         Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
2366         ipv6label.setIpv6Flabel(label);
2367
2368         ipv6Builder.setIpv6Source(srcip6);
2369         ipv6Builder1.setIpv6Destination(dstip6);
2370         // ipv6Builder2.setIpv6NdTarget(ndtarget);
2371         // ipv6Builder3.setIpv6NdSll(ndsll);
2372         // ipv6Builder4.setIpv6NdTll(ndtll);
2373         ipv6Builder5.setIpv6ExtHeader(nextheader.build());
2374         ipv6Builder6.setIpv6Label(ipv6label.build());
2375
2376         setFieldBuilder.setLayer3Match(ipv6Builder.build());
2377         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2378         ab.setKey(new ActionKey(0));
2379         actionLists.add(ab.build());
2380
2381         setFieldBuilder1.setLayer3Match(ipv6Builder1.build());
2382         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2383         ab1.setKey(new ActionKey(1));
2384         actionLists.add(ab1.build());
2385
2386         /*
2387          * setFieldBuilder2.setLayer3Match(ipv6Builder2.build());
2388          * ab2.setAction(new
2389          * SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2390          * ab2.setKey(new ActionKey(2)); actionLists.add(ab2.build());
2391          *
2392          * setFieldBuilder3.setLayer3Match(ipv6Builder3.build());
2393          * ab3.setAction(new
2394          * SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
2395          * ab3.setKey(new ActionKey(3)); actionLists.add(ab3.build());
2396          *
2397          * setFieldBuilder4.setLayer3Match(ipv6Builder4.build());
2398          * ab4.setAction(new
2399          * SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
2400          * ab4.setKey(new ActionKey(4)); actionLists.add(ab4.build());
2401          */
2402         setFieldBuilder5.setLayer3Match(ipv6Builder5.build());
2403         ab5.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder5.build()).build());
2404         ab5.setKey(new ActionKey(5));
2405         actionLists.add(ab5.build());
2406
2407         setFieldBuilder6.setLayer3Match(ipv6Builder6.build());
2408         ab6.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder6.build()).build());
2409         ab6.setKey(new ActionKey(6));
2410         actionLists.add(ab6.build());
2411
2412         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2413         aab.setAction(actionLists);
2414
2415         InstructionBuilder ib = new InstructionBuilder();
2416         ib.setKey(new InstructionKey(0));
2417         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2418
2419         // Put our Instruction in a list of Instructions
2420         InstructionsBuilder isb = new InstructionsBuilder();
2421         List<Instruction> instructions = new ArrayList<Instruction>();
2422         instructions.add(ib.build());
2423         isb.setInstruction(instructions);
2424         return isb;
2425     }
2426
2427     private static InstructionsBuilder createAppyActionInstruction45() {
2428
2429         List<Action> actionList = new ArrayList<Action>();
2430         ActionBuilder ab = new ActionBuilder();
2431         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2432         ActionBuilder ab1 = new ActionBuilder();
2433         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2434
2435         // Icmpv6
2436         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
2437         Icmpv6MatchBuilder icmpv6match1 = new Icmpv6MatchBuilder();
2438         icmpv6match.setIcmpv6Type((short) 135);
2439         icmpv6match1.setIcmpv6Code((short) 0);
2440         setFieldBuilder.setIcmpv6Match(icmpv6match.build());
2441         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2442         ab.setKey(new ActionKey(0));
2443         actionList.add(ab.build());
2444
2445         setFieldBuilder1.setIcmpv6Match(icmpv6match1.build());
2446         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2447         ab1.setKey(new ActionKey(1));
2448         actionList.add(ab1.build());
2449
2450         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2451         aab.setAction(actionList);
2452
2453         InstructionBuilder ib = new InstructionBuilder();
2454         ib.setKey(new InstructionKey(0));
2455         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2456
2457         // Put our Instruction in a list of Instructions
2458         InstructionsBuilder isb = new InstructionsBuilder();
2459         List<Instruction> instructions = new ArrayList<Instruction>();
2460         instructions.add(ib.build());
2461         isb.setInstruction(instructions);
2462         return isb;
2463     }
2464
2465     private static InstructionsBuilder createAppyActionInstruction46() {
2466
2467         List<Action> actionList = new ArrayList<Action>();
2468         ActionBuilder ab = new ActionBuilder();
2469         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2470         ActionBuilder ab1 = new ActionBuilder();
2471         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2472         ActionBuilder ab2 = new ActionBuilder();
2473         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2474
2475         // MPLS
2476         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2477         ProtocolMatchFieldsBuilder protomatch1 = new ProtocolMatchFieldsBuilder();
2478         ProtocolMatchFieldsBuilder protomatch2 = new ProtocolMatchFieldsBuilder();
2479         protomatch.setMplsLabel((long) 36008);
2480         protomatch1.setMplsTc((short) 4);
2481         protomatch2.setMplsBos((short) 1);
2482         setFieldBuilder.setProtocolMatchFields(protomatch.build());
2483         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2484         ab.setKey(new ActionKey(0));
2485         actionList.add(ab.build());
2486
2487         setFieldBuilder1.setProtocolMatchFields(protomatch1.build());
2488         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2489         ab1.setKey(new ActionKey(1));
2490         actionList.add(ab1.build());
2491
2492         setFieldBuilder2.setProtocolMatchFields(protomatch2.build());
2493         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2494         ab2.setKey(new ActionKey(2));
2495         actionList.add(ab2.build());
2496
2497         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2498         aab.setAction(actionList);
2499
2500         InstructionBuilder ib = new InstructionBuilder();
2501         ib.setKey(new InstructionKey(0));
2502         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2503
2504         // Put our Instruction in a list of Instructions
2505         InstructionsBuilder isb = new InstructionsBuilder();
2506         List<Instruction> instructions = new ArrayList<Instruction>();
2507         instructions.add(ib.build());
2508         isb.setInstruction(instructions);
2509         return isb;
2510     }
2511
2512     private static InstructionsBuilder createAppyActionInstruction47() {
2513
2514         List<Action> actionList = new ArrayList<Action>();
2515         ActionBuilder ab = new ActionBuilder();
2516         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2517         // PBB
2518         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2519         protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new byte[] { 0, 1, 0, 0 }).build());
2520         setFieldBuilder.setProtocolMatchFields(protomatch.build());
2521         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2522         actionList.add(ab.build());
2523
2524         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2525         aab.setAction(actionList);
2526
2527         InstructionBuilder ib = new InstructionBuilder();
2528         ib.setKey(new InstructionKey(0));
2529         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2530
2531         // Put our Instruction in a list of Instructions
2532         InstructionsBuilder isb = new InstructionsBuilder();
2533         List<Instruction> instructions = new ArrayList<Instruction>();
2534         instructions.add(ib.build());
2535         isb.setInstruction(instructions);
2536         return isb;
2537     }
2538
2539     private static InstructionsBuilder createAppyActionInstruction48() {
2540
2541         List<Action> actionList = new ArrayList<Action>();
2542         ActionBuilder ab = new ActionBuilder();
2543         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2544         // Tunnel
2545         TunnelBuilder tunnel = new TunnelBuilder();
2546         tunnel.setTunnelId(BigInteger.valueOf(10668));
2547         setFieldBuilder.setTunnel(tunnel.build());
2548         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2549         actionList.add(ab.build());
2550
2551         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2552         aab.setAction(actionList);
2553
2554         InstructionBuilder ib = new InstructionBuilder();
2555         ib.setKey(new InstructionKey(0));
2556         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2557
2558         // Put our Instruction in a list of Instructions
2559         InstructionsBuilder isb = new InstructionsBuilder();
2560         List<Instruction> instructions = new ArrayList<Instruction>();
2561         instructions.add(ib.build());
2562         isb.setInstruction(instructions);
2563         return isb;
2564     }
2565
2566     private static MatchBuilder createLLDPMatch() {
2567         MatchBuilder match = new MatchBuilder();
2568         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2569         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2570         ethTypeBuilder.setType(new EtherType(0x88ccL));
2571         eth.setEthernetType(ethTypeBuilder.build());
2572         match.setEthernetMatch(eth.build());
2573         return match;
2574     }
2575
2576     /**
2577      * @return
2578      */
2579     private static MatchBuilder createMatch1() {
2580         MatchBuilder match = new MatchBuilder();
2581         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2582         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
2583         ipv4Match.setIpv4Destination(prefix);
2584         Ipv4Match i4m = ipv4Match.build();
2585         match.setLayer3Match(i4m);
2586
2587         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2588         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2589         ethTypeBuilder.setType(new EtherType(0x0800L));
2590         eth.setEthernetType(ethTypeBuilder.build());
2591         match.setEthernetMatch(eth.build());
2592         return match;
2593     }
2594
2595     /**
2596      * @return
2597      */
2598     private static MatchBuilder createIPv4DstMatch() {
2599         MatchBuilder match = new MatchBuilder();
2600         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2601         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
2602         ipv4Match.setIpv4Destination(prefix);
2603         Ipv4Match i4m = ipv4Match.build();
2604         match.setLayer3Match(i4m);
2605
2606         return match;
2607     }
2608
2609     /**
2610      * @return
2611      */
2612     private static MatchBuilder createIPv4SrcMatch() {
2613         MatchBuilder match = new MatchBuilder();
2614         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2615         Ipv4Prefix prefix = new Ipv4Prefix("10.20.30.40/24");
2616         ipv4Match.setIpv4Source(prefix);
2617         Ipv4Match i4m = ipv4Match.build();
2618         match.setLayer3Match(i4m);
2619
2620         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2621         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2622         ethTypeBuilder.setType(new EtherType(0x0800L));
2623         eth.setEthernetType(ethTypeBuilder.build());
2624         match.setEthernetMatch(eth.build());
2625         return match;
2626     }
2627
2628     /**
2629      * @return
2630      */
2631     private static MatchBuilder createMatch2() {
2632         MatchBuilder match = new MatchBuilder();
2633         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2634         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
2635         ipv4Match.setIpv4Source(prefix);
2636         Ipv4Match i4m = ipv4Match.build();
2637         match.setLayer3Match(i4m);
2638
2639         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2640         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2641         ethTypeBuilder.setType(new EtherType(0x0800L));
2642         eth.setEthernetType(ethTypeBuilder.build());
2643         match.setEthernetMatch(eth.build());
2644         return match;
2645     }
2646
2647     /**
2648      * @return
2649      */
2650     private static MatchBuilder createMatch3() {
2651         MatchBuilder match = new MatchBuilder();
2652         EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2653         EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2654         ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2655         ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2656         match.setEthernetMatch(ethernetMatch.build());
2657
2658         return match;
2659     }
2660
2661     /**
2662      * @return
2663      */
2664     private static MatchBuilder createICMPv6Match1() {
2665
2666         MatchBuilder match = new MatchBuilder();
2667         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2668         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2669         ethTypeBuilder.setType(new EtherType(0x86ddL));
2670         eth.setEthernetType(ethTypeBuilder.build());
2671         match.setEthernetMatch(eth.build());
2672
2673         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2674         ipmatch.setIpProtocol((short) 256);
2675         match.setIpMatch(ipmatch.build());
2676
2677         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2678                                                                    // match
2679         icmpv6match.setIcmpv6Type((short) 135);
2680         icmpv6match.setIcmpv6Code((short) 1);
2681         match.setIcmpv6Match(icmpv6match.build());
2682
2683         return match;
2684     }
2685
2686     private static MatchBuilder createMatch33() {
2687
2688         MatchBuilder match = new MatchBuilder();
2689         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2690         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
2691         ipv4Match.setIpv4Source(prefix);
2692         Ipv4Match i4m = ipv4Match.build();
2693         match.setLayer3Match(i4m);
2694
2695         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2696         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2697         ethTypeBuilder.setType(new EtherType(0xfffeL));
2698         eth.setEthernetType(ethTypeBuilder.build());
2699         match.setEthernetMatch(eth.build());
2700         return match;
2701     }
2702
2703     private static MatchBuilder createInphyportMatch(NodeId nodeId) {
2704         MatchBuilder match = new MatchBuilder();
2705         match.setInPort(new NodeConnectorId(nodeId + ":202"));
2706         match.setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
2707         return match;
2708     }
2709
2710     private static MatchBuilder createEthernetMatch() {
2711         MatchBuilder match = new MatchBuilder();
2712
2713         byte[] mask1 = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
2714         byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
2715
2716         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
2717                                                                     // match
2718         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2719         EtherType type = new EtherType(0x0800L);
2720         ethmatch.setEthernetType(ethtype.setType(type).build());
2721
2722         EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
2723                                                                                // macaddress
2724                                                                                // match
2725         MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2726         ethdest.setAddress(macdest);
2727         ethdest.setMask(mask1);
2728
2729         ethmatch.setEthernetDestination(ethdest.build());
2730
2731         EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
2732         MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2733         ethsrc.setAddress(macsrc);
2734         ethsrc.setMask(mask2);
2735
2736         ethmatch.setEthernetSource(ethsrc.build());
2737         match.setEthernetMatch(ethmatch.build());
2738         return match;
2739
2740     }
2741
2742     /**
2743      * @return
2744      */
2745
2746     private static MatchBuilder createVlanMatch() {
2747         MatchBuilder match = new MatchBuilder();
2748         VlanMatchBuilder vlanBuilder = new VlanMatchBuilder(); // vlan match
2749         VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2750         VlanId vlanId = new VlanId(10);
2751         VlanPcp vpcp = new VlanPcp((short) 3);
2752         vlanBuilder.setVlanPcp(vpcp);
2753         vlanIdBuilder.setVlanId(vlanId);
2754         vlanIdBuilder.setVlanIdPresent(true);
2755         vlanBuilder.setVlanId(vlanIdBuilder.build());
2756         match.setVlanMatch(vlanBuilder.build());
2757         return match;
2758     }
2759
2760     /**
2761      * @return
2762      */
2763     private static MatchBuilder createArpMatch() {
2764         MatchBuilder match = new MatchBuilder();
2765
2766         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2767         MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2768         MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2769
2770         byte[] mask = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
2771         byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
2772
2773         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2774         EtherType type = new EtherType(0x0806L);
2775         ethmatch.setEthernetType(ethtype.setType(type).build());
2776
2777         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
2778         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2779
2780         ArpMatchBuilder arpmatch = new ArpMatchBuilder(); // arp match
2781         ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2782         arpsrc.setAddress(macsrc);
2783         arpsrc.setMask(mask);
2784         ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2785         arpdst.setAddress(macdest);
2786         arpdst.setMask(mask2);
2787         arpmatch.setArpOp(2);
2788         arpmatch.setArpSourceHardwareAddress(arpsrc.build());
2789         arpmatch.setArpTargetHardwareAddress(arpdst.build());
2790         arpmatch.setArpSourceTransportAddress(srcip);
2791         arpmatch.setArpTargetTransportAddress(dstip);
2792
2793         match.setEthernetMatch(ethmatch.build());
2794         match.setLayer3Match(arpmatch.build());
2795
2796         return match;
2797     }
2798
2799     /**
2800      * @return
2801      */
2802     private static MatchBuilder createIPMatch() {
2803         MatchBuilder match = new MatchBuilder();
2804         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2805         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2806         EtherType type = new EtherType(0x0800L);
2807         ethmatch.setEthernetType(ethtype.setType(type).build());
2808         match.setEthernetMatch(ethmatch.build());
2809
2810         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2811         ipmatch.setIpProtocol((short) 1);
2812         Dscp dscp = new Dscp((short) 3);
2813         ipmatch.setIpDscp(dscp);
2814         ipmatch.setIpEcn((short) 2);
2815         match.setIpMatch(ipmatch.build());
2816         return match;
2817     }
2818
2819     /**
2820      * @return
2821      */
2822     private static MatchBuilder createL3IPv4Match() {
2823         MatchBuilder match = new MatchBuilder();
2824
2825         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2826         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2827         ethTypeBuilder.setType(new EtherType(0x0800L));
2828         eth.setEthernetType(ethTypeBuilder.build());
2829         match.setEthernetMatch(eth.build());
2830
2831         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2832         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
2833         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2834         Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
2835         ipv4match.setIpv4Destination(dstip);
2836         ipv4match.setIpv4Source(srcip);
2837         match.setLayer3Match(ipv4match.build());
2838
2839         return match;
2840
2841     }
2842
2843     /**
2844      * @return
2845      */
2846     private static MatchBuilder createL3IPv6Match() {
2847         MatchBuilder match = new MatchBuilder();
2848
2849         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2850         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2851         ethTypeBuilder.setType(new EtherType(0x86ddL));
2852         eth.setEthernetType(ethTypeBuilder.build());
2853         match.setEthernetMatch(eth.build());
2854
2855         Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
2856         Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
2857         Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
2858         MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
2859         MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
2860         Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
2861         nextheader.setIpv6Exthdr(58);
2862         Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2863         Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
2864         ipv6label.setIpv6Flabel(label);
2865         ipv6label.setFlabelMask(new byte[] { 0, 1, -1, -1 });
2866
2867         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2868                                                                    // match
2869         icmpv6match.setIcmpv6Type((short) 135);
2870         icmpv6match.setIcmpv6Code((short) 0);
2871         match.setIcmpv6Match(icmpv6match.build());
2872
2873         Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
2874         // ipv6match.setIpv6Source(srcip6);
2875         // ipv6match.setIpv6Destination(dstip6);
2876         // ipv6match.setIpv6ExtHeader(nextheader.build());
2877         ipv6match.setIpv6NdSll(ndsll);
2878         ipv6match.setIpv6NdTll(ndtll);
2879         // ipv6match.setIpv6NdTarget(ndtarget);
2880         ipv6match.setIpv6Label(ipv6label.build());
2881
2882         match.setLayer3Match(ipv6match.build());
2883
2884         return match;
2885     }
2886
2887     /**
2888      * @return
2889      */
2890
2891     private static MatchBuilder createICMPv4Match() {
2892         MatchBuilder match = new MatchBuilder();
2893         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2894         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2895         ethTypeBuilder.setType(new EtherType(0x0800L));
2896         eth.setEthernetType(ethTypeBuilder.build());
2897         match.setEthernetMatch(eth.build());
2898
2899         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2900         ipmatch.setIpProtocol((short) 1);
2901         match.setIpMatch(ipmatch.build());
2902
2903         Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
2904                                                                    // match
2905         icmpv4match.setIcmpv4Type((short) 8);
2906         icmpv4match.setIcmpv4Code((short) 0);
2907         match.setIcmpv4Match(icmpv4match.build());
2908         return match;
2909     }
2910
2911     /**
2912      * @return
2913      */
2914     private static MatchBuilder createICMPv6Match() {
2915
2916         MatchBuilder match = new MatchBuilder();
2917         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2918         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2919         ethTypeBuilder.setType(new EtherType(0x86ddL));
2920         eth.setEthernetType(ethTypeBuilder.build());
2921         match.setEthernetMatch(eth.build());
2922
2923         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2924         ipmatch.setIpProtocol((short) 58);
2925         match.setIpMatch(ipmatch.build());
2926
2927         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2928                                                                    // match
2929         icmpv6match.setIcmpv6Type((short) 135);
2930         icmpv6match.setIcmpv6Code((short) 1);
2931         match.setIcmpv6Match(icmpv6match.build());
2932
2933         return match;
2934     }
2935
2936     /**
2937      * @return
2938      */
2939     private static MatchBuilder createToSMatch() {
2940         MatchBuilder match = new MatchBuilder();
2941         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2942         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2943         EtherType type = new EtherType(0x0800L);
2944         ethmatch.setEthernetType(ethtype.setType(type).build());
2945         match.setEthernetMatch(ethmatch.build());
2946
2947         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2948         ipmatch.setIpProtocol((short) 6);
2949         Dscp dscp = new Dscp((short) 8);
2950         ipmatch.setIpDscp(dscp);
2951         match.setIpMatch(ipmatch.build());
2952         return match;
2953     }
2954
2955     /**
2956      * @return
2957      */
2958
2959     private static MatchBuilder createL4TCPMatch() {
2960         MatchBuilder match = new MatchBuilder();
2961
2962         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2963         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2964         ethTypeBuilder.setType(new EtherType(0x0800L));
2965         eth.setEthernetType(ethTypeBuilder.build());
2966         match.setEthernetMatch(eth.build());
2967
2968         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2969         ipmatch.setIpProtocol((short) 6);
2970         match.setIpMatch(ipmatch.build());
2971
2972         PortNumber srcport = new PortNumber(1213);
2973         PortNumber dstport = new PortNumber(646);
2974         TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
2975         tcpmatch.setTcpSourcePort(srcport);
2976         tcpmatch.setTcpDestinationPort(dstport);
2977         match.setLayer4Match(tcpmatch.build());
2978
2979         return match;
2980     }
2981
2982     /**
2983      * @return
2984      */
2985     private static MatchBuilder createL4UDPMatch() {
2986         MatchBuilder match = new MatchBuilder();
2987
2988         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2989         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2990         ethTypeBuilder.setType(new EtherType(0x0800L));
2991         eth.setEthernetType(ethTypeBuilder.build());
2992         match.setEthernetMatch(eth.build());
2993
2994         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2995         ipmatch.setIpProtocol((short) 17);
2996         match.setIpMatch(ipmatch.build());
2997
2998         PortNumber srcport = new PortNumber(1325);
2999         PortNumber dstport = new PortNumber(42);
3000         UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
3001         udpmatch.setUdpDestinationPort(dstport);
3002         udpmatch.setUdpSourcePort(srcport);
3003         match.setLayer4Match(udpmatch.build());
3004
3005         return match;
3006     }
3007
3008     /**
3009      * @return
3010      */
3011     private static MatchBuilder createL4SCTPMatch() {
3012         MatchBuilder match = new MatchBuilder();
3013
3014         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3015         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3016         ethTypeBuilder.setType(new EtherType(0x0800L));
3017         eth.setEthernetType(ethTypeBuilder.build());
3018         match.setEthernetMatch(eth.build());
3019
3020         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
3021         ipmatch.setIpProtocol((short) 132);
3022         match.setIpMatch(ipmatch.build());
3023
3024         SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
3025         PortNumber srcport = new PortNumber(1435);
3026         PortNumber dstport = new PortNumber(22);
3027         sctpmatch.setSctpSourcePort(srcport);
3028         sctpmatch.setSctpDestinationPort(dstport);
3029         match.setLayer4Match(sctpmatch.build());
3030
3031         return match;
3032     }
3033
3034     /**
3035      * @return
3036      */
3037     private static MatchBuilder createMetadataMatch() {
3038         MatchBuilder match = new MatchBuilder();
3039         byte[] metamask = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1 };
3040         MetadataBuilder metadata = new MetadataBuilder(); // metadata match
3041         metadata.setMetadata(BigInteger.valueOf(500L));
3042         metadata.setMetadataMask(metamask);
3043         match.setMetadata(metadata.build());
3044
3045         return match;
3046     }
3047
3048     /**
3049      * @return
3050      */
3051     private static MatchBuilder createMplsMatch() {
3052         MatchBuilder match = new MatchBuilder();
3053
3054         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3055         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3056         ethTypeBuilder.setType(new EtherType(0x8847L));
3057         eth.setEthernetType(ethTypeBuilder.build());
3058         match.setEthernetMatch(eth.build());
3059
3060         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
3061         // match
3062         protomatch.setMplsLabel((long) 36008);
3063         protomatch.setMplsTc((short) 4);
3064         protomatch.setMplsBos((short) 1);
3065         match.setProtocolMatchFields(protomatch.build());
3066
3067         return match;
3068
3069     }
3070
3071     /**
3072      * @return
3073      */
3074     private static MatchBuilder createPbbMatch() {
3075         MatchBuilder match = new MatchBuilder();
3076
3077         EthernetMatchBuilder eth = new EthernetMatchBuilder();
3078         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
3079         ethTypeBuilder.setType(new EtherType(0x88E7L));
3080         eth.setEthernetType(ethTypeBuilder.build());
3081         match.setEthernetMatch(eth.build());
3082
3083         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
3084         // match
3085         protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new byte[] { 0, 1, 0, 0 }).build());
3086         match.setProtocolMatchFields(protomatch.build());
3087
3088         return match;
3089
3090     }
3091
3092     /**
3093      * @return
3094      */
3095     private static MatchBuilder createTunnelIDMatch() {
3096         MatchBuilder match = new MatchBuilder();
3097         TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
3098         tunnel.setTunnelId(BigInteger.valueOf(10668));
3099         byte[] mask = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1 };
3100         tunnel.setTunnelMask(mask);
3101         match.setTunnel(tunnel.build());
3102
3103         return match;
3104     }
3105
3106     public void _removeMDFlow(CommandInterpreter ci) {
3107         DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
3108         NodeBuilder tn = createTestNode(ci.nextArgument());
3109         String flowtype = ci.nextArgument();
3110         FlowBuilder tf;
3111         if (flowtype.equals("fTM")) {
3112             tf = createtablemiss(tn, flowtype, ci.nextArgument());
3113         } else {
3114             tf = createTestFlow(tn, flowtype, ci.nextArgument());
3115         }
3116         InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, tn.getKey())
3117                 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
3118                 .child(Flow.class, tf.getKey()).build();
3119         modification.removeOperationalData(nodeBuilderToInstanceId(tn));
3120         modification.removeOperationalData(path1);
3121         modification.removeConfigurationData(nodeBuilderToInstanceId(tn));
3122         modification.removeConfigurationData(path1);
3123         Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
3124         try {
3125             RpcResult<TransactionStatus> result = commitFuture.get();
3126             TransactionStatus status = result.getResult();
3127             ci.println("Status of Flow Data Loaded Transaction: " + status);
3128
3129         } catch (InterruptedException e) {
3130             LOG.error(e.getMessage(), e);
3131         } catch (ExecutionException e) {
3132             LOG.error(e.getMessage(), e);
3133         }
3134     }
3135
3136     public void _addMDFlow(CommandInterpreter ci) {
3137         NodeBuilder tn = createTestNode(ci.nextArgument());
3138         String flowtype = ci.nextArgument();
3139         FlowBuilder tf;
3140         if (flowtype.equals("fTM")) {
3141             tf = createtablemiss(tn, flowtype, ci.nextArgument());
3142         } else {
3143             tf = createTestFlow(tn, flowtype, ci.nextArgument());
3144         }
3145         writeFlow(ci, tf, tn);
3146     }
3147
3148     private void writeFlow(CommandInterpreter ci, FlowBuilder flow, NodeBuilder nodeBuilder) {
3149         DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
3150         InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class)
3151                 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
3152                 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey()).build();
3153         modification.putOperationalData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
3154         modification.putOperationalData(path1, flow.build());
3155         modification.putConfigurationData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
3156         modification.putConfigurationData(path1, flow.build());
3157         Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
3158         try {
3159             RpcResult<TransactionStatus> result = commitFuture.get();
3160             TransactionStatus status = result.getResult();
3161             ci.println("Status of Flow Data Loaded Transaction: " + status);
3162
3163         } catch (InterruptedException e) {
3164             LOG.error(e.getMessage(), e);
3165         } catch (ExecutionException e) {
3166             LOG.error(e.getMessage(), e);
3167         }
3168     }
3169
3170     public void _modifyMDFlow(CommandInterpreter ci) {
3171         NodeBuilder tn = createTestNode(ci.nextArgument());
3172         FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
3173         tf.setFlowName(updatedFlowName);
3174         writeFlow(ci, tf, tn);
3175         tf.setFlowName(originalFlowName);
3176         writeFlow(ci, tf, tn);
3177     }
3178
3179     private static NodeRef createNodeRef(String string) {
3180         NodeKey key = new NodeKey(new NodeId(string));
3181         InstanceIdentifier<Node> path = InstanceIdentifier.builder().node(Nodes.class).node(Node.class, key)
3182                 .toInstance();
3183
3184         return new NodeRef(path);
3185     }
3186
3187     @Override
3188     public String getHelp() {
3189         return "No help";
3190     }
3191 }