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