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