2 * Copyright (c) 2013 Ericsson , Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.test;
11 import java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.List;
14 import java.util.concurrent.ExecutionException;
15 import java.util.concurrent.Future;
17 import org.eclipse.osgi.framework.console.CommandInterpreter;
18 import org.eclipse.osgi.framework.console.CommandProvider;
19 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
20 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
21 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
22 import org.opendaylight.controller.sal.binding.api.NotificationService;
23 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCaseBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCaseBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCaseBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.action._case.FloodActionBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.hw.path.action._case.HwPathActionBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.loopback.action._case.LoopbackActionBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.type.action._case.SetDlTypeActionBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.next.hop.action._case.SetNextHopActionBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.cfi.action._case.SetVlanCfiActionBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
162 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
163 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
164 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
167 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
168 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
169 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
170 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
171 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
172 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
173 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
174 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
175 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
176 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
177 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
178 import org.opendaylight.yangtools.concepts.Registration;
179 import org.opendaylight.yangtools.yang.binding.DataObject;
180 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
181 import org.opendaylight.yangtools.yang.common.RpcResult;
182 import org.osgi.framework.BundleContext;
183 import org.slf4j.Logger;
184 import org.slf4j.LoggerFactory;
186 public class OpenflowpluginTestCommandProvider implements CommandProvider {
188 private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
190 private DataBrokerService dataBrokerService;
191 private ProviderContext pc;
192 private final BundleContext ctx;
193 private FlowBuilder testFlow;
194 private NodeBuilder testNode;
195 private final String originalFlowName = "Foo";
196 private final String updatedFlowName = "Bar";
197 private final FlowEventListener flowEventListener = new FlowEventListener();
198 private final PortEventListener portEventListener = new PortEventListener();
199 private static NotificationService notificationService;
200 private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listener1Reg;
201 private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listener2Reg;
203 public OpenflowpluginTestCommandProvider(BundleContext ctx) {
207 public void onSessionInitiated(ProviderContext session) {
209 notificationService = session.getSALService(NotificationService.class);
211 listener1Reg = notificationService.registerNotificationListener(flowEventListener);
212 listener2Reg = notificationService.registerNotificationListener(portEventListener);
213 dataBrokerService = session.getSALService(DataBrokerService.class);
214 ctx.registerService(CommandProvider.class.getName(), this, null);
215 createTestFlow(createTestNode(null), null, null);
218 private NodeBuilder createTestNode(String nodeId) {
219 if (nodeId == null) {
220 nodeId = OpenflowpluginTestActivator.NODE_ID;
222 NodeRef nodeOne = createNodeRef(nodeId);
223 NodeBuilder builder = new NodeBuilder();
224 builder.setId(new NodeId(nodeId));
225 builder.setKey(new NodeKey(builder.getId()));
230 final class FlowEventListener implements SalFlowListener {
232 List<FlowAdded> addedFlows = new ArrayList<>();
233 List<FlowRemoved> removedFlows = new ArrayList<>();
234 List<FlowUpdated> updatedFlows = new ArrayList<>();
237 public void onFlowAdded(FlowAdded notification) {
238 System.out.println("flow to be added.........................." + notification.toString());
239 System.out.println("added flow Xid........................." + notification.getTransactionId().getValue());
240 System.out.println("-----------------------------------------------------------------------------------");
241 addedFlows.add(notification);
245 public void onFlowRemoved(FlowRemoved notification) {
246 System.out.println("removed flow.........................." + notification.toString());
247 System.out.println("remove flow Xid........................." + notification.getTransactionId().getValue());
248 System.out.println("-----------------------------------------------------------------------------------");
249 removedFlows.add(notification);
253 public void onFlowUpdated(FlowUpdated notification) {
254 System.out.println("updated flow.........................." + notification.toString());
256 .println("updated flow Xid........................." + notification.getTransactionId().getValue());
257 System.out.println("-----------------------------------------------------------------------------------");
258 updatedFlows.add(notification);
262 public void onNodeErrorNotification(NodeErrorNotification notification) {
263 System.out.println("Error notification flow Xid........................."
264 + notification.getTransactionId().getValue());
265 System.out.println("-----------------------------------------------------------------------------------");
269 public void onNodeExperimenterErrorNotification(NodeExperimenterErrorNotification notification) {
270 // TODO Auto-generated method stub
275 public void onSwitchFlowRemoved(SwitchFlowRemoved notification) {
277 .println("Switch flow removed : Cookies..................." + notification.getCookie().toString());
278 System.out.println("-----------------------------------------------------------------------------------");
283 final class PortEventListener implements OpendaylightInventoryListener {
286 public void onNodeConnectorRemoved(NodeConnectorRemoved notification) {
287 System.out.println("PortStatusMessage: NodeConnectorRemoved ...................");
288 System.out.println(notification.getNodeConnectorRef());
289 System.out.println("----------------------------------------------------------------------");
293 public void onNodeConnectorUpdated(NodeConnectorUpdated notification) {
294 System.out.println("PortStatusMessage: NodeConnectorUpdated ...................");
295 System.out.println(notification.getNodeConnectorRef());
296 System.out.println("----------------------------------------------------------------------");
300 public void onNodeRemoved(NodeRemoved notification) {
301 System.out.println("PortStatusMessage: NodeConnectorUpdated ...................");
302 System.out.println(notification.getNodeRef());
303 System.out.println("----------------------------------------------------------------------");
307 public void onNodeUpdated(NodeUpdated notification) {
308 System.out.println("PortStatusMessage: NodeConnectorUpdated ...................");
309 System.out.println(notification.getNodeRef());
310 System.out.println("----------------------------------------------------------------------");
315 private InstanceIdentifier<Node> nodeBuilderToInstanceId(NodeBuilder node) {
316 return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
319 private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
321 FlowBuilder flow = new FlowBuilder();
324 String flowType = flowTypeArg;
325 if (flowType == null) {
332 flow.setMatch(createMatch1().build());
333 flow.setInstructions(createDecNwTtlInstructions().build());
337 flow.setMatch(createMatch2().build());
338 flow.setInstructions(createDropInstructions().build());
342 flow.setMatch(createMatch3().build());
343 flow.setInstructions(createDropInstructions().build());
347 flow.setMatch(createEthernetMatch().build());
348 flow.setInstructions(createDropInstructions().build());
352 flow.setMatch(createMatch1().build());
353 flow.setInstructions(createAppyActionInstruction().build());
357 flow.setMatch(createMatch1().build());
358 flow.setInstructions(createGotoTableInstructions().build());
362 flow.setMatch(createMatch1().build());
363 flow.setInstructions(createMeterInstructions().build());
367 flow.setMatch(createMatch1().build());
368 flow.setInstructions(createAppyActionInstruction1().build());
372 flow.setMatch(createMatch1().build());
373 flow.setInstructions(createAppyActionInstruction2().build());
377 flow.setMatch(createMatch1().build());
378 flow.setInstructions(createAppyActionInstruction3().build());
382 flow.setMatch(createMatch1().build());
383 flow.setInstructions(createAppyActionInstruction4().build());
387 flow.setMatch(createMatch1().build());
388 flow.setInstructions(createAppyActionInstruction5().build());
392 flow.setMatch(createMatch1().build());
393 flow.setInstructions(createAppyActionInstruction6().build());
397 flow.setMatch(createMatch1().build());
398 flow.setInstructions(createAppyActionInstruction7().build());
402 flow.setMatch(createMatch1().build());
403 flow.setInstructions(createAppyActionInstruction8().build());
407 flow.setMatch(createMatch1().build());
408 flow.setInstructions(createAppyActionInstruction9().build());
412 flow.setMatch(createMatch1().build());
413 flow.setInstructions(createAppyActionInstruction10().build());
417 flow.setMatch(createMatch1().build());
418 flow.setInstructions(createAppyActionInstruction11().build());
422 flow.setMatch(createMatch1().build());
423 flow.setInstructions(createAppyActionInstruction12().build());
427 flow.setMatch(createMatch1().build());
428 flow.setInstructions(createAppyActionInstruction13().build());
432 flow.setMatch(createMatch1().build());
433 flow.setInstructions(createAppyActionInstruction14().build());
437 flow.setMatch(createMatch1().build());
438 flow.setInstructions(createAppyActionInstruction15().build());
442 flow.setMatch(createMatch1().build());
443 flow.setInstructions(createAppyActionInstruction16().build());
447 flow.setMatch(createMatch1().build());
448 flow.setInstructions(createAppyActionInstruction17().build());
452 flow.setMatch(createMatch1().build());
453 flow.setInstructions(createAppyActionInstruction18().build());
457 flow.setMatch(createMatch1().build());
458 flow.setInstructions(createAppyActionInstruction19().build());
462 flow.setMatch(createMatch1().build());
463 flow.setInstructions(createMetadataInstructions().build());
467 flow.setMatch(createMatch1().build());
468 flow.setInstructions(createAppyActionInstruction20().build());
472 flow.setMatch(createMatch1().build());
473 flow.setInstructions(createAppyActionInstruction21().build());
477 flow.setMatch(createMatch1().build());
478 flow.setInstructions(createAppyActionInstruction22().build());
482 flow.setMatch(createMatch1().build());
483 flow.setInstructions(createAppyActionInstruction23().build());
487 flow.setMatch(createMatch1().build());
488 flow.setInstructions(createAppyActionInstruction24().build());
492 flow.setMatch(createMatch1().build());
493 flow.setInstructions(createAppyActionInstruction25().build());
497 flow.setMatch(createMatch1().build());
498 flow.setInstructions(createAppyActionInstruction26().build());
502 flow.setMatch(createMatch1().build());
503 flow.setInstructions(createAppyActionInstruction27().build());
507 flow.setMatch(createMatch1().build());
508 flow.setInstructions(createAppyActionInstruction28().build());
512 flow.setMatch(createMatch1().build());
513 flow.setInstructions(createAppyActionInstruction29().build());
517 flow.setMatch(createMatch1().build());
518 flow.setInstructions(createAppyActionInstruction30().build());
522 flow.setMatch(createMatch1().build());
523 flow.setInstructions(createAppyActionInstruction31().build());
527 flow.setMatch(createMatch1().build());
528 flow.setInstructions(createAppyActionInstruction32().build());
532 flow.setMatch(createMatch1().build());
533 flow.setInstructions(createAppyActionInstruction33().build());
537 flow.setMatch(createMatch1().build());
538 flow.setInstructions(createAppyActionInstruction34().build());
542 flow.setMatch(createICMPv6Match().build());
543 flow.setInstructions(createDecNwTtlInstructions().build());
547 flow.setMatch(createInphyportMatch().build());
548 flow.setInstructions(createDropInstructions().build());
552 flow.setMatch(createMetadataMatch().build());
553 flow.setInstructions(createDropInstructions().build());
557 flow.setMatch(createL3IPv6Match().build());
558 flow.setInstructions(createDecNwTtlInstructions().build());
562 flow.setMatch(createL4SCTPMatch().build());
563 flow.setInstructions(createAppyActionInstruction().build());
567 flow.setMatch(createTunnelIDMatch().build());
568 flow.setInstructions(createGotoTableInstructions().build());
572 flow.setMatch(createVlanMatch().build());
573 flow.setInstructions(createMeterInstructions().build());
577 flow.setMatch(createPbbMatch().build());
578 flow.setInstructions(createMeterInstructions().build());
582 flow.setMatch(createVlanMatch().build());
583 flow.setInstructions(createDropInstructions().build());
587 flow.setMatch(createL4TCPMatch().build());
588 flow.setInstructions(createDropInstructions().build());
593 flow.setMatch(createL4UDPMatch().build());
594 flow.setInstructions(createDropInstructions().build());
598 flow.setMatch(new MatchBuilder().build());
599 flow.setInstructions(createSentToControllerInstructions().build());
603 flow.setMatch(createToSMatch().build());
604 flow.setInstructions(createDropInstructions().build());
608 flow.setMatch(createToSMatch().build());
609 flow.setInstructions(createOutputInstructions("INPORT", 10).build());
613 flow.setMatch(createToSMatch().build());
614 flow.setInstructions(createOutputInstructions("FLOOD", 20).build());
618 flow.setMatch(createToSMatch().build());
619 flow.setInstructions(createOutputInstructions("ALL", 30).build());
623 flow.setMatch(createToSMatch().build());
624 flow.setInstructions(createOutputInstructions("NORMAL", 40).build());
628 flow.setMatch(createToSMatch().build());
629 flow.setInstructions(createOutputInstructions("LOCAL", 50).build());
633 flow.setMatch(createToSMatch().build());
634 flow.setInstructions(createOutputInstructions("TABLE", 60).build());
638 flow.setMatch(createToSMatch().build());
639 flow.setInstructions(createOutputInstructions("NONE", 70).build());
643 flow.setMatch(createToSMatch().build());
644 flow.setInstructions(createStripVlanInstructions().build());
645 flow.setBarrier(Boolean.TRUE);
649 flow.setMatch(createMatch1().build());
650 flow.setInstructions(createAppyActionInstruction35().build());
654 flow.setMatch(createMatch1().build());
655 flow.setInstructions(createAppyActionInstruction36().build());
659 flow.setMatch(createMatch1().build());
660 flow.setInstructions(createAppyActionInstruction37().build());
664 flow.setMatch(createMatch1().build());
665 flow.setInstructions(createAppyActionInstruction38().build());
669 flow.setMatch(createL4TCPMatch().build());
670 flow.setInstructions(createAppyActionInstruction39().build());
674 flow.setMatch(createL4UDPMatch().build());
675 flow.setInstructions(createAppyActionInstruction40().build());
679 flow.setMatch(createL4SCTPMatch().build());
680 flow.setInstructions(createAppyActionInstruction41().build());
684 flow.setMatch(createICMPv4Match().build());
685 flow.setInstructions(createAppyActionInstruction42().build());
689 flow.setMatch(createArpMatch().build());
690 flow.setInstructions(createAppyActionInstruction43().build());
694 flow.setMatch(createL3IPv6Match().build());
695 flow.setInstructions(createAppyActionInstruction44().build());
699 flow.setMatch(createICMPv6Match().build());
700 flow.setInstructions(createAppyActionInstruction45().build());
704 flow.setMatch(createMplsMatch().build());
705 flow.setInstructions(createAppyActionInstruction46().build());
709 flow.setMatch(createPbbMatch().build());
710 flow.setInstructions(createAppyActionInstruction47().build());
714 flow.setMatch(createTunnelIDMatch().build());
715 flow.setInstructions(createAppyActionInstruction48().build());
718 LOG.warn("flow type not understood: {}", flowType);
721 FlowKey key = new FlowKey(new FlowId(id));
722 if (null == flow.isBarrier()) {
723 flow.setBarrier(Boolean.FALSE);
725 // flow.setBufferId(new Long(12));
726 BigInteger value = new BigInteger("10", 10);
727 BigInteger outputPort = new BigInteger("65535", 10);
728 flow.setCookie(value);
729 flow.setCookieMask(value);
730 flow.setHardTimeout(0);
731 flow.setIdleTimeout(0);
732 flow.setInstallHw(false);
733 flow.setStrict(false);
734 flow.setContainerName(null);
735 flow.setFlags(new FlowModFlags(false, false, false, false, true));
736 flow.setId(new FlowId(new Long(12)));
737 flow.setTableId(getTableId(tableId));
738 flow.setOutGroup(new Long(2));
739 // set outport to OFPP_NONE (65535) to disable remove restriction for
741 flow.setOutPort(outputPort);
745 flow.setFlowName(originalFlowName + "X" + flowType);
750 private short getTableId(String tableId) {
753 table = Short.parseShort(tableId);
754 } catch (Exception ex) {
755 // ignore exception and continue with default value
765 private static InstructionsBuilder createDecNwTtlInstructions() {
766 DecNwTtlBuilder ta = new DecNwTtlBuilder();
767 DecNwTtl decNwTtl = ta.build();
768 ActionBuilder ab = new ActionBuilder();
769 ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
771 // Add our drop action to a list
772 List<Action> actionList = new ArrayList<Action>();
773 actionList.add(ab.build());
775 // Create an Apply Action
776 ApplyActionsBuilder aab = new ApplyActionsBuilder();
777 aab.setAction(actionList);
779 // Wrap our Apply Action in an Instruction
780 InstructionBuilder ib = new InstructionBuilder();
781 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
782 ib.setKey(new InstructionKey(0));
785 // Put our Instruction in a list of Instructions
786 InstructionsBuilder isb = new InstructionsBuilder();
787 List<Instruction> instructions = new ArrayList<Instruction>();
788 instructions.add(ib.build());
789 isb.setInstruction(instructions);
796 private static InstructionsBuilder createMeterInstructions() {
798 MeterBuilder aab = new MeterBuilder();
799 aab.setMeterId(new MeterId(new Long(1)));
801 InstructionBuilder ib = new InstructionBuilder();
802 ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
804 // Put our Instruction in a list of Instructions
805 InstructionsBuilder isb = new InstructionsBuilder();
806 List<Instruction> instructions = new ArrayList<Instruction>();
807 instructions.add(ib.build());
808 isb.setInstruction(instructions);
812 private static InstructionsBuilder createMetadataInstructions() {
814 WriteMetadataBuilder aab = new WriteMetadataBuilder();
815 aab.setMetadata(new BigInteger("10", 10));
816 aab.setMetadataMask(new BigInteger("12", 10));
818 InstructionBuilder ib = new InstructionBuilder();
819 ib.setInstruction(new WriteMetadataCaseBuilder().setWriteMetadata(aab.build()).build());
821 // Put our Instruction in a list of Instructions
822 InstructionsBuilder isb = new InstructionsBuilder();
823 List<Instruction> instructions = new ArrayList<Instruction>();
824 instructions.add(ib.build());
825 isb.setInstruction(instructions);
829 private static InstructionsBuilder createGotoTableInstructions() {
831 GoToTableBuilder aab = new GoToTableBuilder();
832 aab.setTableId((short) 2);
834 InstructionBuilder ib = new InstructionBuilder();
835 ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
837 // Put our Instruction in a list of Instructions
838 InstructionsBuilder isb = new InstructionsBuilder();
839 List<Instruction> instructions = new ArrayList<Instruction>();
840 instructions.add(ib.build());
841 isb.setInstruction(instructions);
845 private static InstructionsBuilder createDropInstructions() {
846 DropActionBuilder dab = new DropActionBuilder();
847 DropAction dropAction = dab.build();
848 ActionBuilder ab = new ActionBuilder();
849 ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
851 // Add our drop action to a list
852 List<Action> actionList = new ArrayList<Action>();
853 actionList.add(ab.build());
855 // Create an Apply Action
856 ApplyActionsBuilder aab = new ApplyActionsBuilder();
857 aab.setAction(actionList);
859 // Wrap our Apply Action in an Instruction
860 InstructionBuilder ib = new InstructionBuilder();
861 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
863 // Put our Instruction in a list of Instructions
864 InstructionsBuilder isb = new InstructionsBuilder();
865 List<Instruction> instructions = new ArrayList<Instruction>();
866 instructions.add(ib.build());
867 isb.setInstruction(instructions);
871 private static InstructionsBuilder createAppyActionInstruction() {
873 List<Action> actionList = new ArrayList<Action>();
874 ActionBuilder ab = new ActionBuilder();
875 ControllerActionBuilder controller = new ControllerActionBuilder();
876 controller.setMaxLength(5);
877 ab.setAction(new ControllerActionCaseBuilder().setControllerAction(controller.build()).build());
878 actionList.add(ab.build());
879 // Create an Apply Action
880 ApplyActionsBuilder aab = new ApplyActionsBuilder();
881 aab.setAction(actionList);
883 // Wrap our Apply Action in an Instruction
884 InstructionBuilder ib = new InstructionBuilder();
885 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
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);
895 private static InstructionsBuilder createAppyActionInstruction1() {
897 List<Action> actionList = new ArrayList<Action>();
898 ActionBuilder ab = new ActionBuilder();
900 OutputActionBuilder output = new OutputActionBuilder();
901 output.setMaxLength(56);
902 Uri value = new Uri("PCEP");
903 output.setOutputNodeConnector(value);
904 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
905 actionList.add(ab.build());
906 // Create an Apply Action
907 ApplyActionsBuilder aab = new ApplyActionsBuilder();
908 aab.setAction(actionList);
910 // Wrap our Apply Action in an Instruction
911 InstructionBuilder ib = new InstructionBuilder();
912 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
914 // Put our Instruction in a list of Instructions
915 InstructionsBuilder isb = new InstructionsBuilder();
916 List<Instruction> instructions = new ArrayList<Instruction>();
917 instructions.add(ib.build());
918 isb.setInstruction(instructions);
922 private static InstructionsBuilder createSentToControllerInstructions() {
923 List<Action> actionList = new ArrayList<Action>();
924 ActionBuilder ab = new ActionBuilder();
926 OutputActionBuilder output = new OutputActionBuilder();
927 output.setMaxLength(56);
928 Uri value = new Uri("CONTROLLER");
929 output.setOutputNodeConnector(value);
930 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
932 ab.setKey(new ActionKey(0));
933 actionList.add(ab.build());
934 // Create an Apply Action
935 ApplyActionsBuilder aab = new ApplyActionsBuilder();
936 aab.setAction(actionList);
938 // Wrap our Apply Action in an Instruction
939 InstructionBuilder ib = new InstructionBuilder();
940 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
942 ib.setKey(new InstructionKey(0));
944 // Put our Instruction in a list of Instructions
945 InstructionsBuilder isb = new InstructionsBuilder();
946 List<Instruction> instructions = new ArrayList<Instruction>();
947 instructions.add(ib.build());
948 isb.setInstruction(instructions);
952 private static InstructionsBuilder createOutputInstructions(String outputType, int outputValue) {
953 List<Action> actionList = new ArrayList<Action>();
954 ActionBuilder ab = new ActionBuilder();
956 OutputActionBuilder output = new OutputActionBuilder();
957 output.setMaxLength(outputValue);
958 Uri value = new Uri(outputType);
959 output.setOutputNodeConnector(value);
960 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
962 ab.setKey(new ActionKey(0));
963 actionList.add(ab.build());
964 // Create an Apply Action
965 ApplyActionsBuilder aab = new ApplyActionsBuilder();
966 aab.setAction(actionList);
968 // Wrap our Apply Action in an Instruction
969 InstructionBuilder ib = new InstructionBuilder();
970 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
972 ib.setKey(new InstructionKey(0));
974 // Put our Instruction in a list of Instructions
975 InstructionsBuilder isb = new InstructionsBuilder();
976 List<Instruction> instructions = new ArrayList<Instruction>();
977 instructions.add(ib.build());
978 isb.setInstruction(instructions);
982 private static InstructionsBuilder createStripVlanInstructions() {
983 List<Action> actionList = new ArrayList<Action>();
984 ActionBuilder ab = new ActionBuilder();
986 StripVlanActionBuilder stripActionBuilder = new StripVlanActionBuilder();
987 ab.setAction(new StripVlanActionCaseBuilder().setStripVlanAction(stripActionBuilder.build()).build());
989 ab.setKey(new ActionKey(0));
990 actionList.add(ab.build());
991 // Create an Apply Action
992 ApplyActionsBuilder aab = new ApplyActionsBuilder();
993 aab.setAction(actionList);
995 // Wrap our Apply Action in an Instruction
996 InstructionBuilder ib = new InstructionBuilder();
997 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
999 ib.setKey(new InstructionKey(0));
1001 // Put our Instruction in a list of Instructions
1002 InstructionsBuilder isb = new InstructionsBuilder();
1003 List<Instruction> instructions = new ArrayList<Instruction>();
1004 instructions.add(ib.build());
1005 isb.setInstruction(instructions);
1009 private static InstructionsBuilder createAppyActionInstruction2() {
1011 List<Action> actionList = new ArrayList<Action>();
1012 ActionBuilder ab = new ActionBuilder();
1014 PushMplsActionBuilder push = new PushMplsActionBuilder();
1015 push.setEthernetType(new Integer(0x8847));
1016 ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
1017 actionList.add(ab.build());
1018 // Create an Apply Action
1019 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1020 aab.setAction(actionList);
1022 // Wrap our Apply Action in an Instruction
1023 InstructionBuilder ib = new InstructionBuilder();
1024 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1026 // Put our Instruction in a list of Instructions
1027 InstructionsBuilder isb = new InstructionsBuilder();
1028 List<Instruction> instructions = new ArrayList<Instruction>();
1029 instructions.add(ib.build());
1030 isb.setInstruction(instructions);
1034 private static InstructionsBuilder createAppyActionInstruction3() {
1036 List<Action> actionList = new ArrayList<Action>();
1037 ActionBuilder ab = new ActionBuilder();
1039 PushPbbActionBuilder pbb = new PushPbbActionBuilder();
1040 pbb.setEthernetType(new Integer(0x88E7));
1041 ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
1042 actionList.add(ab.build());
1043 // Create an Apply Action
1044 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1045 aab.setAction(actionList);
1047 // Wrap our Apply Action in an Instruction
1048 InstructionBuilder ib = new InstructionBuilder();
1049 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1051 // Put our Instruction in a list of Instructions
1052 InstructionsBuilder isb = new InstructionsBuilder();
1053 List<Instruction> instructions = new ArrayList<Instruction>();
1054 instructions.add(ib.build());
1055 isb.setInstruction(instructions);
1059 private static InstructionsBuilder createAppyActionInstruction4() {
1061 List<Action> actionList = new ArrayList<Action>();
1062 ActionBuilder ab = new ActionBuilder();
1064 PushVlanActionBuilder vlan = new PushVlanActionBuilder();
1065 vlan.setEthernetType(new Integer(0x8100));
1066 ab.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
1067 actionList.add(ab.build());
1069 // Create an Apply Action
1070 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1071 aab.setAction(actionList);
1073 // Wrap our Apply Action in an Instruction
1074 InstructionBuilder ib = new InstructionBuilder();
1075 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1077 // Put our Instruction in a list of Instructions
1078 InstructionsBuilder isb = new InstructionsBuilder();
1079 List<Instruction> instructions = new ArrayList<Instruction>();
1080 instructions.add(ib.build());
1081 isb.setInstruction(instructions);
1085 private static InstructionsBuilder createAppyActionInstruction5() {
1087 List<Action> actionList = new ArrayList<Action>();
1088 ActionBuilder ab = new ActionBuilder();
1090 SetDlDstActionBuilder setdl = new SetDlDstActionBuilder();
1091 setdl.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1092 ab.setAction(new SetDlDstActionCaseBuilder().setSetDlDstAction(setdl.build()).build());
1093 actionList.add(ab.build());
1094 // Create an Apply Action
1095 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1096 aab.setAction(actionList);
1098 // Wrap our Apply Action in an Instruction
1099 InstructionBuilder ib = new InstructionBuilder();
1100 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1102 // Put our Instruction in a list of Instructions
1103 InstructionsBuilder isb = new InstructionsBuilder();
1104 List<Instruction> instructions = new ArrayList<Instruction>();
1105 instructions.add(ib.build());
1106 isb.setInstruction(instructions);
1110 private static InstructionsBuilder createAppyActionInstruction6() {
1112 List<Action> actionList = new ArrayList<Action>();
1113 ActionBuilder ab = new ActionBuilder();
1115 SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
1116 src.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1117 ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(src.build()).build());
1118 actionList.add(ab.build());
1120 // Create an Apply Action
1121 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1122 aab.setAction(actionList);
1124 // Wrap our Apply Action in an Instruction
1125 InstructionBuilder ib = new InstructionBuilder();
1126 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1128 // Put our Instruction in a list of Instructions
1129 InstructionsBuilder isb = new InstructionsBuilder();
1130 List<Instruction> instructions = new ArrayList<Instruction>();
1131 instructions.add(ib.build());
1132 isb.setInstruction(instructions);
1136 private static InstructionsBuilder createAppyActionInstruction7() {
1138 List<Action> actionList = new ArrayList<Action>();
1139 ActionBuilder ab = new ActionBuilder();
1141 SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
1142 VlanId a = new VlanId(4000);
1144 ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
1145 actionList.add(ab.build());
1146 // Create an Apply Action
1147 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1148 aab.setAction(actionList);
1150 // Wrap our Apply Action in an Instruction
1151 InstructionBuilder ib = new InstructionBuilder();
1152 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1154 // Put our Instruction in a list of Instructions
1155 InstructionsBuilder isb = new InstructionsBuilder();
1156 List<Instruction> instructions = new ArrayList<Instruction>();
1157 instructions.add(ib.build());
1158 isb.setInstruction(instructions);
1162 private static InstructionsBuilder createAppyActionInstruction8() {
1164 List<Action> actionList = new ArrayList<Action>();
1165 ActionBuilder ab = new ActionBuilder();
1167 SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
1168 VlanPcp pcp1 = new VlanPcp((short) 2);
1169 pcp.setVlanPcp(pcp1);
1170 ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
1171 actionList.add(ab.build());
1172 // Create an Apply Action
1173 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1174 aab.setAction(actionList);
1176 // Wrap our Apply Action in an Instruction
1177 InstructionBuilder ib = new InstructionBuilder();
1178 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1180 // Put our Instruction in a list of Instructions
1181 InstructionsBuilder isb = new InstructionsBuilder();
1182 List<Instruction> instructions = new ArrayList<Instruction>();
1183 instructions.add(ib.build());
1184 isb.setInstruction(instructions);
1188 private static InstructionsBuilder createAppyActionInstruction9() {
1190 List<Action> actionList = new ArrayList<Action>();
1191 ActionBuilder ab = new ActionBuilder();
1193 CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
1194 ab.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
1195 actionList.add(ab.build());
1196 // Create an Apply Action
1197 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1198 aab.setAction(actionList);
1200 // Wrap our Apply Action in an Instruction
1201 InstructionBuilder ib = new InstructionBuilder();
1202 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
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);
1212 private static InstructionsBuilder createAppyActionInstruction10() {
1214 List<Action> actionList = new ArrayList<Action>();
1215 ActionBuilder ab = new ActionBuilder();
1217 CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
1218 ab.setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(ttlout.build()).build());
1219 actionList.add(ab.build());
1220 // Create an Apply Action
1221 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1222 aab.setAction(actionList);
1224 // Wrap our Apply Action in an Instruction
1225 InstructionBuilder ib = new InstructionBuilder();
1226 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1228 // Put our Instruction in a list of Instructions
1229 InstructionsBuilder isb = new InstructionsBuilder();
1230 List<Instruction> instructions = new ArrayList<Instruction>();
1231 instructions.add(ib.build());
1232 isb.setInstruction(instructions);
1236 private static InstructionsBuilder createAppyActionInstruction11() {
1238 List<Action> actionList = new ArrayList<Action>();
1239 ActionBuilder ab = new ActionBuilder();
1241 DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
1242 ab.setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(mpls.build()).build());
1243 actionList.add(ab.build());
1244 // Create an Apply Action
1245 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1246 aab.setAction(actionList);
1248 // Wrap our Apply Action in an Instruction
1249 InstructionBuilder ib = new InstructionBuilder();
1250 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1252 // Put our Instruction in a list of Instructions
1253 InstructionsBuilder isb = new InstructionsBuilder();
1254 List<Instruction> instructions = new ArrayList<Instruction>();
1255 instructions.add(ib.build());
1256 isb.setInstruction(instructions);
1260 private static InstructionsBuilder createAppyActionInstruction12() {
1262 List<Action> actionList = new ArrayList<Action>();
1263 ActionBuilder ab = new ActionBuilder();
1265 DecNwTtlBuilder nwttl = new DecNwTtlBuilder();
1266 ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(nwttl.build()).build());
1267 actionList.add(ab.build());
1269 // Create an Apply Action
1270 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1271 aab.setAction(actionList);
1273 // Wrap our Apply Action in an Instruction
1274 InstructionBuilder ib = new InstructionBuilder();
1275 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1277 // Put our Instruction in a list of Instructions
1278 InstructionsBuilder isb = new InstructionsBuilder();
1279 List<Instruction> instructions = new ArrayList<Instruction>();
1280 instructions.add(ib.build());
1281 isb.setInstruction(instructions);
1285 private static InstructionsBuilder createAppyActionInstruction13() {
1287 List<Action> actionList = new ArrayList<Action>();
1288 ActionBuilder ab = new ActionBuilder();
1290 DropActionBuilder drop = new DropActionBuilder();
1291 ab.setAction(new DropActionCaseBuilder().setDropAction(drop.build()).build());
1292 actionList.add(ab.build());
1294 // Create an Apply Action
1295 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1296 aab.setAction(actionList);
1298 // Wrap our Apply Action in an Instruction
1299 InstructionBuilder ib = new InstructionBuilder();
1300 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1302 // Put our Instruction in a list of Instructions
1303 InstructionsBuilder isb = new InstructionsBuilder();
1304 List<Instruction> instructions = new ArrayList<Instruction>();
1305 instructions.add(ib.build());
1306 isb.setInstruction(instructions);
1310 private static InstructionsBuilder createAppyActionInstruction14() {
1312 List<Action> actionList = new ArrayList<Action>();
1313 ActionBuilder ab = new ActionBuilder();
1315 FloodActionBuilder fld = new FloodActionBuilder();
1316 ab.setAction(new FloodActionCaseBuilder().setFloodAction(fld.build()).build());
1317 actionList.add(ab.build());
1318 // Create an Apply Action
1319 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1320 aab.setAction(actionList);
1322 // Wrap our Apply Action in an Instruction
1323 InstructionBuilder ib = new InstructionBuilder();
1324 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1326 // Put our Instruction in a list of Instructions
1327 InstructionsBuilder isb = new InstructionsBuilder();
1328 List<Instruction> instructions = new ArrayList<Instruction>();
1329 instructions.add(ib.build());
1330 isb.setInstruction(instructions);
1334 private static InstructionsBuilder createAppyActionInstruction15() {
1336 List<Action> actionList = new ArrayList<Action>();
1337 ActionBuilder ab = new ActionBuilder();
1339 FloodAllActionBuilder fldall = new FloodAllActionBuilder();
1340 ab.setAction(new FloodAllActionCaseBuilder().setFloodAllAction(fldall.build()).build());
1341 actionList.add(ab.build());
1342 // Create an Apply Action
1343 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1344 aab.setAction(actionList);
1346 // Wrap our Apply Action in an Instruction
1347 InstructionBuilder ib = new InstructionBuilder();
1348 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1350 // Put our Instruction in a list of Instructions
1351 InstructionsBuilder isb = new InstructionsBuilder();
1352 List<Instruction> instructions = new ArrayList<Instruction>();
1353 instructions.add(ib.build());
1354 isb.setInstruction(instructions);
1358 private static InstructionsBuilder createAppyActionInstruction16() {
1360 List<Action> actionList = new ArrayList<Action>();
1361 ActionBuilder ab = new ActionBuilder();
1363 GroupActionBuilder groupActionB = new GroupActionBuilder();
1364 groupActionB.setGroupId(1L);
1365 groupActionB.setGroup("0");
1366 ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
1367 actionList.add(ab.build());
1369 // Create an Apply Action
1370 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1371 aab.setAction(actionList);
1373 // Wrap our Apply Action in an Instruction
1374 InstructionBuilder ib = new InstructionBuilder();
1375 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1377 // Put our Instruction in a list of Instructions
1378 InstructionsBuilder isb = new InstructionsBuilder();
1379 List<Instruction> instructions = new ArrayList<Instruction>();
1380 instructions.add(ib.build());
1381 isb.setInstruction(instructions);
1385 private static InstructionsBuilder createAppyActionInstruction17() {
1387 List<Action> actionList = new ArrayList<Action>();
1388 ActionBuilder ab = new ActionBuilder();
1390 HwPathActionBuilder hwPathB = new HwPathActionBuilder();
1391 ab.setAction(new HwPathActionCaseBuilder().setHwPathAction(hwPathB.build()).build());
1392 actionList.add(ab.build());
1393 // Create an Apply Action
1394 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1395 aab.setAction(actionList);
1397 // Wrap our Apply Action in an Instruction
1398 InstructionBuilder ib = new InstructionBuilder();
1399 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1401 // Put our Instruction in a list of Instructions
1402 InstructionsBuilder isb = new InstructionsBuilder();
1403 List<Instruction> instructions = new ArrayList<Instruction>();
1404 instructions.add(ib.build());
1405 isb.setInstruction(instructions);
1409 private static InstructionsBuilder createAppyActionInstruction18() {
1411 List<Action> actionList = new ArrayList<Action>();
1412 ActionBuilder ab = new ActionBuilder();
1414 LoopbackActionBuilder loopbackActionBuilder = new LoopbackActionBuilder();
1415 ab.setAction(new LoopbackActionCaseBuilder().setLoopbackAction(loopbackActionBuilder.build()).build());
1416 actionList.add(ab.build());
1418 // Create an Apply Action
1419 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1420 aab.setAction(actionList);
1422 // Wrap our Apply Action in an Instruction
1423 InstructionBuilder ib = new InstructionBuilder();
1424 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1426 // Put our Instruction in a list of Instructions
1427 InstructionsBuilder isb = new InstructionsBuilder();
1428 List<Instruction> instructions = new ArrayList<Instruction>();
1429 instructions.add(ib.build());
1430 isb.setInstruction(instructions);
1434 private static InstructionsBuilder createAppyActionInstruction19() {
1436 List<Action> actionList = new ArrayList<Action>();
1437 ActionBuilder ab = new ActionBuilder();
1439 PopMplsActionBuilder popMplsActionBuilder = new PopMplsActionBuilder();
1440 popMplsActionBuilder.setEthernetType(0XB);
1441 ab.setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsActionBuilder.build()).build());
1442 actionList.add(ab.build());
1443 // Create an Apply Action
1444 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1445 aab.setAction(actionList);
1447 // Wrap our Apply Action in an Instruction
1448 InstructionBuilder ib = new InstructionBuilder();
1449 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1451 // Put our Instruction in a list of Instructions
1452 InstructionsBuilder isb = new InstructionsBuilder();
1453 List<Instruction> instructions = new ArrayList<Instruction>();
1454 instructions.add(ib.build());
1455 isb.setInstruction(instructions);
1459 private static InstructionsBuilder createAppyActionInstruction20() {
1461 List<Action> actionList = new ArrayList<Action>();
1462 ActionBuilder ab = new ActionBuilder();
1464 PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
1465 ab.setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPbbActionBuilder.build()).build());
1466 actionList.add(ab.build());
1467 // Create an Apply Action
1468 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1469 aab.setAction(actionList);
1471 // Wrap our Apply Action in an Instruction
1472 InstructionBuilder ib = new InstructionBuilder();
1473 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1475 // Put our Instruction in a list of Instructions
1476 InstructionsBuilder isb = new InstructionsBuilder();
1477 List<Instruction> instructions = new ArrayList<Instruction>();
1478 instructions.add(ib.build());
1479 isb.setInstruction(instructions);
1483 private static InstructionsBuilder createAppyActionInstruction21() {
1485 List<Action> actionList = new ArrayList<Action>();
1486 ActionBuilder ab = new ActionBuilder();
1488 PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
1489 ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
1490 actionList.add(ab.build());
1492 // Create an Apply Action
1493 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1494 aab.setAction(actionList);
1496 // Wrap our Apply Action in an Instruction
1497 InstructionBuilder ib = new InstructionBuilder();
1498 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1500 // Put our Instruction in a list of Instructions
1501 InstructionsBuilder isb = new InstructionsBuilder();
1502 List<Instruction> instructions = new ArrayList<Instruction>();
1503 instructions.add(ib.build());
1504 isb.setInstruction(instructions);
1508 private static InstructionsBuilder createAppyActionInstruction22() {
1510 List<Action> actionList = new ArrayList<Action>();
1511 ActionBuilder ab = new ActionBuilder();
1513 SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
1514 setDlTypeActionBuilder.setDlType(new EtherType(8L));
1515 ab.setAction(new SetDlTypeActionCaseBuilder().setSetDlTypeAction(setDlTypeActionBuilder.build()).build());
1516 actionList.add(ab.build());
1518 // Create an Apply Action
1519 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1520 aab.setAction(actionList);
1522 // Wrap our Apply Action in an Instruction
1523 InstructionBuilder ib = new InstructionBuilder();
1524 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1526 // Put our Instruction in a list of Instructions
1527 InstructionsBuilder isb = new InstructionsBuilder();
1528 List<Instruction> instructions = new ArrayList<Instruction>();
1529 instructions.add(ib.build());
1530 isb.setInstruction(instructions);
1534 private static InstructionsBuilder createAppyActionInstruction23() {
1536 List<Action> actionList = new ArrayList<Action>();
1537 ActionBuilder ab = new ActionBuilder();
1539 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1540 setFieldBuilder.setInPort(new Long(2));
1541 actionList.add(ab.build());
1543 // Create an Apply Action
1544 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1545 aab.setAction(actionList);
1547 // Wrap our Apply Action in an Instruction
1548 InstructionBuilder ib = new InstructionBuilder();
1549 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1551 // Put our Instruction in a list of Instructions
1552 InstructionsBuilder isb = new InstructionsBuilder();
1553 List<Instruction> instructions = new ArrayList<Instruction>();
1554 instructions.add(ib.build());
1555 isb.setInstruction(instructions);
1559 private static InstructionsBuilder createAppyActionInstruction24() {
1561 List<Action> actionList = new ArrayList<Action>();
1562 ActionBuilder ab = new ActionBuilder();
1564 SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
1565 setMplsTtlActionBuilder.setMplsTtl((short) 0X1);
1566 ab.setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMplsTtlActionBuilder.build()).build());
1567 actionList.add(ab.build());
1569 // Create an Apply Action
1570 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1571 aab.setAction(actionList);
1573 // Wrap our Apply Action in an Instruction
1574 InstructionBuilder ib = new InstructionBuilder();
1575 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1577 // Put our Instruction in a list of Instructions
1578 InstructionsBuilder isb = new InstructionsBuilder();
1579 List<Instruction> instructions = new ArrayList<Instruction>();
1580 instructions.add(ib.build());
1581 isb.setInstruction(instructions);
1585 private static InstructionsBuilder createAppyActionInstruction25() {
1587 List<Action> actionList = new ArrayList<Action>();
1588 ActionBuilder ab = new ActionBuilder();
1590 SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
1591 Ipv4Builder ipnext = new Ipv4Builder();
1592 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
1593 ipnext.setIpv4Address(prefix);
1594 setNextHopActionBuilder.setAddress(ipnext.build());
1595 ab.setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilder.build()).build());
1596 actionList.add(ab.build());
1598 // Create an Apply Action
1599 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1600 aab.setAction(actionList);
1602 // Wrap our Apply Action in an Instruction
1603 InstructionBuilder ib = new InstructionBuilder();
1604 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1606 // Put our Instruction in a list of Instructions
1607 InstructionsBuilder isb = new InstructionsBuilder();
1608 List<Instruction> instructions = new ArrayList<Instruction>();
1609 instructions.add(ib.build());
1610 isb.setInstruction(instructions);
1614 private static InstructionsBuilder createAppyActionInstruction26() {
1616 List<Action> actionList = new ArrayList<Action>();
1617 ActionBuilder ab = new ActionBuilder();
1619 SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
1620 Ipv4Builder ipdst = new Ipv4Builder();
1621 Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
1622 ipdst.setIpv4Address(prefixdst);
1623 setNwDstActionBuilder.setAddress(ipdst.build());
1624 ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
1625 actionList.add(ab.build());
1627 // Create an Apply Action
1628 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1629 aab.setAction(actionList);
1631 // Wrap our Apply Action in an Instruction
1632 InstructionBuilder ib = new InstructionBuilder();
1633 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1635 // Put our Instruction in a list of Instructions
1636 InstructionsBuilder isb = new InstructionsBuilder();
1637 List<Instruction> instructions = new ArrayList<Instruction>();
1638 instructions.add(ib.build());
1639 isb.setInstruction(instructions);
1643 private static InstructionsBuilder createAppyActionInstruction27() {
1645 List<Action> actionList = new ArrayList<Action>();
1646 ActionBuilder ab = new ActionBuilder();
1648 SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
1649 Ipv4Builder ipsrc = new Ipv4Builder();
1650 Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
1651 ipsrc.setIpv4Address(prefixsrc);
1652 setNwsrcActionBuilder.setAddress(ipsrc.build());
1653 ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
1654 actionList.add(ab.build());
1656 // Create an Apply Action
1657 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1658 aab.setAction(actionList);
1660 // Wrap our Apply Action in an Instruction
1661 InstructionBuilder ib = new InstructionBuilder();
1662 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1664 // Put our Instruction in a list of Instructions
1665 InstructionsBuilder isb = new InstructionsBuilder();
1666 List<Instruction> instructions = new ArrayList<Instruction>();
1667 instructions.add(ib.build());
1668 isb.setInstruction(instructions);
1672 private static InstructionsBuilder createAppyActionInstruction28() {
1674 List<Action> actionList = new ArrayList<Action>();
1675 ActionBuilder ab = new ActionBuilder();
1677 SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
1678 setNwTosActionBuilder.setTos(8);
1679 ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.build()).build());
1680 actionList.add(ab.build());
1681 // Create an Apply Action
1682 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1683 aab.setAction(actionList);
1685 // Wrap our Apply Action in an Instruction
1686 InstructionBuilder ib = new InstructionBuilder();
1687 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1689 // Put our Instruction in a list of Instructions
1690 InstructionsBuilder isb = new InstructionsBuilder();
1691 List<Instruction> instructions = new ArrayList<Instruction>();
1692 instructions.add(ib.build());
1693 isb.setInstruction(instructions);
1697 private static InstructionsBuilder createAppyActionInstruction29() {
1699 List<Action> actionList = new ArrayList<Action>();
1700 ActionBuilder ab = new ActionBuilder();
1702 SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
1703 setNwTtlActionBuilder.setNwTtl((short) 1);
1704 ab.setAction(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
1705 actionList.add(ab.build());
1707 // Create an Apply Action
1708 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1709 aab.setAction(actionList);
1711 // Wrap our Apply Action in an Instruction
1712 InstructionBuilder ib = new InstructionBuilder();
1713 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1715 // Put our Instruction in a list of Instructions
1716 InstructionsBuilder isb = new InstructionsBuilder();
1717 List<Instruction> instructions = new ArrayList<Instruction>();
1718 instructions.add(ib.build());
1719 isb.setInstruction(instructions);
1723 private static InstructionsBuilder createAppyActionInstruction30() {
1725 List<Action> actionList = new ArrayList<Action>();
1726 ActionBuilder ab = new ActionBuilder();
1728 SetQueueActionBuilder setQueueActionBuilder = new SetQueueActionBuilder();
1729 setQueueActionBuilder.setQueueId(1L);
1730 ab.setAction(new SetQueueActionCaseBuilder().setSetQueueAction(setQueueActionBuilder.build()).build());
1731 actionList.add(ab.build());
1732 // Create an Apply Action
1733 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1734 aab.setAction(actionList);
1736 // Wrap our Apply Action in an Instruction
1737 InstructionBuilder ib = new InstructionBuilder();
1738 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1740 // Put our Instruction in a list of Instructions
1741 InstructionsBuilder isb = new InstructionsBuilder();
1742 List<Instruction> instructions = new ArrayList<Instruction>();
1743 instructions.add(ib.build());
1744 isb.setInstruction(instructions);
1748 private static InstructionsBuilder createAppyActionInstruction31() {
1750 List<Action> actionList = new ArrayList<Action>();
1751 ActionBuilder ab = new ActionBuilder();
1753 SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
1754 setTpDstActionBuilder.setPort(new PortNumber(109));
1756 ab.setAction(new SetTpDstActionCaseBuilder().setSetTpDstAction(setTpDstActionBuilder.build()).build());
1757 actionList.add(ab.build());
1758 // Create an Apply Action
1759 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1760 aab.setAction(actionList);
1762 // Wrap our Apply Action in an Instruction
1763 InstructionBuilder ib = new InstructionBuilder();
1764 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1766 // Put our Instruction in a list of Instructions
1767 InstructionsBuilder isb = new InstructionsBuilder();
1768 List<Instruction> instructions = new ArrayList<Instruction>();
1769 instructions.add(ib.build());
1770 isb.setInstruction(instructions);
1774 private static InstructionsBuilder createAppyActionInstruction32() {
1776 List<Action> actionList = new ArrayList<Action>();
1777 ActionBuilder ab = new ActionBuilder();
1779 SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
1780 setTpSrcActionBuilder.setPort(new PortNumber(109));
1781 ab.setAction(new SetTpSrcActionCaseBuilder().setSetTpSrcAction(setTpSrcActionBuilder.build()).build());
1782 actionList.add(ab.build());
1784 // Create an Apply Action
1785 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1786 aab.setAction(actionList);
1788 // Wrap our Apply Action in an Instruction
1789 InstructionBuilder ib = new InstructionBuilder();
1790 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1792 // Put our Instruction in a list of Instructions
1793 InstructionsBuilder isb = new InstructionsBuilder();
1794 List<Instruction> instructions = new ArrayList<Instruction>();
1795 instructions.add(ib.build());
1796 isb.setInstruction(instructions);
1800 private static InstructionsBuilder createAppyActionInstruction33() {
1802 List<Action> actionList = new ArrayList<Action>();
1803 ActionBuilder ab = new ActionBuilder();
1805 SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
1806 setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(2));
1807 ab.setAction(new SetVlanCfiActionCaseBuilder().setSetVlanCfiAction(setVlanCfiActionBuilder.build()).build());
1808 actionList.add(ab.build());
1810 // Create an Apply Action
1811 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1812 aab.setAction(actionList);
1814 // Wrap our Apply Action in an Instruction
1815 InstructionBuilder ib = new InstructionBuilder();
1816 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1818 // Put our Instruction in a list of Instructions
1819 InstructionsBuilder isb = new InstructionsBuilder();
1820 List<Instruction> instructions = new ArrayList<Instruction>();
1821 instructions.add(ib.build());
1822 isb.setInstruction(instructions);
1826 private static InstructionsBuilder createAppyActionInstruction34() {
1828 List<Action> actionList = new ArrayList<Action>();
1829 ActionBuilder ab = new ActionBuilder();
1831 SwPathActionBuilder swPathAction = new SwPathActionBuilder();
1832 ab.setAction(new SwPathActionCaseBuilder().setSwPathAction(swPathAction.build()).build());
1833 actionList.add(ab.build());
1835 // Create an Apply Action
1836 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1837 aab.setAction(actionList);
1839 // Wrap our Apply Action in an Instruction
1840 InstructionBuilder ib = new InstructionBuilder();
1841 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1843 // Put our Instruction in a list of Instructions
1844 InstructionsBuilder isb = new InstructionsBuilder();
1845 List<Instruction> instructions = new ArrayList<Instruction>();
1846 instructions.add(ib.build());
1847 isb.setInstruction(instructions);
1851 private static InstructionsBuilder createAppyActionInstruction35() {
1853 List<Action> actionList = new ArrayList<Action>();
1854 ActionBuilder ab = new ActionBuilder();
1855 ActionBuilder ab1 = new ActionBuilder();
1856 ActionBuilder ab2 = new ActionBuilder();
1858 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1859 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1860 SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
1863 EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
1864 EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
1865 ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
1866 EthernetMatchBuilder ethernetMatch1 = new EthernetMatchBuilder();
1867 EthernetDestinationBuilder ethDestBuilder = new EthernetDestinationBuilder();
1868 ethDestBuilder.setAddress(new MacAddress("00:00:00:00:00:02"));
1869 EthernetMatchBuilder ethernetMatch2 = new EthernetMatchBuilder();
1870 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1871 ethTypeBuilder.setType(new EtherType(0x86ddL));
1873 ethernetMatch.setEthernetSource(ethSourceBuilder.build());
1874 ethernetMatch1.setEthernetDestination(ethDestBuilder.build());
1875 ethernetMatch2.setEthernetType(ethTypeBuilder.build());
1876 setFieldBuilder.setEthernetMatch(ethernetMatch.build());
1877 setFieldBuilder1.setEthernetMatch(ethernetMatch1.build());
1878 setFieldBuilder2.setEthernetMatch(ethernetMatch2.build());
1879 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1880 ab.setKey(new ActionKey(0));
1881 actionList.add(ab.build());
1883 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1884 ab1.setKey(new ActionKey(1));
1885 actionList.add(ab1.build());
1887 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
1888 ab2.setKey(new ActionKey(2));
1889 actionList.add(ab2.build());
1891 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1892 aab.setAction(actionList);
1894 InstructionBuilder ib = new InstructionBuilder();
1895 ib.setKey(new InstructionKey(0));
1896 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1898 // Put our Instruction in a list of Instructions
1899 InstructionsBuilder isb = new InstructionsBuilder();
1900 List<Instruction> instructions = new ArrayList<Instruction>();
1901 instructions.add(ib.build());
1902 isb.setInstruction(instructions);
1906 private static InstructionsBuilder createAppyActionInstruction36() {
1908 List<Action> actionList = new ArrayList<Action>();
1909 ActionBuilder ab = new ActionBuilder();
1910 ActionBuilder ab1 = new ActionBuilder();
1912 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1913 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1916 VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
1917 VlanMatchBuilder vlanBuilder1 = new VlanMatchBuilder();
1918 VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
1919 VlanId vlanId = new VlanId(10);
1920 VlanPcp vpcp = new VlanPcp((short) 3);
1921 vlanBuilder.setVlanPcp(vpcp);
1922 vlanBuilder1.setVlanId(vlanIdBuilder.setVlanId(vlanId).setVlanIdPresent(true).build());
1923 setFieldBuilder.setVlanMatch(vlanBuilder.build());
1924 setFieldBuilder1.setVlanMatch(vlanBuilder1.build());
1925 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1926 ab.setKey(new ActionKey(0));
1927 actionList.add(ab.build());
1928 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1929 ab1.setKey(new ActionKey(1));
1930 actionList.add(ab1.build());
1932 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1933 aab.setAction(actionList);
1935 InstructionBuilder ib = new InstructionBuilder();
1936 ib.setKey(new InstructionKey(0));
1937 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1939 // Put our Instruction in a list of Instructions
1940 InstructionsBuilder isb = new InstructionsBuilder();
1941 List<Instruction> instructions = new ArrayList<Instruction>();
1942 instructions.add(ib.build());
1943 isb.setInstruction(instructions);
1947 private static InstructionsBuilder createAppyActionInstruction37() {
1949 List<Action> actionList = new ArrayList<Action>();
1950 ActionBuilder ab = new ActionBuilder();
1951 ActionBuilder ab1 = new ActionBuilder();
1952 ActionBuilder ab2 = new ActionBuilder();
1954 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1955 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1956 SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
1958 IpMatchBuilder ipmatch = new IpMatchBuilder();
1959 IpMatchBuilder ipmatch1 = new IpMatchBuilder();
1960 IpMatchBuilder ipmatch2 = new IpMatchBuilder();
1961 Dscp dscp = new Dscp((short) 3);
1962 ipmatch.setIpDscp(dscp);
1963 ipmatch1.setIpEcn((short) 2);
1964 ipmatch2.setIpProtocol((short) 120);
1965 setFieldBuilder.setIpMatch(ipmatch.build());
1966 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1967 ab.setKey(new ActionKey(0));
1968 actionList.add(ab.build());
1970 setFieldBuilder1.setIpMatch(ipmatch1.build());
1971 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1972 ab1.setKey(new ActionKey(1));
1973 actionList.add(ab1.build());
1975 setFieldBuilder2.setIpMatch(ipmatch2.build());
1976 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
1977 ab2.setKey(new ActionKey(2));
1978 actionList.add(ab2.build());
1980 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1981 aab.setAction(actionList);
1983 InstructionBuilder ib = new InstructionBuilder();
1984 ib.setKey(new InstructionKey(0));
1985 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1987 // Put our Instruction in a list of Instructions
1988 InstructionsBuilder isb = new InstructionsBuilder();
1989 List<Instruction> instructions = new ArrayList<Instruction>();
1990 instructions.add(ib.build());
1991 isb.setInstruction(instructions);
1995 private static InstructionsBuilder createAppyActionInstruction38() {
1997 List<Action> actionList = new ArrayList<Action>();
1998 ActionBuilder ab = new ActionBuilder();
1999 ActionBuilder ab1 = new ActionBuilder();
2001 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2002 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2004 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2005 Ipv4MatchBuilder ipv4Match1 = new Ipv4MatchBuilder();
2006 Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.5210");
2007 Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1");
2008 ipv4Match1.setIpv4Destination(dstip);
2009 ipv4Match.setIpv4Source(srcip);
2010 setFieldBuilder.setLayer3Match(ipv4Match.build());
2011 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2012 ab.setKey(new ActionKey(0));
2013 actionList.add(ab.build());
2015 setFieldBuilder1.setLayer3Match(ipv4Match1.build());
2016 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2017 ab1.setKey(new ActionKey(1));
2018 actionList.add(ab1.build());
2020 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2021 aab.setAction(actionList);
2023 InstructionBuilder ib = new InstructionBuilder();
2024 ib.setKey(new InstructionKey(0));
2025 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2027 // Put our Instruction in a list of Instructions
2028 InstructionsBuilder isb = new InstructionsBuilder();
2029 List<Instruction> instructions = new ArrayList<Instruction>();
2030 instructions.add(ib.build());
2031 isb.setInstruction(instructions);
2035 private static InstructionsBuilder createAppyActionInstruction39() {
2037 List<Action> actionList = new ArrayList<Action>();
2038 ActionBuilder ab = new ActionBuilder();
2039 ActionBuilder ab1 = new ActionBuilder();
2041 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2042 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2045 PortNumber tcpsrcport = new PortNumber(1213);
2046 PortNumber tcpdstport = new PortNumber(646);
2047 TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
2048 TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder();
2049 tcpmatch.setTcpSourcePort(tcpsrcport);
2050 tcpmatch1.setTcpDestinationPort(tcpdstport);
2051 setFieldBuilder.setLayer4Match(tcpmatch.build());
2052 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2053 ab.setKey(new ActionKey(0));
2054 actionList.add(ab.build());
2056 setFieldBuilder1.setLayer4Match(tcpmatch1.build());
2057 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2058 ab1.setKey(new ActionKey(1));
2059 actionList.add(ab.build());
2061 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2062 aab.setAction(actionList);
2064 InstructionBuilder ib = new InstructionBuilder();
2065 ib.setKey(new InstructionKey(0));
2066 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2068 // Put our Instruction in a list of Instructions
2069 InstructionsBuilder isb = new InstructionsBuilder();
2070 List<Instruction> instructions = new ArrayList<Instruction>();
2071 instructions.add(ib.build());
2072 isb.setInstruction(instructions);
2076 private static InstructionsBuilder createAppyActionInstruction40() {
2078 List<Action> actionList = new ArrayList<Action>();
2079 ActionBuilder ab = new ActionBuilder();
2080 ActionBuilder ab1 = new ActionBuilder();
2082 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2083 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2086 PortNumber udpsrcport = new PortNumber(1325);
2087 PortNumber udpdstport = new PortNumber(42);
2088 UdpMatchBuilder udpmatch = new UdpMatchBuilder();
2089 UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
2090 udpmatch.setUdpDestinationPort(udpdstport);
2091 udpmatch1.setUdpSourcePort(udpsrcport);
2092 setFieldBuilder.setLayer4Match(udpmatch.build());
2093 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2094 ab.setKey(new ActionKey(0));
2095 actionList.add(ab.build());
2097 setFieldBuilder1.setLayer4Match(udpmatch1.build());
2098 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2099 ab1.setKey(new ActionKey(1));
2100 actionList.add(ab1.build());
2102 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2103 aab.setAction(actionList);
2105 InstructionBuilder ib = new InstructionBuilder();
2106 ib.setKey(new InstructionKey(0));
2107 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2109 // Put our Instruction in a list of Instructions
2110 InstructionsBuilder isb = new InstructionsBuilder();
2111 List<Instruction> instructions = new ArrayList<Instruction>();
2112 instructions.add(ib.build());
2113 isb.setInstruction(instructions);
2117 private static InstructionsBuilder createAppyActionInstruction41() {
2119 List<Action> actionList = new ArrayList<Action>();
2120 ActionBuilder ab = new ActionBuilder();
2121 ActionBuilder ab1 = new ActionBuilder();
2123 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2124 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2127 SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
2128 SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
2129 PortNumber srcport = new PortNumber(1435);
2130 PortNumber dstport = new PortNumber(22);
2131 sctpmatch.setSctpSourcePort(srcport);
2132 sctpmatch1.setSctpDestinationPort(dstport);
2133 setFieldBuilder.setLayer4Match(sctpmatch.build());
2134 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2135 ab.setKey(new ActionKey(0));
2136 actionList.add(ab.build());
2138 setFieldBuilder1.setLayer4Match(sctpmatch1.build());
2139 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2140 ab1.setKey(new ActionKey(1));
2141 actionList.add(ab1.build());
2143 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2144 aab.setAction(actionList);
2146 InstructionBuilder ib = new InstructionBuilder();
2147 ib.setKey(new InstructionKey(0));
2148 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2150 // Put our Instruction in a list of Instructions
2151 InstructionsBuilder isb = new InstructionsBuilder();
2152 List<Instruction> instructions = new ArrayList<Instruction>();
2153 instructions.add(ib.build());
2154 isb.setInstruction(instructions);
2158 private static InstructionsBuilder createAppyActionInstruction42() {
2160 List<Action> actionList = new ArrayList<Action>();
2161 ActionBuilder ab = new ActionBuilder();
2162 ActionBuilder ab1 = new ActionBuilder();
2163 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2164 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2167 Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
2168 Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
2169 icmpv4match.setIcmpv4Type((short) 8);
2170 icmpv4match1.setIcmpv4Code((short) 0);
2171 setFieldBuilder.setIcmpv4Match(icmpv4match.build());
2172 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2173 ab.setKey(new ActionKey(0));
2174 actionList.add(ab.build());
2176 setFieldBuilder1.setIcmpv4Match(icmpv4match1.build());
2177 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2178 ab1.setKey(new ActionKey(1));
2179 actionList.add(ab1.build());
2181 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2182 aab.setAction(actionList);
2184 InstructionBuilder ib = new InstructionBuilder();
2185 ib.setKey(new InstructionKey(0));
2186 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2188 // Put our Instruction in a list of Instructions
2189 InstructionsBuilder isb = new InstructionsBuilder();
2190 List<Instruction> instructions = new ArrayList<Instruction>();
2191 instructions.add(ib.build());
2192 isb.setInstruction(instructions);
2196 private static InstructionsBuilder createAppyActionInstruction43() {
2198 List<Action> actionList = new ArrayList<Action>();
2199 ActionBuilder ab = new ActionBuilder();
2200 ActionBuilder ab1 = new ActionBuilder();
2201 ActionBuilder ab2 = new ActionBuilder();
2202 ActionBuilder ab3 = new ActionBuilder();
2203 ActionBuilder ab4 = new ActionBuilder();
2205 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2206 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2207 SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2208 SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
2209 SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
2211 // setting the values of ARP
2212 MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2213 MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2214 Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52/10");
2215 Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1/8");
2216 // create ARP match action
2217 ArpMatchBuilder arpmatch = new ArpMatchBuilder();
2218 ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
2219 ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
2220 ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
2221 ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
2222 ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2223 arpsrc.setAddress(macsrc);
2224 ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2225 arpdst.setAddress(macdest);
2226 arpmatch.setArpOp(2);
2227 arpmatch1.setArpSourceHardwareAddress(arpsrc.build());
2228 arpmatch2.setArpTargetHardwareAddress(arpdst.build());
2229 arpmatch3.setArpSourceTransportAddress(srciparp);
2230 arpmatch4.setArpTargetTransportAddress(dstiparp);
2231 setFieldBuilder.setLayer3Match(arpmatch.build());
2232 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2233 ab.setKey(new ActionKey(0));
2234 actionList.add(ab.build());
2236 setFieldBuilder1.setLayer3Match(arpmatch1.build());
2237 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2238 ab1.setKey(new ActionKey(1));
2239 actionList.add(ab1.build());
2241 setFieldBuilder2.setLayer3Match(arpmatch2.build());
2242 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2243 ab2.setKey(new ActionKey(2));
2244 actionList.add(ab2.build());
2246 setFieldBuilder3.setLayer3Match(arpmatch3.build());
2247 ab3.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
2248 ab3.setKey(new ActionKey(3));
2249 actionList.add(ab3.build());
2251 setFieldBuilder4.setLayer3Match(arpmatch4.build());
2252 ab4.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
2253 ab4.setKey(new ActionKey(4));
2254 actionList.add(ab4.build());
2256 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2257 aab.setAction(actionList);
2259 InstructionBuilder ib = new InstructionBuilder();
2260 ib.setKey(new InstructionKey(0));
2261 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2263 // Put our Instruction in a list of Instructions
2264 InstructionsBuilder isb = new InstructionsBuilder();
2265 List<Instruction> instructions = new ArrayList<Instruction>();
2266 instructions.add(ib.build());
2267 isb.setInstruction(instructions);
2271 private static InstructionsBuilder createAppyActionInstruction44() {
2273 List<Action> actionList = new ArrayList<Action>();
2274 ActionBuilder ab = new ActionBuilder();
2275 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2276 ActionBuilder ab1 = new ActionBuilder();
2277 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2280 Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
2281 Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
2282 Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2");
2283 Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1");
2284 ipv6Builder1.setIpv6Destination(dstip6);
2285 ipv6Builder.setIpv6Source(srcip6);
2286 setFieldBuilder.setLayer3Match(ipv6Builder.build());
2287 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2288 ab.setKey(new ActionKey(0));
2289 actionList.add(ab.build());
2291 setFieldBuilder1.setLayer3Match(ipv6Builder1.build());
2292 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2293 ab1.setKey(new ActionKey(1));
2294 actionList.add(ab1.build());
2296 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2297 aab.setAction(actionList);
2299 InstructionBuilder ib = new InstructionBuilder();
2300 ib.setKey(new InstructionKey(0));
2301 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2303 // Put our Instruction in a list of Instructions
2304 InstructionsBuilder isb = new InstructionsBuilder();
2305 List<Instruction> instructions = new ArrayList<Instruction>();
2306 instructions.add(ib.build());
2307 isb.setInstruction(instructions);
2311 private static InstructionsBuilder createAppyActionInstruction45() {
2313 List<Action> actionList = new ArrayList<Action>();
2314 ActionBuilder ab = new ActionBuilder();
2315 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2316 ActionBuilder ab1 = new ActionBuilder();
2317 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2320 Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
2321 Icmpv6MatchBuilder icmpv6match1 = new Icmpv6MatchBuilder();
2322 icmpv6match.setIcmpv6Type((short) 135);
2323 icmpv6match1.setIcmpv6Code((short) 0);
2324 setFieldBuilder.setIcmpv6Match(icmpv6match.build());
2325 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2326 ab.setKey(new ActionKey(0));
2327 actionList.add(ab.build());
2329 setFieldBuilder1.setIcmpv6Match(icmpv6match1.build());
2330 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2331 ab1.setKey(new ActionKey(1));
2332 actionList.add(ab1.build());
2334 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2335 aab.setAction(actionList);
2337 InstructionBuilder ib = new InstructionBuilder();
2338 ib.setKey(new InstructionKey(0));
2339 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2341 // Put our Instruction in a list of Instructions
2342 InstructionsBuilder isb = new InstructionsBuilder();
2343 List<Instruction> instructions = new ArrayList<Instruction>();
2344 instructions.add(ib.build());
2345 isb.setInstruction(instructions);
2349 private static InstructionsBuilder createAppyActionInstruction46() {
2351 List<Action> actionList = new ArrayList<Action>();
2352 ActionBuilder ab = new ActionBuilder();
2353 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2354 ActionBuilder ab1 = new ActionBuilder();
2355 SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2356 ActionBuilder ab2 = new ActionBuilder();
2357 SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2360 ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2361 ProtocolMatchFieldsBuilder protomatch1 = new ProtocolMatchFieldsBuilder();
2362 ProtocolMatchFieldsBuilder protomatch2 = new ProtocolMatchFieldsBuilder();
2363 protomatch.setMplsLabel((long) 36008);
2364 protomatch1.setMplsTc((short) 4);
2365 protomatch2.setMplsBos((short) 1);
2366 setFieldBuilder.setProtocolMatchFields(protomatch.build());
2367 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2368 ab.setKey(new ActionKey(0));
2369 actionList.add(ab.build());
2371 setFieldBuilder1.setProtocolMatchFields(protomatch1.build());
2372 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2373 ab1.setKey(new ActionKey(1));
2374 actionList.add(ab1.build());
2376 setFieldBuilder2.setProtocolMatchFields(protomatch2.build());
2377 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2378 ab2.setKey(new ActionKey(2));
2379 actionList.add(ab2.build());
2381 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2382 aab.setAction(actionList);
2384 InstructionBuilder ib = new InstructionBuilder();
2385 ib.setKey(new InstructionKey(0));
2386 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2388 // Put our Instruction in a list of Instructions
2389 InstructionsBuilder isb = new InstructionsBuilder();
2390 List<Instruction> instructions = new ArrayList<Instruction>();
2391 instructions.add(ib.build());
2392 isb.setInstruction(instructions);
2396 private static InstructionsBuilder createAppyActionInstruction47() {
2398 List<Action> actionList = new ArrayList<Action>();
2399 ActionBuilder ab = new ActionBuilder();
2400 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2402 ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2403 protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new byte[] { 0, 1, 0, 0 }).build());
2404 setFieldBuilder.setProtocolMatchFields(protomatch.build());
2405 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2406 actionList.add(ab.build());
2408 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2409 aab.setAction(actionList);
2411 InstructionBuilder ib = new InstructionBuilder();
2412 ib.setKey(new InstructionKey(0));
2413 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2415 // Put our Instruction in a list of Instructions
2416 InstructionsBuilder isb = new InstructionsBuilder();
2417 List<Instruction> instructions = new ArrayList<Instruction>();
2418 instructions.add(ib.build());
2419 isb.setInstruction(instructions);
2423 private static InstructionsBuilder createAppyActionInstruction48() {
2425 List<Action> actionList = new ArrayList<Action>();
2426 ActionBuilder ab = new ActionBuilder();
2427 SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2429 TunnelBuilder tunnel = new TunnelBuilder();
2430 tunnel.setTunnelId(BigInteger.valueOf(10668));
2431 setFieldBuilder.setTunnel(tunnel.build());
2432 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2433 actionList.add(ab.build());
2435 ApplyActionsBuilder aab = new ApplyActionsBuilder();
2436 aab.setAction(actionList);
2438 InstructionBuilder ib = new InstructionBuilder();
2439 ib.setKey(new InstructionKey(0));
2440 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2442 // Put our Instruction in a list of Instructions
2443 InstructionsBuilder isb = new InstructionsBuilder();
2444 List<Instruction> instructions = new ArrayList<Instruction>();
2445 instructions.add(ib.build());
2446 isb.setInstruction(instructions);
2453 private static MatchBuilder createMatch1() {
2454 MatchBuilder match = new MatchBuilder();
2455 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2456 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
2457 ipv4Match.setIpv4Destination(prefix);
2458 Ipv4Match i4m = ipv4Match.build();
2459 match.setLayer3Match(i4m);
2461 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2462 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2463 ethTypeBuilder.setType(new EtherType(0x0800L));
2464 eth.setEthernetType(ethTypeBuilder.build());
2465 match.setEthernetMatch(eth.build());
2472 private static MatchBuilder createIPv4DstMatch() {
2473 MatchBuilder match = new MatchBuilder();
2474 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2475 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
2476 ipv4Match.setIpv4Destination(prefix);
2477 Ipv4Match i4m = ipv4Match.build();
2478 match.setLayer3Match(i4m);
2486 private static MatchBuilder createIPv4SrcMatch() {
2487 MatchBuilder match = new MatchBuilder();
2488 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2489 Ipv4Prefix prefix = new Ipv4Prefix("10.20.30.40/24");
2490 ipv4Match.setIpv4Source(prefix);
2491 Ipv4Match i4m = ipv4Match.build();
2492 match.setLayer3Match(i4m);
2494 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2495 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2496 ethTypeBuilder.setType(new EtherType(0x0800L));
2497 eth.setEthernetType(ethTypeBuilder.build());
2498 match.setEthernetMatch(eth.build());
2505 private static MatchBuilder createMatch2() {
2506 MatchBuilder match = new MatchBuilder();
2507 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2508 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
2509 ipv4Match.setIpv4Source(prefix);
2510 Ipv4Match i4m = ipv4Match.build();
2511 match.setLayer3Match(i4m);
2513 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2514 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2515 ethTypeBuilder.setType(new EtherType(0x0800L));
2516 eth.setEthernetType(ethTypeBuilder.build());
2517 match.setEthernetMatch(eth.build());
2524 private static MatchBuilder createMatch3() {
2525 MatchBuilder match = new MatchBuilder();
2526 EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2527 EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2528 ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2529 ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2530 match.setEthernetMatch(ethernetMatch.build());
2535 private static MatchBuilder createInphyportMatch() {
2536 MatchBuilder match = new MatchBuilder();
2537 match.setInPort(202L);
2538 match.setInPhyPort(10122L);
2542 private static MatchBuilder createEthernetMatch() {
2543 MatchBuilder match = new MatchBuilder();
2545 byte[] mask1 = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
2546 byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
2548 EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
2550 EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2551 EtherType type = new EtherType(0x0800L);
2552 ethmatch.setEthernetType(ethtype.setType(type).build());
2554 EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
2557 MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2558 ethdest.setAddress(macdest);
2559 ethdest.setMask(mask1);
2561 ethmatch.setEthernetDestination(ethdest.build());
2563 EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
2564 MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2565 ethsrc.setAddress(macsrc);
2566 ethsrc.setMask(mask2);
2568 ethmatch.setEthernetSource(ethsrc.build());
2569 match.setEthernetMatch(ethmatch.build());
2578 private static MatchBuilder createVlanMatch() {
2579 MatchBuilder match = new MatchBuilder();
2580 VlanMatchBuilder vlanBuilder = new VlanMatchBuilder(); // vlan match
2581 VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2582 VlanId vlanId = new VlanId(10);
2583 VlanPcp vpcp = new VlanPcp((short) 3);
2584 vlanBuilder.setVlanPcp(vpcp);
2585 vlanIdBuilder.setVlanId(vlanId);
2586 vlanIdBuilder.setVlanIdPresent(true);
2587 vlanBuilder.setVlanId(vlanIdBuilder.build());
2588 match.setVlanMatch(vlanBuilder.build());
2595 private static MatchBuilder createArpMatch() {
2596 MatchBuilder match = new MatchBuilder();
2598 EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2599 MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2600 MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2602 byte[] mask = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
2603 byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
2605 EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2606 EtherType type = new EtherType(0x0806L);
2607 ethmatch.setEthernetType(ethtype.setType(type).build());
2609 Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
2610 Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2612 ArpMatchBuilder arpmatch = new ArpMatchBuilder(); // arp match
2613 ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2614 arpsrc.setAddress(macsrc);
2615 arpsrc.setMask(mask);
2616 ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2617 arpdst.setAddress(macdest);
2618 arpdst.setMask(mask2);
2619 arpmatch.setArpOp(2);
2620 arpmatch.setArpSourceHardwareAddress(arpsrc.build());
2621 arpmatch.setArpTargetHardwareAddress(arpdst.build());
2622 arpmatch.setArpSourceTransportAddress(srcip);
2623 arpmatch.setArpTargetTransportAddress(dstip);
2625 match.setEthernetMatch(ethmatch.build());
2626 match.setLayer3Match(arpmatch.build());
2634 private static MatchBuilder createIPMatch() {
2635 MatchBuilder match = new MatchBuilder();
2636 EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2637 EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2638 EtherType type = new EtherType(0x0800L);
2639 ethmatch.setEthernetType(ethtype.setType(type).build());
2640 match.setEthernetMatch(ethmatch.build());
2642 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2643 ipmatch.setIpProtocol((short) 1);
2644 Dscp dscp = new Dscp((short) 3);
2645 ipmatch.setIpDscp(dscp);
2646 ipmatch.setIpEcn((short) 2);
2647 match.setIpMatch(ipmatch.build());
2654 private static MatchBuilder createL3IPv4Match() {
2655 MatchBuilder match = new MatchBuilder();
2657 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2658 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2659 ethTypeBuilder.setType(new EtherType(0x0800L));
2660 eth.setEthernetType(ethTypeBuilder.build());
2661 match.setEthernetMatch(eth.build());
2663 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2664 Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
2665 Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2666 Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
2667 ipv4match.setIpv4Destination(dstip);
2668 ipv4match.setIpv4Source(srcip);
2669 match.setLayer3Match(ipv4match.build());
2678 private static MatchBuilder createL3IPv6Match() {
2679 MatchBuilder match = new MatchBuilder();
2681 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2682 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2683 ethTypeBuilder.setType(new EtherType(0x86ddL));
2684 eth.setEthernetType(ethTypeBuilder.build());
2685 match.setEthernetMatch(eth.build());
2687 Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
2688 Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
2689 Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
2690 MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
2691 MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
2692 Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
2693 nextheader.setIpv6Exthdr(58);
2694 Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2695 Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
2696 ipv6label.setIpv6Flabel(label);
2697 ipv6label.setFlabelMask(new byte[] { 0, 1, -1, -1 });
2699 Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2701 icmpv6match.setIcmpv6Type((short) 135);
2702 icmpv6match.setIcmpv6Code((short) 0);
2703 match.setIcmpv6Match(icmpv6match.build());
2705 Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
2706 // ipv6match.setIpv6Source(srcip6);
2707 // ipv6match.setIpv6Destination(dstip6);
2708 // ipv6match.setIpv6ExtHeader(nextheader.build());
2709 ipv6match.setIpv6NdSll(ndsll);
2710 ipv6match.setIpv6NdTll(ndtll);
2711 // ipv6match.setIpv6NdTarget(ndtarget);
2712 ipv6match.setIpv6Label(ipv6label.build());
2714 match.setLayer3Match(ipv6match.build());
2723 private static MatchBuilder createICMPv4Match() {
2724 MatchBuilder match = new MatchBuilder();
2725 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2726 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2727 ethTypeBuilder.setType(new EtherType(0x0800L));
2728 eth.setEthernetType(ethTypeBuilder.build());
2729 match.setEthernetMatch(eth.build());
2731 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2732 ipmatch.setIpProtocol((short) 1);
2733 match.setIpMatch(ipmatch.build());
2735 Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
2737 icmpv4match.setIcmpv4Type((short) 8);
2738 icmpv4match.setIcmpv4Code((short) 0);
2739 match.setIcmpv4Match(icmpv4match.build());
2746 private static MatchBuilder createICMPv6Match() {
2748 MatchBuilder match = new MatchBuilder();
2749 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2750 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2751 ethTypeBuilder.setType(new EtherType(0x86ddL));
2752 eth.setEthernetType(ethTypeBuilder.build());
2753 match.setEthernetMatch(eth.build());
2755 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2756 ipmatch.setIpProtocol((short) 58);
2757 match.setIpMatch(ipmatch.build());
2759 Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2761 icmpv6match.setIcmpv6Type((short) 135);
2762 icmpv6match.setIcmpv6Code((short) 1);
2763 match.setIcmpv6Match(icmpv6match.build());
2771 private static MatchBuilder createToSMatch() {
2772 MatchBuilder match = new MatchBuilder();
2773 EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2774 EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2775 EtherType type = new EtherType(0x0800L);
2776 ethmatch.setEthernetType(ethtype.setType(type).build());
2777 match.setEthernetMatch(ethmatch.build());
2779 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2780 ipmatch.setIpProtocol((short) 6);
2781 Dscp dscp = new Dscp((short) 8);
2782 ipmatch.setIpDscp(dscp);
2783 match.setIpMatch(ipmatch.build());
2791 private static MatchBuilder createL4TCPMatch() {
2792 MatchBuilder match = new MatchBuilder();
2794 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2795 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2796 ethTypeBuilder.setType(new EtherType(0x0800L));
2797 eth.setEthernetType(ethTypeBuilder.build());
2798 match.setEthernetMatch(eth.build());
2800 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2801 ipmatch.setIpProtocol((short) 6);
2802 match.setIpMatch(ipmatch.build());
2804 PortNumber srcport = new PortNumber(1213);
2805 PortNumber dstport = new PortNumber(646);
2806 TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
2807 tcpmatch.setTcpSourcePort(srcport);
2808 tcpmatch.setTcpDestinationPort(dstport);
2809 match.setLayer4Match(tcpmatch.build());
2817 private static MatchBuilder createL4UDPMatch() {
2818 MatchBuilder match = new MatchBuilder();
2820 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2821 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2822 ethTypeBuilder.setType(new EtherType(0x0800L));
2823 eth.setEthernetType(ethTypeBuilder.build());
2824 match.setEthernetMatch(eth.build());
2826 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2827 ipmatch.setIpProtocol((short) 17);
2828 match.setIpMatch(ipmatch.build());
2830 PortNumber srcport = new PortNumber(1325);
2831 PortNumber dstport = new PortNumber(42);
2832 UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
2833 udpmatch.setUdpDestinationPort(dstport);
2834 udpmatch.setUdpSourcePort(srcport);
2835 match.setLayer4Match(udpmatch.build());
2843 private static MatchBuilder createL4SCTPMatch() {
2844 MatchBuilder match = new MatchBuilder();
2846 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2847 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2848 ethTypeBuilder.setType(new EtherType(0x0800L));
2849 eth.setEthernetType(ethTypeBuilder.build());
2850 match.setEthernetMatch(eth.build());
2852 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2853 ipmatch.setIpProtocol((short) 132);
2854 match.setIpMatch(ipmatch.build());
2856 SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
2857 PortNumber srcport = new PortNumber(1435);
2858 PortNumber dstport = new PortNumber(22);
2859 sctpmatch.setSctpSourcePort(srcport);
2860 sctpmatch.setSctpDestinationPort(dstport);
2861 match.setLayer4Match(sctpmatch.build());
2869 private static MatchBuilder createMetadataMatch() {
2870 MatchBuilder match = new MatchBuilder();
2871 byte[] metamask = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1 };
2872 MetadataBuilder metadata = new MetadataBuilder(); // metadata match
2873 metadata.setMetadata(BigInteger.valueOf(500L));
2874 metadata.setMetadataMask(metamask);
2875 match.setMetadata(metadata.build());
2883 private static MatchBuilder createMplsMatch() {
2884 MatchBuilder match = new MatchBuilder();
2886 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2887 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2888 ethTypeBuilder.setType(new EtherType(0x8847L));
2889 eth.setEthernetType(ethTypeBuilder.build());
2890 match.setEthernetMatch(eth.build());
2892 ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
2894 protomatch.setMplsLabel((long) 36008);
2895 protomatch.setMplsTc((short) 4);
2896 protomatch.setMplsBos((short) 1);
2897 match.setProtocolMatchFields(protomatch.build());
2906 private static MatchBuilder createPbbMatch() {
2907 MatchBuilder match = new MatchBuilder();
2909 EthernetMatchBuilder eth = new EthernetMatchBuilder();
2910 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2911 ethTypeBuilder.setType(new EtherType(0x88E7L));
2912 eth.setEthernetType(ethTypeBuilder.build());
2913 match.setEthernetMatch(eth.build());
2915 ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
2917 protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new byte[] { 0, 1, 0, 0 }).build());
2918 match.setProtocolMatchFields(protomatch.build());
2927 private static MatchBuilder createTunnelIDMatch() {
2928 MatchBuilder match = new MatchBuilder();
2929 TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
2930 tunnel.setTunnelId(BigInteger.valueOf(10668));
2931 byte[] mask = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1 };
2932 tunnel.setTunnelMask(mask);
2933 match.setTunnel(tunnel.build());
2938 public void _removeMDFlow(CommandInterpreter ci) {
2939 DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
2940 NodeBuilder tn = createTestNode(ci.nextArgument());
2941 FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
2942 InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, tn.getKey())
2943 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
2944 .child(Flow.class, tf.getKey()).build();
2945 modification.removeOperationalData(nodeBuilderToInstanceId(tn));
2946 modification.removeOperationalData(path1);
2947 modification.removeConfigurationData(nodeBuilderToInstanceId(tn));
2948 modification.removeConfigurationData(path1);
2949 Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
2951 RpcResult<TransactionStatus> result = commitFuture.get();
2952 TransactionStatus status = result.getResult();
2953 ci.println("Status of Flow Data Loaded Transaction: " + status);
2955 } catch (InterruptedException e) {
2956 LOG.error(e.getMessage(), e);
2957 } catch (ExecutionException e) {
2958 LOG.error(e.getMessage(), e);
2962 public void _addMDFlow(CommandInterpreter ci) {
2963 NodeBuilder tn = createTestNode(ci.nextArgument());
2964 FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
2965 writeFlow(ci, tf, tn);
2968 private void writeFlow(CommandInterpreter ci, FlowBuilder flow, NodeBuilder nodeBuilder) {
2969 DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
2970 InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class)
2971 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
2972 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey()).build();
2973 modification.putOperationalData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
2974 modification.putOperationalData(path1, flow.build());
2975 modification.putConfigurationData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
2976 modification.putConfigurationData(path1, flow.build());
2977 Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
2979 RpcResult<TransactionStatus> result = commitFuture.get();
2980 TransactionStatus status = result.getResult();
2981 ci.println("Status of Flow Data Loaded Transaction: " + status);
2983 } catch (InterruptedException e) {
2984 LOG.error(e.getMessage(), e);
2985 } catch (ExecutionException e) {
2986 LOG.error(e.getMessage(), e);
2990 public void _modifyMDFlow(CommandInterpreter ci) {
2991 NodeBuilder tn = createTestNode(ci.nextArgument());
2992 FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
2993 tf.setFlowName(updatedFlowName);
2994 writeFlow(ci, tf, tn);
2995 tf.setFlowName(originalFlowName);
2996 writeFlow(ci, tf, tn);
2999 private static NodeRef createNodeRef(String string) {
3000 NodeKey key = new NodeKey(new NodeId(string));
3001 InstanceIdentifier<Node> path = InstanceIdentifier.builder().node(Nodes.class).node(Node.class, key)
3004 return new NodeRef(path);
3008 public String getHelp() {