2 * Copyright (c) 2013, 2015 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
8 package org.opendaylight.openflowplugin.test;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.util.concurrent.FutureCallback;
13 import com.google.common.util.concurrent.MoreExecutors;
14 import java.util.concurrent.ExecutorService;
15 import java.util.concurrent.Executors;
16 import java.util.concurrent.TimeUnit;
17 import javax.annotation.PreDestroy;
18 import javax.inject.Inject;
19 import javax.inject.Singleton;
20 import org.eclipse.osgi.framework.console.CommandInterpreter;
21 import org.eclipse.osgi.framework.console.CommandProvider;
22 import org.opendaylight.mdsal.binding.api.DataBroker;
23 import org.opendaylight.mdsal.binding.api.NotificationService;
24 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
25 import org.opendaylight.mdsal.common.api.CommitInfo;
26 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCaseBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCaseBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCaseBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCaseBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
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.ActionBuilder;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagsMatchBuilder;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder;
162 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
163 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
164 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
167 import org.opendaylight.yangtools.concepts.Registration;
168 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
169 import org.opendaylight.yangtools.yang.binding.util.BindingMap;
170 import org.opendaylight.yangtools.yang.common.Uint16;
171 import org.opendaylight.yangtools.yang.common.Uint32;
172 import org.opendaylight.yangtools.yang.common.Uint64;
173 import org.opendaylight.yangtools.yang.common.Uint8;
174 import org.osgi.service.component.annotations.Activate;
175 import org.osgi.service.component.annotations.Component;
176 import org.osgi.service.component.annotations.Deactivate;
177 import org.osgi.service.component.annotations.Reference;
178 import org.slf4j.Logger;
179 import org.slf4j.LoggerFactory;
182 @Component(service = CommandProvider.class, immediate = true)
183 public class OpenflowpluginTestCommandProvider implements CommandProvider, AutoCloseable {
184 private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
186 private static final String ORIGINAL_FLOW_NAME = "Foo";
187 private static final String UPDATED_FLOW_NAME = "Bar";
188 private static final String IPV4_PREFIX = "10.0.0.1/24";
189 private static final String DEST_MAC_ADDRESS = "ff:ff:ff:ff:ff:ff";
190 private static final String SRC_MAC_ADDRESS = "00:00:00:00:23:ae";
192 private final DataBroker dataBroker;
193 private final Registration reg;
197 public OpenflowpluginTestCommandProvider(@Reference final DataBroker dataBroker,
198 @Reference final NotificationService notificationService) {
199 this.dataBroker = requireNonNull(dataBroker);
201 reg = notificationService.registerCompositeListener(FlowEventListenerLoggingImpl.newListener());
202 createTestFlow(createTestNode(null), null, null);
208 public void close() {
212 private static NodeBuilder createTestNode(final String nodeId) {
213 return new NodeBuilder().setId(new NodeId(nodeId != null ? nodeId : OpenflowpluginTestActivator.NODE_ID));
216 private static InstanceIdentifier<Node> nodeBuilderToInstanceId(final NodeBuilder node) {
217 return InstanceIdentifier.create(Nodes.class).child(Node.class, node.key());
220 private static FlowBuilder createTestFlow(final NodeBuilder nodeBuilder, final String flowTypeArg,
221 final String tableId) {
222 final long TEST_ID = 123;
226 String flowType = flowTypeArg;
227 if (flowType == null) {
231 final FlowBuilder flow = new FlowBuilder()
232 .setPriority(Uint16.TWO);
237 flow.setMatch(createMatch1().build());
238 flow.setInstructions(createDecNwTtlInstructions().build());
242 flow.setMatch(createMatch2().build());
243 flow.setInstructions(createDropInstructions().build());
247 flow.setMatch(createMatch3().build());
248 flow.setInstructions(createDropInstructions().build());
252 flow.setMatch(createEthernetMatch().build());
253 flow.setInstructions(createDropInstructions().build());
257 flow.setMatch(createMatch1().build());
258 flow.setInstructions(createAppyActionInstruction().build());
262 flow.setMatch(createMatch1().build());
263 flow.setInstructions(createGotoTableInstructions().build());
267 flow.setMatch(createMatch1().build());
268 flow.setInstructions(createMeterInstructions().build());
272 flow.setMatch(createMatch1().build());
273 flow.setInstructions(createAppyActionInstruction1().build());
277 flow.setMatch(createMatch1().build());
278 flow.setInstructions(createAppyActionInstruction2().build());
282 flow.setMatch(createMatch1().build());
283 flow.setInstructions(createAppyActionInstruction3().build());
287 flow.setMatch(createMatch1().build());
288 flow.setInstructions(createAppyActionInstruction4().build());
292 flow.setMatch(createMatch1().build());
293 flow.setInstructions(createAppyActionInstruction5().build());
297 flow.setMatch(createMatch1().build());
298 flow.setInstructions(createAppyActionInstruction6().build());
302 flow.setMatch(createMatch1().build());
303 flow.setInstructions(createAppyActionInstruction7().build());
307 flow.setMatch(createMatch1().build());
308 flow.setInstructions(createAppyActionInstruction8().build());
312 flow.setMatch(createMatch1().build());
313 flow.setInstructions(createAppyActionInstruction9().build());
317 flow.setMatch(createMatch1().build());
318 flow.setInstructions(createAppyActionInstruction10().build());
322 flow.setMatch(createMatch1().build());
323 flow.setInstructions(createAppyActionInstruction11().build());
327 flow.setMatch(createMatch1().build());
328 flow.setInstructions(createAppyActionInstruction12().build());
332 flow.setMatch(createMatch1().build());
333 flow.setInstructions(createAppyActionInstruction13().build());
337 flow.setMatch(createMatch1().build());
338 flow.setInstructions(createAppyActionInstruction14().build());
342 flow.setMatch(createMatch1().build());
343 flow.setInstructions(createAppyActionInstruction15().build());
347 // f23 can be used as test-case for generating error notification
348 // if the particular group is not configured - tested
349 flow.setMatch(createMatch1().build());
350 flow.setInstructions(createAppyActionInstruction16().build());
354 flow.setMatch(createMatch1().build());
355 flow.setInstructions(createAppyActionInstruction17().build());
359 flow.setMatch(createMatch1().build());
360 flow.setInstructions(createAppyActionInstruction18().build());
364 flow.setMatch(createMatch1().build());
365 flow.setInstructions(createAppyActionInstruction19().build());
369 flow.setMatch(createMatch1().build());
370 flow.setInstructions(createMetadataInstructions().build());
374 flow.setMatch(createMatch1().build());
375 flow.setInstructions(createAppyActionInstruction20().build());
379 flow.setMatch(createMatch1().build());
380 flow.setInstructions(createAppyActionInstruction21().build());
384 flow.setMatch(createMatch1().build());
385 flow.setInstructions(createAppyActionInstruction22().build());
389 flow.setMatch(createMatch1().build());
390 flow.setInstructions(createAppyActionInstruction23(nodeBuilder.getId()).build());
394 flow.setMatch(createMatch1().build());
395 flow.setInstructions(createAppyActionInstruction24().build());
399 flow.setMatch(createMatch1().build());
400 flow.setInstructions(createAppyActionInstruction25().build());
404 flow.setMatch(createMatch1().build());
405 flow.setInstructions(createAppyActionInstruction26().build());
409 flow.setMatch(createMatch1().build());
410 flow.setInstructions(createAppyActionInstruction27().build());
414 flow.setMatch(createMatch1().build());
415 flow.setInstructions(createAppyActionInstruction28().build());
419 flow.setMatch(createMatch1().build());
420 flow.setInstructions(createAppyActionInstruction29().build());
424 flow.setMatch(createMatch1().build());
425 flow.setInstructions(createAppyActionInstruction30().build());
429 flow.setMatch(createMatch1().build());
430 flow.setInstructions(createAppyActionInstruction31().build());
434 flow.setMatch(createMatch1().build());
435 flow.setInstructions(createAppyActionInstruction32().build());
439 flow.setMatch(createMatch1().build());
440 flow.setInstructions(createAppyActionInstruction33().build());
444 flow.setMatch(createMatch1().build());
445 flow.setInstructions(createAppyActionInstruction34().build());
449 flow.setMatch(createICMPv6Match().build());
450 flow.setInstructions(createDecNwTtlInstructions().build());
454 flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
455 flow.setInstructions(createDropInstructions().build());
459 flow.setMatch(createMetadataMatch().build());
460 flow.setInstructions(createDropInstructions().build());
464 flow.setMatch(createL3IPv6Match().build());
465 flow.setInstructions(createDecNwTtlInstructions().build());
469 flow.setMatch(createL4SCTPMatch().build());
470 flow.setInstructions(createAppyActionInstruction().build());
474 flow.setMatch(createTunnelIDMatch().build());
475 flow.setInstructions(createGotoTableInstructions().build());
479 flow.setMatch(createVlanMatch().build());
480 flow.setInstructions(createMeterInstructions().build());
484 flow.setMatch(createPbbMatch().build());
485 flow.setInstructions(createMeterInstructions().build());
489 flow.setMatch(createVlanMatch().build());
490 flow.setInstructions(createDropInstructions().build());
494 flow.setMatch(createL4TCPMatch().build());
495 flow.setInstructions(createDropInstructions().build());
500 flow.setMatch(createL4UDPMatch().build());
501 flow.setInstructions(createDropInstructions().build());
505 flow.setMatch(new MatchBuilder().build());
506 flow.setInstructions(createSentToControllerInstructions().build());
507 flow.setPriority(Uint16.ZERO);
511 flow.setMatch(createToSMatch().build());
512 flow.setInstructions(createDropInstructions().build());
516 flow.setMatch(createToSMatch().build());
517 flow.setInstructions(createOutputInstructions("INPORT", Uint16.TEN).build());
521 flow.setMatch(createToSMatch().build());
522 flow.setInstructions(createOutputInstructions("FLOOD", Uint16.valueOf(20)).build());
526 flow.setMatch(createToSMatch().build());
527 flow.setInstructions(createOutputInstructions("ALL", Uint16.valueOf(30)).build());
531 flow.setMatch(createToSMatch().build());
532 flow.setInstructions(createOutputInstructions("NORMAL", Uint16.valueOf(40)).build());
536 flow.setMatch(createToSMatch().build());
537 flow.setInstructions(createOutputInstructions("LOCAL", Uint16.valueOf(50)).build());
541 flow.setMatch(createToSMatch().build());
542 flow.setInstructions(createOutputInstructions("TABLE", Uint16.valueOf(60)).build());
546 flow.setMatch(createToSMatch().build());
547 flow.setInstructions(createOutputInstructions("NONE", Uint16.valueOf(70)).build());
551 flow.setMatch(createToSMatch().build());
552 flow.setInstructions(createStripVlanInstructions().build());
553 flow.setBarrier(Boolean.TRUE);
557 flow.setMatch(createMatch1().build());
558 flow.setInstructions(createAppyActionInstruction35().build());
562 flow.setMatch(createMatch1().build());
563 flow.setInstructions(createAppyActionInstruction36().build());
567 flow.setMatch(createMatch1().build());
568 flow.setInstructions(createAppyActionInstruction37().build());
572 flow.setMatch(createMatch1().build());
573 flow.setInstructions(createAppyActionInstruction38().build());
577 flow.setMatch(createL4TCPMatch().build());
578 flow.setInstructions(createAppyActionInstruction39().build());
582 flow.setMatch(createL4UDPMatch().build());
583 flow.setInstructions(createAppyActionInstruction40().build());
587 flow.setMatch(createL4SCTPMatch().build());
588 flow.setInstructions(createAppyActionInstruction41().build());
592 flow.setMatch(createICMPv4Match().build());
593 flow.setInstructions(createAppyActionInstruction42().build());
597 flow.setMatch(createArpMatch().build());
598 flow.setInstructions(createAppyActionInstruction43().build());
602 flow.setMatch(createL3IPv6Match().build());
603 flow.setInstructions(createAppyActionInstruction44().build());
607 flow.setMatch(createICMPv6Match().build());
608 flow.setInstructions(createAppyActionInstruction45().build());
612 flow.setMatch(createMplsMatch().build());
613 flow.setInstructions(createAppyActionInstruction46().build());
617 flow.setMatch(createPbbMatch().build());
618 flow.setInstructions(createAppyActionInstruction47().build());
622 flow.setMatch(createTunnelIDMatch().build());
623 flow.setInstructions(createAppyActionInstruction48().build());
627 flow.setMatch(createMatch33().build());
628 flow.setInstructions(createDropInstructions().build());
632 flow.setMatch(createICMPv6Match1().build());
633 flow.setInstructions(createDecNwTtlInstructions().build());
637 flow.setMatch(createVlanMatch().build());
638 flow.setInstructions(createAppyActionInstruction88().build());
642 flow.setMatch(createLLDPMatch().build());
643 flow.setInstructions(createSentToControllerInstructions().build());
647 flow.setMatch(createToSMatch().build());
648 flow.setInstructions(createOutputInstructions().build());
651 // Test TCP_Flag Match
653 flow.setMatch(createTcpFlagMatch().build());
654 flow.setInstructions(createDropInstructions().build());
658 // match vlan=10,dl_vlan_pcp=3
659 flow.setMatch(createVlanMatch().build());
661 flow.setInstructions(createAppyActionInstruction88().build());
664 // Test Tunnel IPv4 Src (e.g. set_field:172.16.100.200->tun_src)
666 flow.setMatch(createMatch3().build());
667 flow.setInstructions(createTunnelIpv4SrcInstructions().build());
670 // Test Tunnel IPv4 Dst (e.g. set_field:172.16.100.100->tun_dst)
672 flow.setMatch(createMatch1().build());
673 flow.setInstructions(createTunnelIpv4DstInstructions().build());
676 LOG.warn("flow type not understood: {}", flowType);
679 if (flow.getBarrier() == null) {
680 flow.setBarrier(Boolean.FALSE);
684 .setCookie(new FlowCookie(Uint64.TEN))
685 .setCookieMask(new FlowCookie(Uint64.TEN))
686 .setHardTimeout(Uint16.ZERO)
687 .setIdleTimeout(Uint16.ZERO)
690 .setContainerName(null)
691 .setFlags(new FlowModFlags(false, false, false, false, true))
692 .setId(new FlowId("12"))
693 .setTableId(getTableId(tableId))
694 .withKey(new FlowKey(new FlowId(Long.toString(id))))
695 .setFlowName(ORIGINAL_FLOW_NAME + "X" + flowType);
698 private static FlowBuilder createTestFlowPerfTest(final String flowTypeArg, final String tableId, final int id) {
699 String flowType = flowTypeArg;
702 if (flowType == null) {
706 final FlowBuilder flow = new FlowBuilder()
707 .setPriority(Uint16.valueOf(flowId));
712 flow.setMatch(createMatch1().build());
713 flow.setInstructions(createDecNwTtlInstructions().build());
716 LOG.warn("flow type not understood: {}", flowType);
719 if (flow.getBarrier() == null) {
720 flow.setBarrier(Boolean.FALSE);
724 .setCookie(new FlowCookie(Uint64.TEN))
725 .setCookieMask(new FlowCookie(Uint64.TEN))
726 .setHardTimeout(Uint16.ZERO)
727 .setIdleTimeout(Uint16.ZERO)
730 .setContainerName(null)
731 .setFlags(new FlowModFlags(false, false, false, false, true))
732 .setId(new FlowId("12"))
733 .setTableId(getTableId(tableId))
734 .withKey(new FlowKey(new FlowId(Long.toString(flowId))))
735 .setFlowName(ORIGINAL_FLOW_NAME + "X" + flowType);
738 private static FlowBuilder createtablemiss() {
739 return new FlowBuilder()
740 .setMatch(new MatchBuilder().build())
741 .setInstructions(createSentToControllerInstructions().build())
742 .setPriority(Uint16.ZERO)
743 .setTableId(Uint8.ZERO)
744 .withKey(new FlowKey(new FlowId("456")));
747 private static Uint8 getTableId(final String tableId) {
748 Uint8 table = Uint8.TWO;
750 if (tableId == null) {
755 table = Uint8.valueOf(tableId);
756 } catch (NumberFormatException ex) {
757 LOG.info("Parsing String tableId {} failed. Continuing with default tableId {}.",
763 private static InstructionsBuilder createDecNwTtlInstructions() {
764 return new InstructionsBuilder()
765 .setInstruction(BindingMap.of(new InstructionBuilder()
767 .setInstruction(new ApplyActionsCaseBuilder()
768 .setApplyActions(new ApplyActionsBuilder()
769 .setAction(BindingMap.of(new ActionBuilder()
771 .setAction(new DecNwTtlCaseBuilder().setDecNwTtl(new DecNwTtlBuilder().build()).build())
778 private static InstructionsBuilder createMeterInstructions() {
779 return new InstructionsBuilder()
780 .setInstruction(BindingMap.of(new InstructionBuilder()
782 .setInstruction(new MeterCaseBuilder()
783 .setMeter(new MeterBuilder().setMeterId(new MeterId(Uint32.ONE)).build())
788 private static InstructionsBuilder createMetadataInstructions() {
789 return new InstructionsBuilder()
790 .setInstruction(BindingMap.of(new InstructionBuilder()
791 .withKey(new InstructionKey(0))
792 .setInstruction(new WriteMetadataCaseBuilder()
793 .setWriteMetadata(new WriteMetadataBuilder()
794 .setMetadata(Uint64.TEN).setMetadataMask(Uint64.TEN)
800 private static InstructionsBuilder createGotoTableInstructions() {
801 return new InstructionsBuilder()
802 .setInstruction(BindingMap.of(new InstructionBuilder()
804 .setInstruction(new GoToTableCaseBuilder()
805 .setGoToTable(new GoToTableBuilder().setTableId(Uint8.valueOf(5)).build())
810 private static InstructionsBuilder createDropInstructions() {
811 // Wrap our Apply Action in an Instruction
812 return new InstructionsBuilder()
813 .setInstruction(BindingMap.of(new InstructionBuilder()
815 .setInstruction(new ApplyActionsCaseBuilder()
816 .setApplyActions(new ApplyActionsBuilder()
817 .setAction(BindingMap.of(new ActionBuilder()
818 .withKey(new ActionKey(0))
819 .setAction(new DropActionCaseBuilder()
820 .setDropAction(new DropActionBuilder().build())
828 private static InstructionsBuilder createAppyActionInstruction() {
829 return new InstructionsBuilder()
830 .setInstruction(BindingMap.of(new InstructionBuilder()
832 .setInstruction(new ApplyActionsCaseBuilder()
833 .setApplyActions(new ApplyActionsBuilder()
834 .setAction(BindingMap.of(new ActionBuilder()
836 .setAction(new ControllerActionCaseBuilder()
837 .setControllerAction(new ControllerActionBuilder()
838 .setMaxLength(Uint16.valueOf(5))
847 private static InstructionsBuilder createAppyActionInstruction1() {
848 return new InstructionsBuilder()
849 .setInstruction(BindingMap.of(new InstructionBuilder()
851 .setInstruction(new ApplyActionsCaseBuilder()
852 .setApplyActions(new ApplyActionsBuilder()
853 .setAction(BindingMap.of(new ActionBuilder()
855 .setAction(new OutputActionCaseBuilder()
856 .setOutputAction(new OutputActionBuilder()
857 .setMaxLength(Uint16.valueOf(56))
858 .setOutputNodeConnector(new Uri("PCEP"))
867 private static InstructionsBuilder createOutputInstructions() {
868 // test case for Output Port works if the particular port exists
869 // this particular test-case is for Port : 1
870 // tested as (addMDFlow openflow:<dpid> f82)
871 return new InstructionsBuilder()
872 .setInstruction(BindingMap.of(new InstructionBuilder()
874 .setInstruction(new ApplyActionsCaseBuilder()
875 .setApplyActions(new ApplyActionsBuilder()
876 .setAction(BindingMap.of(new ActionBuilder()
878 .setAction(new OutputActionCaseBuilder()
879 .setOutputAction(new OutputActionBuilder().setOutputNodeConnector(new Uri("1")).build())
887 private static InstructionsBuilder createOutputInstructions(final String outputType, final Uint16 outputValue) {
888 return new InstructionsBuilder()
889 .setInstruction(BindingMap.of(new InstructionBuilder()
891 .setInstruction(new ApplyActionsCaseBuilder()
892 .setApplyActions(new ApplyActionsBuilder()
893 .setAction(BindingMap.of(new ActionBuilder()
895 .setAction(new OutputActionCaseBuilder()
896 .setOutputAction(new OutputActionBuilder()
897 .setMaxLength(outputValue)
898 .setOutputNodeConnector(new Uri(outputType))
907 private static InstructionsBuilder createSentToControllerInstructions() {
908 return new InstructionsBuilder()
909 .setInstruction(BindingMap.of(new InstructionBuilder()
911 .setInstruction(new ApplyActionsCaseBuilder()
912 .setApplyActions(new ApplyActionsBuilder()
913 .setAction(BindingMap.of(new ActionBuilder()
915 .setAction(new OutputActionCaseBuilder()
916 .setOutputAction(new OutputActionBuilder()
917 .setMaxLength(Uint16.MAX_VALUE)
918 .setOutputNodeConnector(new Uri(OutputPortValues.CONTROLLER.toString()))
927 private static InstructionsBuilder createStripVlanInstructions() {
928 return new InstructionsBuilder()
929 .setInstruction(BindingMap.of(new InstructionBuilder()
931 .setInstruction(new ApplyActionsCaseBuilder()
932 .setApplyActions(new ApplyActionsBuilder()
933 .setAction(BindingMap.of(new ActionBuilder()
935 .setAction(new StripVlanActionCaseBuilder()
936 .setStripVlanAction(new StripVlanActionBuilder().build())
944 private static InstructionsBuilder createAppyActionInstruction2() {
945 return new InstructionsBuilder()
946 .setInstruction(BindingMap.of(new InstructionBuilder()
948 .setInstruction(new ApplyActionsCaseBuilder()
949 .setApplyActions(new ApplyActionsBuilder()
950 .setAction(BindingMap.of(new ActionBuilder()
952 .setAction(new PushMplsActionCaseBuilder()
953 .setPushMplsAction(new PushMplsActionBuilder()
954 .setEthernetType(Uint16.valueOf(0x8847))
963 private static InstructionsBuilder createAppyActionInstruction3() {
964 return new InstructionsBuilder()
965 .setInstruction(BindingMap.of(new InstructionBuilder()
967 .setInstruction(new ApplyActionsCaseBuilder()
968 .setApplyActions(new ApplyActionsBuilder()
969 .setAction(BindingMap.of(new ActionBuilder()
971 .setAction(new PushPbbActionCaseBuilder()
972 .setPushPbbAction(new PushPbbActionBuilder()
973 .setEthernetType(Uint16.valueOf(0x88E7))
982 private static InstructionsBuilder createAppyActionInstruction4() {
983 return new InstructionsBuilder()
984 .setInstruction(BindingMap.of(new InstructionBuilder()
986 .setInstruction(new ApplyActionsCaseBuilder()
987 .setApplyActions(new ApplyActionsBuilder()
988 .setAction(BindingMap.of(new ActionBuilder()
990 .setAction(new PushVlanActionCaseBuilder()
991 .setPushVlanAction(new PushVlanActionBuilder()
992 .setEthernetType(Uint16.valueOf(0x8100))
1001 private static InstructionsBuilder createAppyActionInstruction5() {
1002 return new InstructionsBuilder()
1003 .setInstruction(BindingMap.of(new InstructionBuilder()
1005 .setInstruction(new ApplyActionsCaseBuilder()
1006 .setApplyActions(new ApplyActionsBuilder()
1007 .setAction(BindingMap.of(new ActionBuilder()
1009 .setAction(new SetDlDstActionCaseBuilder()
1010 .setSetDlDstAction(new SetDlDstActionBuilder()
1011 .setAddress(new MacAddress("00:05:b9:7c:81:5f"))
1020 private static InstructionsBuilder createAppyActionInstruction6() {
1021 return new InstructionsBuilder()
1022 .setInstruction(BindingMap.of(new InstructionBuilder()
1024 .setInstruction(new ApplyActionsCaseBuilder()
1025 .setApplyActions(new ApplyActionsBuilder().setAction(BindingMap.of(new ActionBuilder()
1027 .setAction(new SetDlSrcActionCaseBuilder()
1028 .setSetDlSrcAction(new SetDlSrcActionBuilder()
1029 .setAddress(new MacAddress("00:05:b9:7c:81:5f"))
1037 private static InstructionsBuilder createAppyActionInstruction7() {
1038 return new InstructionsBuilder()
1039 .setInstruction(BindingMap.of(new InstructionBuilder()
1041 .setInstruction(new ApplyActionsCaseBuilder()
1042 .setApplyActions(new ApplyActionsBuilder()
1043 .setAction(BindingMap.of(new ActionBuilder()
1045 .setAction(new SetVlanIdActionCaseBuilder()
1046 .setSetVlanIdAction(new SetVlanIdActionBuilder()
1047 .setVlanId(new VlanId(Uint16.valueOf(4000))).build())
1055 private static InstructionsBuilder createAppyActionInstruction8() {
1056 return new InstructionsBuilder()
1057 .setInstruction(BindingMap.of(new InstructionBuilder()
1059 .setInstruction(new ApplyActionsCaseBuilder()
1060 .setApplyActions(new ApplyActionsBuilder()
1061 .setAction(BindingMap.of(new ActionBuilder()
1063 .setAction(new SetVlanPcpActionCaseBuilder()
1064 .setSetVlanPcpAction(new SetVlanPcpActionBuilder()
1065 .setVlanPcp(new VlanPcp(Uint8.TWO))
1074 private static InstructionsBuilder createAppyActionInstruction88() {
1075 return new InstructionsBuilder()
1076 .setInstruction(BindingMap.of(new InstructionBuilder()
1078 .setInstruction(new ApplyActionsCaseBuilder()
1079 .setApplyActions(new ApplyActionsBuilder()
1080 .setAction(BindingMap.of(new ActionBuilder()
1082 .setAction(new SetVlanPcpActionCaseBuilder()
1083 .setSetVlanPcpAction(new SetVlanPcpActionBuilder()
1084 // the code point is a 3-bit(0-7) field representing the frame priority level
1085 .setVlanPcp(new VlanPcp(Uint8.valueOf(4)))
1094 private static InstructionsBuilder createAppyActionInstruction9() {
1095 return new InstructionsBuilder()
1096 .setInstruction(BindingMap.of(new InstructionBuilder()
1098 .setInstruction(new ApplyActionsCaseBuilder()
1099 .setApplyActions(new ApplyActionsBuilder()
1100 .setAction(BindingMap.of(new ActionBuilder()
1102 .setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(new CopyTtlInBuilder().build()).build())
1109 private static InstructionsBuilder createAppyActionInstruction10() {
1110 return new InstructionsBuilder()
1111 .setInstruction(BindingMap.of(new InstructionBuilder()
1113 .setInstruction(new ApplyActionsCaseBuilder()
1114 .setApplyActions(new ApplyActionsBuilder()
1115 .setAction(BindingMap.of(new ActionBuilder()
1117 .setAction(new CopyTtlOutCaseBuilder()
1118 .setCopyTtlOut(new CopyTtlOutBuilder().build())
1126 private static InstructionsBuilder createAppyActionInstruction11() {
1127 return new InstructionsBuilder()
1128 .setInstruction(BindingMap.of(new InstructionBuilder()
1130 .setInstruction(new ApplyActionsCaseBuilder()
1131 .setApplyActions(new ApplyActionsBuilder()
1132 .setAction(BindingMap.of(new ActionBuilder()
1134 .setAction(new DecMplsTtlCaseBuilder()
1135 .setDecMplsTtl(new DecMplsTtlBuilder().build())
1143 private static InstructionsBuilder createAppyActionInstruction12() {
1144 return new InstructionsBuilder()
1145 .setInstruction(BindingMap.of(new InstructionBuilder()
1147 .setInstruction(new ApplyActionsCaseBuilder()
1148 .setApplyActions(new ApplyActionsBuilder()
1149 .setAction(BindingMap.of(new ActionBuilder()
1151 .setAction(new DecNwTtlCaseBuilder().setDecNwTtl(new DecNwTtlBuilder().build()).build())
1158 private static InstructionsBuilder createAppyActionInstruction13() {
1159 return new InstructionsBuilder()
1160 .setInstruction(BindingMap.of(new InstructionBuilder()
1162 .setInstruction(new ApplyActionsCaseBuilder()
1163 .setApplyActions(new ApplyActionsBuilder()
1164 .setAction(BindingMap.of(new ActionBuilder()
1166 .setAction(new DropActionCaseBuilder()
1167 .setDropAction(new DropActionBuilder().build())
1175 private static InstructionsBuilder createAppyActionInstruction14() {
1176 return new InstructionsBuilder()
1177 .setInstruction(BindingMap.of(new InstructionBuilder()
1179 .setInstruction(new ApplyActionsCaseBuilder()
1180 .setApplyActions(new ApplyActionsBuilder()
1181 .setAction(BindingMap.of(new ActionBuilder()
1183 .setAction(new FloodActionCaseBuilder()
1184 .setFloodAction(new FloodActionBuilder().build())
1192 private static InstructionsBuilder createAppyActionInstruction15() {
1193 return new InstructionsBuilder()
1194 .setInstruction(BindingMap.of(new InstructionBuilder()
1196 .setInstruction(new ApplyActionsCaseBuilder()
1197 .setApplyActions(new ApplyActionsBuilder()
1198 .setAction(BindingMap.of(new ActionBuilder()
1200 .setAction(new FloodAllActionCaseBuilder()
1201 .setFloodAllAction(new FloodAllActionBuilder().build())
1209 private static InstructionsBuilder createAppyActionInstruction16() {
1210 return new InstructionsBuilder()
1211 .setInstruction(BindingMap.of(new InstructionBuilder()
1213 .setInstruction(new ApplyActionsCaseBuilder()
1214 .setApplyActions(new ApplyActionsBuilder()
1215 .setAction(BindingMap.of(new ActionBuilder()
1217 .setAction(new GroupActionCaseBuilder()
1218 .setGroupAction(new GroupActionBuilder().setGroupId(Uint32.ONE).setGroup("0").build())
1226 private static InstructionsBuilder createAppyActionInstruction17() {
1227 return new InstructionsBuilder()
1228 .setInstruction(BindingMap.of(new InstructionBuilder()
1230 .setInstruction(new ApplyActionsCaseBuilder()
1231 .setApplyActions(new ApplyActionsBuilder()
1232 .setAction(BindingMap.of(new ActionBuilder()
1234 .setAction(new HwPathActionCaseBuilder()
1235 .setHwPathAction(new HwPathActionBuilder().build())
1243 private static InstructionsBuilder createAppyActionInstruction18() {
1244 return new InstructionsBuilder()
1245 .setInstruction(BindingMap.of(new InstructionBuilder()
1247 .setInstruction(new ApplyActionsCaseBuilder()
1248 .setApplyActions(new ApplyActionsBuilder()
1249 .setAction(BindingMap.of(new ActionBuilder()
1251 .setAction(new LoopbackActionCaseBuilder()
1252 .setLoopbackAction(new LoopbackActionBuilder().build())
1260 private static InstructionsBuilder createAppyActionInstruction19() {
1261 return new InstructionsBuilder()
1262 .setInstruction(BindingMap.of(new InstructionBuilder()
1264 .setInstruction(new ApplyActionsCaseBuilder()
1265 .setApplyActions(new ApplyActionsBuilder()
1266 .setAction(BindingMap.of(new ActionBuilder()
1268 .setAction(new PopMplsActionCaseBuilder()
1269 .setPopMplsAction(new PopMplsActionBuilder()
1270 .setEthernetType(Uint16.valueOf(0xB))
1279 private static InstructionsBuilder createAppyActionInstruction20() {
1280 return new InstructionsBuilder()
1281 .setInstruction(BindingMap.of(new InstructionBuilder()
1283 .setInstruction(new ApplyActionsCaseBuilder()
1284 .setApplyActions(new ApplyActionsBuilder()
1285 .setAction(BindingMap.of(new ActionBuilder()
1287 .setAction(new PopPbbActionCaseBuilder()
1288 .setPopPbbAction(new PopPbbActionBuilder().build())
1296 private static InstructionsBuilder createAppyActionInstruction21() {
1297 return new InstructionsBuilder()
1298 .setInstruction(BindingMap.of(new InstructionBuilder()
1300 .setInstruction(new ApplyActionsCaseBuilder()
1301 .setApplyActions(new ApplyActionsBuilder()
1302 .setAction(BindingMap.of(new ActionBuilder()
1304 .setAction(new PopVlanActionCaseBuilder()
1305 .setPopVlanAction(new PopVlanActionBuilder().build())
1313 private static InstructionsBuilder createAppyActionInstruction22() {
1314 return new InstructionsBuilder()
1315 .setInstruction(BindingMap.of(new InstructionBuilder()
1317 .setInstruction(new ApplyActionsCaseBuilder()
1318 .setApplyActions(new ApplyActionsBuilder()
1319 .setAction(BindingMap.of(new ActionBuilder()
1321 .setAction(new SetDlTypeActionCaseBuilder()
1322 .setSetDlTypeAction(new SetDlTypeActionBuilder()
1323 .setDlType(new EtherType(Uint32.valueOf(8)))
1332 private static InstructionsBuilder createAppyActionInstruction23(final NodeId nodeId) {
1333 return new InstructionsBuilder()
1334 .setInstruction(BindingMap.of(new InstructionBuilder()
1336 .setInstruction(new ApplyActionsCaseBuilder()
1337 .setApplyActions(new ApplyActionsBuilder()
1338 .setAction(BindingMap.of(new ActionBuilder().setOrder(0).build()))
1344 private static InstructionsBuilder createAppyActionInstruction24() {
1345 return new InstructionsBuilder()
1346 .setInstruction(BindingMap.of(new InstructionBuilder()
1348 .setInstruction(new ApplyActionsCaseBuilder()
1349 .setApplyActions(new ApplyActionsBuilder()
1350 .setAction(BindingMap.of(new ActionBuilder()
1352 .setAction(new SetMplsTtlActionCaseBuilder()
1353 .setSetMplsTtlAction(new SetMplsTtlActionBuilder().setMplsTtl(Uint8.ONE).build())
1361 private static InstructionsBuilder createAppyActionInstruction25() {
1362 return new InstructionsBuilder()
1363 .setInstruction(BindingMap.of(new InstructionBuilder()
1365 .setInstruction(new ApplyActionsCaseBuilder()
1366 .setApplyActions(new ApplyActionsBuilder()
1367 .setAction(BindingMap.of(new ActionBuilder()
1369 .setAction(new SetNextHopActionCaseBuilder()
1370 .setSetNextHopAction(new SetNextHopActionBuilder()
1371 .setAddress(new Ipv4Builder().setIpv4Address(new Ipv4Prefix(IPV4_PREFIX)).build())
1380 private static InstructionsBuilder createAppyActionInstruction26() {
1381 return new InstructionsBuilder()
1382 .setInstruction(BindingMap.of(new InstructionBuilder()
1384 .setInstruction(new ApplyActionsCaseBuilder()
1385 .setApplyActions(new ApplyActionsBuilder()
1386 .setAction(BindingMap.of(new ActionBuilder()
1388 .setAction(new SetNwDstActionCaseBuilder()
1389 .setSetNwDstAction(new SetNwDstActionBuilder()
1390 .setAddress(new Ipv4Builder()
1391 .setIpv4Address(new Ipv4Prefix("10.0.0.21/24"))
1401 private static InstructionsBuilder createAppyActionInstruction27() {
1402 return new InstructionsBuilder()
1403 .setInstruction(BindingMap.of(new InstructionBuilder()
1405 .setInstruction(new ApplyActionsCaseBuilder()
1406 .setApplyActions(new ApplyActionsBuilder()
1407 .setAction(BindingMap.of(new ActionBuilder()
1409 .setAction(new SetNwSrcActionCaseBuilder()
1410 .setSetNwSrcAction(new SetNwSrcActionBuilder()
1411 .setAddress(new Ipv4Builder()
1412 .setIpv4Address(new Ipv4Prefix("10.0.23.21/24"))
1422 private static InstructionsBuilder createAppyActionInstruction28() {
1423 return new InstructionsBuilder()
1424 .setInstruction(BindingMap.of(new InstructionBuilder()
1426 .setInstruction(new ApplyActionsCaseBuilder()
1427 .setApplyActions(new ApplyActionsBuilder()
1428 .setAction(BindingMap.of(new ActionBuilder()
1430 .setAction(new SetNwTosActionCaseBuilder()
1431 .setSetNwTosAction(new SetNwTosActionBuilder().setTos(8).build())
1439 private static InstructionsBuilder createAppyActionInstruction29() {
1440 return new InstructionsBuilder()
1441 .setInstruction(BindingMap.of(new InstructionBuilder()
1443 .setInstruction(new ApplyActionsCaseBuilder()
1444 .setApplyActions(new ApplyActionsBuilder()
1445 .setAction(BindingMap.of(new ActionBuilder()
1447 .setAction(new SetNwTtlActionCaseBuilder()
1448 .setSetNwTtlAction(new SetNwTtlActionBuilder().setNwTtl(Uint8.ONE).build())
1456 private static InstructionsBuilder createAppyActionInstruction30() {
1457 return new InstructionsBuilder()
1458 .setInstruction(BindingMap.of(new InstructionBuilder()
1460 .setInstruction(new ApplyActionsCaseBuilder()
1461 .setApplyActions(new ApplyActionsBuilder()
1462 .setAction(BindingMap.of(new ActionBuilder()
1464 .setAction(new SetQueueActionCaseBuilder()
1465 .setSetQueueAction(new SetQueueActionBuilder().setQueueId(Uint32.ONE).build())
1473 private static InstructionsBuilder createAppyActionInstruction31() {
1474 return new InstructionsBuilder()
1475 .setInstruction(BindingMap.of(new InstructionBuilder()
1477 .setInstruction(new ApplyActionsCaseBuilder()
1478 .setApplyActions(new ApplyActionsBuilder()
1479 .setAction(BindingMap.of(new ActionBuilder()
1481 .setAction(new SetTpDstActionCaseBuilder()
1482 .setSetTpDstAction(new SetTpDstActionBuilder()
1483 .setPort(new PortNumber(Uint16.valueOf(109)))
1492 private static InstructionsBuilder createAppyActionInstruction32() {
1493 return new InstructionsBuilder()
1494 .setInstruction(BindingMap.of(new InstructionBuilder()
1496 .setInstruction(new ApplyActionsCaseBuilder()
1497 .setApplyActions(new ApplyActionsBuilder()
1498 .setAction(BindingMap.of(new ActionBuilder()
1500 .setAction(new SetTpSrcActionCaseBuilder()
1501 .setSetTpSrcAction(new SetTpSrcActionBuilder()
1502 .setPort(new PortNumber(Uint16.valueOf(109)))
1511 private static InstructionsBuilder createAppyActionInstruction33() {
1512 return new InstructionsBuilder()
1513 .setInstruction(BindingMap.of(new InstructionBuilder()
1515 .setInstruction(new ApplyActionsCaseBuilder()
1516 .setApplyActions(new ApplyActionsBuilder()
1517 .setAction(BindingMap.of(new ActionBuilder()
1519 .setAction(new SetVlanCfiActionCaseBuilder()
1520 .setSetVlanCfiAction(new SetVlanCfiActionBuilder().setVlanCfi(new VlanCfi(2)).build())
1528 private static InstructionsBuilder createAppyActionInstruction34() {
1529 return new InstructionsBuilder()
1530 .setInstruction(BindingMap.of(new InstructionBuilder()
1532 .setInstruction(new ApplyActionsCaseBuilder()
1533 .setApplyActions(new ApplyActionsBuilder()
1534 .setAction(BindingMap.of(new ActionBuilder()
1536 .setAction(new SwPathActionCaseBuilder()
1537 .setSwPathAction(new SwPathActionBuilder().build())
1545 private static InstructionsBuilder createAppyActionInstruction35() {
1547 return new InstructionsBuilder()
1548 .setInstruction(BindingMap.of(new InstructionBuilder()
1550 .setInstruction(new ApplyActionsCaseBuilder()
1551 .setApplyActions(new ApplyActionsBuilder()
1552 .setAction(BindingMap.of(new ActionBuilder()
1554 .setAction(new SetFieldCaseBuilder()
1555 .setSetField(new SetFieldBuilder()
1556 .setEthernetMatch(new EthernetMatchBuilder()
1557 .setEthernetSource(new EthernetSourceBuilder()
1558 .setAddress(new MacAddress("00:00:00:00:00:01"))
1563 .build(), new ActionBuilder()
1565 .setAction(new SetFieldCaseBuilder()
1566 .setSetField(new SetFieldBuilder()
1567 .setEthernetMatch(new EthernetMatchBuilder()
1568 .setEthernetDestination(new EthernetDestinationBuilder()
1569 .setAddress(new MacAddress("00:00:00:00:00:02"))
1574 .build(), new ActionBuilder()
1576 .setAction(new SetFieldCaseBuilder()
1577 .setSetField(new SetFieldBuilder()
1578 .setEthernetMatch(new EthernetMatchBuilder()
1579 .setEthernetType(new EthernetTypeBuilder()
1580 .setType(new EtherType(Uint32.valueOf(0x86dd))).build())
1590 private static InstructionsBuilder createAppyActionInstruction36() {
1591 return new InstructionsBuilder()
1592 .setInstruction(BindingMap.of(new InstructionBuilder()
1594 .setInstruction(new ApplyActionsCaseBuilder()
1595 .setApplyActions(new ApplyActionsBuilder()
1596 .setAction(BindingMap.of(new ActionBuilder()
1598 .setAction(new SetFieldCaseBuilder().setSetField(new SetFieldBuilder()
1599 .setVlanMatch(new VlanMatchBuilder()
1600 .setVlanPcp(new VlanPcp(Uint8.valueOf(3)))
1602 .build()).build()).build(), new ActionBuilder()
1604 .setAction(new SetFieldCaseBuilder().setSetField(new SetFieldBuilder()
1605 .setVlanMatch(new VlanMatchBuilder()
1606 .setVlanId(new VlanIdBuilder()
1607 .setVlanId(new VlanId(Uint16.TEN))
1608 .setVlanIdPresent(true)
1619 private static InstructionsBuilder createAppyActionInstruction37() {
1621 return new InstructionsBuilder()
1622 .setInstruction(BindingMap.of(new InstructionBuilder()
1624 .setInstruction(new ApplyActionsCaseBuilder()
1625 .setApplyActions(new ApplyActionsBuilder()
1626 .setAction(BindingMap.of(new ActionBuilder()
1628 .setAction(new SetFieldCaseBuilder()
1629 .setSetField(new SetFieldBuilder()
1630 .setIpMatch(new IpMatchBuilder().setIpDscp(new Dscp(Uint8.valueOf(3))).build())
1633 .build(), new ActionBuilder()
1635 .setAction(new SetFieldCaseBuilder()
1636 .setSetField(new SetFieldBuilder()
1637 .setIpMatch(new IpMatchBuilder().setIpEcn(Uint8.TWO).build())
1640 .build(), new ActionBuilder()
1642 .setAction(new SetFieldCaseBuilder()
1643 .setSetField(new SetFieldBuilder()
1644 .setIpMatch(new IpMatchBuilder().setIpProtocol(Uint8.valueOf(120)).build())
1652 private static InstructionsBuilder createAppyActionInstruction38() {
1654 return new InstructionsBuilder()
1655 .setInstruction(BindingMap.of(new InstructionBuilder()
1657 .setInstruction(new ApplyActionsCaseBuilder()
1658 .setApplyActions(new ApplyActionsBuilder()
1659 .setAction(BindingMap.of(new ActionBuilder()
1661 .setAction(new SetFieldCaseBuilder()
1662 .setSetField(new SetFieldBuilder()
1663 .setLayer3Match(new Ipv4MatchBuilder()
1664 .setIpv4Source(new Ipv4Prefix("100.1.1.1"))
1668 .build(), new ActionBuilder()
1670 .setAction(new SetFieldCaseBuilder()
1671 .setSetField(new SetFieldBuilder()
1672 .setLayer3Match(new Ipv4MatchBuilder()
1673 .setIpv4Destination(new Ipv4Prefix("200.71.9.5210"))
1683 // FIXME: refactor these for brevity
1685 private static InstructionsBuilder createAppyActionInstruction39() {
1686 final ActionBuilder ab = new ActionBuilder();
1687 final ActionBuilder ab1 = new ActionBuilder();
1689 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1690 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1693 final PortNumber tcpsrcport = new PortNumber(Uint16.valueOf(1213));
1694 final PortNumber tcpdstport = new PortNumber(Uint16.valueOf(646));
1695 final TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
1696 final TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder();
1697 tcpmatch.setTcpSourcePort(tcpsrcport);
1698 tcpmatch1.setTcpDestinationPort(tcpdstport);
1699 setFieldBuilder.setLayer4Match(tcpmatch.build());
1700 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1703 setFieldBuilder1.setLayer4Match(tcpmatch1.build());
1704 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1705 ab1.withKey(new ActionKey(1));
1707 return new InstructionsBuilder()
1708 .setInstruction(BindingMap.of(new InstructionBuilder()
1710 .setInstruction(new ApplyActionsCaseBuilder()
1711 .setApplyActions(new ApplyActionsBuilder()
1712 .setAction(BindingMap.of(ab.build(), ab1.build()))
1718 private static InstructionsBuilder createAppyActionInstruction40() {
1719 final ActionBuilder ab = new ActionBuilder();
1720 final ActionBuilder ab1 = new ActionBuilder();
1722 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1723 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1726 final PortNumber udpsrcport = new PortNumber(Uint16.valueOf(1325));
1727 final PortNumber udpdstport = new PortNumber(Uint16.valueOf(42));
1728 final UdpMatchBuilder udpmatch = new UdpMatchBuilder();
1729 final UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
1730 udpmatch.setUdpDestinationPort(udpdstport);
1731 udpmatch1.setUdpSourcePort(udpsrcport);
1732 setFieldBuilder.setLayer4Match(udpmatch.build());
1733 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1736 setFieldBuilder1.setLayer4Match(udpmatch1.build());
1737 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1738 ab1.withKey(new ActionKey(1));
1740 return new InstructionsBuilder()
1741 .setInstruction(BindingMap.of(new InstructionBuilder()
1743 .setInstruction(new ApplyActionsCaseBuilder()
1744 .setApplyActions(new ApplyActionsBuilder()
1745 .setAction(BindingMap.of(ab.build(), ab1.build()))
1751 private static InstructionsBuilder createAppyActionInstruction41() {
1752 final ActionBuilder ab = new ActionBuilder();
1753 final ActionBuilder ab1 = new ActionBuilder();
1755 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1756 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1759 final SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
1760 final SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
1761 final PortNumber srcport = new PortNumber(Uint16.valueOf(1435));
1762 final PortNumber dstport = new PortNumber(Uint16.valueOf(22));
1763 sctpmatch.setSctpSourcePort(srcport);
1764 sctpmatch1.setSctpDestinationPort(dstport);
1765 setFieldBuilder.setLayer4Match(sctpmatch.build());
1766 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1769 setFieldBuilder1.setLayer4Match(sctpmatch1.build());
1770 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1771 ab1.withKey(new ActionKey(1));
1773 return new InstructionsBuilder()
1774 .setInstruction(BindingMap.of(new InstructionBuilder()
1776 .setInstruction(new ApplyActionsCaseBuilder()
1777 .setApplyActions(new ApplyActionsBuilder()
1778 .setAction(BindingMap.of(ab.build(), ab1.build()))
1784 private static InstructionsBuilder createAppyActionInstruction42() {
1785 final ActionBuilder ab = new ActionBuilder();
1786 final ActionBuilder ab1 = new ActionBuilder();
1787 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1788 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1791 final Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
1792 final Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
1793 icmpv4match.setIcmpv4Type(Uint8.valueOf(8));
1794 icmpv4match1.setIcmpv4Code(Uint8.ZERO);
1795 setFieldBuilder.setIcmpv4Match(icmpv4match.build());
1796 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1799 setFieldBuilder1.setIcmpv4Match(icmpv4match1.build());
1800 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1801 ab1.withKey(new ActionKey(1));
1803 return new InstructionsBuilder()
1804 .setInstruction(BindingMap.of(new InstructionBuilder()
1806 .setInstruction(new ApplyActionsCaseBuilder()
1807 .setApplyActions(new ApplyActionsBuilder()
1808 .setAction(BindingMap.of(ab.build(), ab1.build()))
1814 private static InstructionsBuilder createAppyActionInstruction43() {
1815 final ActionBuilder ab = new ActionBuilder();
1816 final ActionBuilder ab1 = new ActionBuilder();
1817 final ActionBuilder ab2 = new ActionBuilder();
1818 final ActionBuilder ab3 = new ActionBuilder();
1819 final ActionBuilder ab4 = new ActionBuilder();
1821 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1822 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1823 final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
1824 final SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
1825 final SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
1827 // setting the values of ARP
1828 final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
1829 final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
1830 final Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52");
1831 final Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1");
1832 // create ARP match action
1833 final ArpMatchBuilder arpmatch = new ArpMatchBuilder();
1834 final ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
1835 final ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
1836 final ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
1837 final ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
1838 final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
1839 arpsrc.setAddress(macsrc);
1840 final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
1841 arpdst.setAddress(macdest);
1842 arpmatch.setArpOp(Uint16.TWO);
1843 arpmatch1.setArpSourceHardwareAddress(arpsrc.build());
1844 arpmatch2.setArpTargetHardwareAddress(arpdst.build());
1845 arpmatch3.setArpSourceTransportAddress(srciparp);
1846 arpmatch4.setArpTargetTransportAddress(dstiparp);
1847 setFieldBuilder.setLayer3Match(arpmatch.build());
1848 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1851 setFieldBuilder1.setLayer3Match(arpmatch1.build());
1852 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1853 ab1.withKey(new ActionKey(1));
1855 setFieldBuilder2.setLayer3Match(arpmatch2.build());
1856 ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
1857 ab2.withKey(new ActionKey(2));
1859 setFieldBuilder3.setLayer3Match(arpmatch3.build());
1860 ab3.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
1861 ab3.withKey(new ActionKey(3));
1863 setFieldBuilder4.setLayer3Match(arpmatch4.build());
1864 ab4.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
1865 ab4.withKey(new ActionKey(4));
1867 return new InstructionsBuilder()
1868 .setInstruction(BindingMap.of(new InstructionBuilder()
1870 .setInstruction(new ApplyActionsCaseBuilder()
1871 .setApplyActions(new ApplyActionsBuilder()
1872 .setAction(BindingMap.of(ab.build(), ab1.build(), ab2.build(), ab3.build(), ab4.build()))
1878 private static InstructionsBuilder createAppyActionInstruction44() {
1879 final ActionBuilder ab = new ActionBuilder();
1880 final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1881 final ActionBuilder ab1 = new ActionBuilder();
1882 final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1883 final ActionBuilder ab5 = new ActionBuilder();
1884 final SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
1885 final ActionBuilder ab6 = new ActionBuilder();
1886 final SetFieldBuilder setFieldBuilder6 = new SetFieldBuilder();
1889 final Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
1890 final Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
1891 final Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
1892 final Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
1894 final Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/128");
1895 final Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/128");
1896 final Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
1897 nextheader.setIpv6Exthdr(Uint16.valueOf(58));
1898 final Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
1899 final Ipv6FlowLabel label = new Ipv6FlowLabel(Uint32.valueOf(10028));
1900 ipv6label.setIpv6Flabel(label);
1902 ipv6Builder.setIpv6Source(srcip6);
1903 ipv6Builder1.setIpv6Destination(dstip6);
1904 ipv6Builder5.setIpv6ExtHeader(nextheader.build());
1905 ipv6Builder6.setIpv6Label(ipv6label.build());
1907 setFieldBuilder.setLayer3Match(ipv6Builder.build());
1908 ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1911 setFieldBuilder1.setLayer3Match(ipv6Builder1.build());
1912 ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1913 ab1.withKey(new ActionKey(1));
1915 setFieldBuilder5.setLayer3Match(ipv6Builder5.build());
1916 ab5.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder5.build()).build());
1917 ab5.withKey(new ActionKey(5));
1919 setFieldBuilder6.setLayer3Match(ipv6Builder6.build());
1920 ab6.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder6.build()).build());
1921 ab6.withKey(new ActionKey(6));
1923 return new InstructionsBuilder()
1924 .setInstruction(BindingMap.of(new InstructionBuilder()
1926 .setInstruction(new ApplyActionsCaseBuilder()
1927 .setApplyActions(new ApplyActionsBuilder()
1928 .setAction(BindingMap.of(ab.build(), ab1.build(), ab5.build(), ab6.build()))
1934 private static InstructionsBuilder createAppyActionInstruction45() {
1936 return new InstructionsBuilder()
1937 .setInstruction(BindingMap.of(new InstructionBuilder()
1939 .setInstruction(new ApplyActionsCaseBuilder()
1940 .setApplyActions(new ApplyActionsBuilder()
1941 .setAction(BindingMap.of(new ActionBuilder()
1943 .setAction(new SetFieldCaseBuilder()
1944 .setSetField(new SetFieldBuilder()
1945 .setIcmpv6Match(new Icmpv6MatchBuilder().setIcmpv6Type(Uint8.valueOf(135)).build())
1948 .build(), new ActionBuilder()
1950 .setAction(new SetFieldCaseBuilder()
1951 .setSetField(new SetFieldBuilder()
1952 .setIcmpv6Match(new Icmpv6MatchBuilder().setIcmpv6Code(Uint8.ZERO).build())
1961 private static InstructionsBuilder createAppyActionInstruction46() {
1963 return new InstructionsBuilder()
1964 .setInstruction(BindingMap.of(new InstructionBuilder()
1966 .setInstruction(new ApplyActionsCaseBuilder()
1967 .setApplyActions(new ApplyActionsBuilder()
1968 .setAction(BindingMap.of(new ActionBuilder()
1970 .setAction(new SetFieldCaseBuilder()
1971 .setSetField(new SetFieldBuilder()
1972 .setProtocolMatchFields(new ProtocolMatchFieldsBuilder()
1973 .setMplsLabel(Uint32.valueOf(36008))
1977 .build(), new ActionBuilder()
1979 .setAction(new SetFieldCaseBuilder()
1980 .setSetField(new SetFieldBuilder()
1981 .setProtocolMatchFields(new ProtocolMatchFieldsBuilder()
1982 .setMplsTc(Uint8.valueOf(4))
1986 .build(), new ActionBuilder()
1988 .setAction(new SetFieldCaseBuilder()
1989 .setSetField(new SetFieldBuilder()
1990 .setProtocolMatchFields(new ProtocolMatchFieldsBuilder()
1991 .setMplsBos(Uint8.ONE)
2001 private static InstructionsBuilder createAppyActionInstruction47() {
2002 return new InstructionsBuilder()
2003 .setInstruction(BindingMap.of(new InstructionBuilder()
2005 .setInstruction(new ApplyActionsCaseBuilder()
2006 .setApplyActions(new ApplyActionsBuilder()
2007 .setAction(BindingMap.of(new ActionBuilder()
2009 .setAction(new SetFieldCaseBuilder()
2010 .setSetField(new SetFieldBuilder()
2011 .setProtocolMatchFields(new ProtocolMatchFieldsBuilder()
2012 .setPbb(new PbbBuilder()
2013 .setPbbIsid(Uint32.valueOf(4))
2014 .setPbbMask(Uint32.valueOf(0x10000))
2025 private static InstructionsBuilder createAppyActionInstruction48() {
2026 return new InstructionsBuilder()
2027 .setInstruction(BindingMap.of(new InstructionBuilder()
2029 .setInstruction(new ApplyActionsCaseBuilder()
2030 .setApplyActions(new ApplyActionsBuilder()
2031 .setAction(BindingMap.of(new ActionBuilder()
2033 .setAction(new SetFieldCaseBuilder()
2034 .setSetField(new SetFieldBuilder()
2036 .setTunnel(new TunnelBuilder().setTunnelId(Uint64.valueOf(10668)).build()).build())
2044 private static InstructionsBuilder createTunnelIpv4DstInstructions() {
2045 return new InstructionsBuilder()
2046 .setInstruction(BindingMap.of(new InstructionBuilder()
2048 .setInstruction(new ApplyActionsCaseBuilder()
2049 .setApplyActions(new ApplyActionsBuilder()
2050 .setAction(BindingMap.of(new ActionBuilder()
2052 .setAction(new SetFieldCaseBuilder()
2053 // Add the IPv4 tunnel dst to the set_field value
2054 .setSetField(new SetFieldBuilder()
2055 .setLayer3Match(new TunnelIpv4MatchBuilder()
2056 // Add the mew IPv4 object as the tunnel destination
2057 .setTunnelIpv4Destination(new Ipv4Prefix("172.16.100.100"))
2067 private static InstructionsBuilder createTunnelIpv4SrcInstructions() {
2068 return new InstructionsBuilder()
2069 .setInstruction(BindingMap.of(new InstructionBuilder()
2071 .setInstruction(new ApplyActionsCaseBuilder()
2072 .setApplyActions(new ApplyActionsBuilder()
2073 .setAction(BindingMap.of(new ActionBuilder()
2075 .setAction(new SetFieldCaseBuilder()
2076 // Add the IPv4 tunnel src to the set_field value
2077 .setSetField(new SetFieldBuilder()
2078 .setLayer3Match(new TunnelIpv4MatchBuilder()
2079 // Add the new IPv4 object as the tunnel destination
2080 .setTunnelIpv4Source(new Ipv4Prefix("172.16.100.200"))
2090 private static MatchBuilder createLLDPMatch() {
2091 final MatchBuilder match = new MatchBuilder();
2092 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2093 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2094 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x88cc)));
2095 eth.setEthernetType(ethTypeBuilder.build());
2096 match.setEthernetMatch(eth.build());
2100 private static MatchBuilder createMatch1() {
2101 final MatchBuilder match = new MatchBuilder();
2102 final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2103 final Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);
2104 ipv4Match.setIpv4Destination(prefix);
2105 final Ipv4Match i4m = ipv4Match.build();
2106 match.setLayer3Match(i4m);
2108 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2109 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2110 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2111 eth.setEthernetType(ethTypeBuilder.build());
2112 match.setEthernetMatch(eth.build());
2116 private static MatchBuilder createMatch2() {
2117 final MatchBuilder match = new MatchBuilder();
2118 final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2119 final Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
2120 ipv4Match.setIpv4Source(prefix);
2121 final Ipv4Match i4m = ipv4Match.build();
2122 match.setLayer3Match(i4m);
2124 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2125 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2126 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2127 eth.setEthernetType(ethTypeBuilder.build());
2128 match.setEthernetMatch(eth.build());
2132 private static MatchBuilder createMatch3() {
2133 final MatchBuilder match = new MatchBuilder();
2134 final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2135 final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2136 ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2137 ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2138 match.setEthernetMatch(ethernetMatch.build());
2143 private static MatchBuilder createICMPv6Match1() {
2144 return new MatchBuilder()
2145 .setEthernetMatch(new EthernetMatchBuilder()
2146 .setEthernetType(new EthernetTypeBuilder()
2147 .setType(new EtherType(Uint32.valueOf(0x86dd)))
2151 .setIpMatch(new IpMatchBuilder().setIpProtocol(Uint8.MAX_VALUE).build())
2153 .setIcmpv6Match(new Icmpv6MatchBuilder()
2154 .setIcmpv6Type(Uint8.valueOf(135))
2155 .setIcmpv6Code(Uint8.ONE)
2159 private static MatchBuilder createMatch33() {
2161 final MatchBuilder match = new MatchBuilder();
2162 final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2163 final Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
2164 ipv4Match.setIpv4Source(prefix);
2165 final Ipv4Match i4m = ipv4Match.build();
2166 match.setLayer3Match(i4m);
2168 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2169 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2170 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0xfffe)));
2171 eth.setEthernetType(ethTypeBuilder.build());
2172 match.setEthernetMatch(eth.build());
2176 private static MatchBuilder createInphyportMatch(final NodeId nodeId) {
2177 final MatchBuilder match = new MatchBuilder();
2178 match.setInPort(new NodeConnectorId(nodeId + ":202"));
2179 match.setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
2183 private static MatchBuilder createEthernetMatch() {
2184 final MatchBuilder match = new MatchBuilder();
2185 final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
2187 final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2188 final EtherType type = new EtherType(Uint32.valueOf(0x0800));
2189 ethmatch.setEthernetType(ethtype.setType(type).build());
2191 final EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
2194 final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
2195 ethdest.setAddress(macdest);
2196 ethdest.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2198 ethmatch.setEthernetDestination(ethdest.build());
2200 final EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
2201 final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
2202 ethsrc.setAddress(macsrc);
2203 ethsrc.setMask(new MacAddress("ff:ff:00:00:00:00"));
2205 ethmatch.setEthernetSource(ethsrc.build());
2206 match.setEthernetMatch(ethmatch.build());
2211 private static MatchBuilder createVlanMatch() {
2212 final MatchBuilder match = new MatchBuilder();
2214 final VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
2215 final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2216 final VlanId vlanId = new VlanId(Uint16.TEN);
2217 final VlanPcp vpcp = new VlanPcp(Uint8.valueOf(3));
2218 vlanBuilder.setVlanPcp(vpcp);
2219 vlanIdBuilder.setVlanId(vlanId);
2220 vlanIdBuilder.setVlanIdPresent(true);
2221 vlanBuilder.setVlanId(vlanIdBuilder.build());
2222 match.setVlanMatch(vlanBuilder.build());
2226 private static MatchBuilder createArpMatch() {
2227 final MatchBuilder match = new MatchBuilder();
2229 final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2230 final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
2231 final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
2233 final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2234 final EtherType type = new EtherType(Uint32.valueOf(0x0806));
2235 ethmatch.setEthernetType(ethtype.setType(type).build());
2238 final Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10");
2239 final Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2242 final ArpMatchBuilder arpmatch = new ArpMatchBuilder();
2243 final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2244 arpsrc.setAddress(macsrc);
2245 arpsrc.setMask(new MacAddress("ff:ff:ff:00:00:00"));
2246 final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2247 arpdst.setAddress(macdest);
2248 arpdst.setMask(new MacAddress("ff:ff:00:00:00:00"));
2249 arpmatch.setArpOp(Uint16.TWO);
2250 arpmatch.setArpSourceHardwareAddress(arpsrc.build());
2251 arpmatch.setArpTargetHardwareAddress(arpdst.build());
2252 arpmatch.setArpSourceTransportAddress(srcip);
2253 arpmatch.setArpTargetTransportAddress(dstip);
2255 match.setEthernetMatch(ethmatch.build());
2256 match.setLayer3Match(arpmatch.build());
2261 private static MatchBuilder createL3IPv6Match() {
2262 final MatchBuilder match = new MatchBuilder();
2264 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2265 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2266 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x86dd)));
2267 eth.setEthernetType(ethTypeBuilder.build());
2268 match.setEthernetMatch(eth.build());
2270 final MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
2271 final MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
2272 final Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2273 final Ipv6FlowLabel label = new Ipv6FlowLabel(Uint32.valueOf(10028));
2274 ipv6label.setIpv6Flabel(label);
2275 ipv6label.setFlabelMask(new Ipv6FlowLabel(Uint32.ONE));
2277 final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2279 icmpv6match.setIcmpv6Type(Uint8.valueOf(135));
2280 icmpv6match.setIcmpv6Code(Uint8.ZERO);
2281 match.setIcmpv6Match(icmpv6match.build());
2283 final Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
2284 // ipv6match.setIpv6Source(srcip6);
2285 // ipv6match.setIpv6Destination(dstip6);
2286 // ipv6match.setIpv6ExtHeader(nextheader.build());
2287 ipv6match.setIpv6NdSll(ndsll);
2288 ipv6match.setIpv6NdTll(ndtll);
2289 // ipv6match.setIpv6NdTarget(ndtarget);
2290 ipv6match.setIpv6Label(ipv6label.build());
2292 match.setLayer3Match(ipv6match.build());
2297 private static MatchBuilder createICMPv4Match() {
2298 final MatchBuilder match = new MatchBuilder();
2299 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2300 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2301 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2302 eth.setEthernetType(ethTypeBuilder.build());
2303 match.setEthernetMatch(eth.build());
2305 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2306 ipmatch.setIpProtocol(Uint8.ONE);
2307 match.setIpMatch(ipmatch.build());
2309 final Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
2311 icmpv4match.setIcmpv4Type(Uint8.valueOf(8));
2312 icmpv4match.setIcmpv4Code(Uint8.ZERO);
2313 match.setIcmpv4Match(icmpv4match.build());
2317 private static MatchBuilder createICMPv6Match() {
2319 final MatchBuilder match = new MatchBuilder();
2320 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2321 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2322 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x86dd)));
2323 eth.setEthernetType(ethTypeBuilder.build());
2324 match.setEthernetMatch(eth.build());
2326 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2327 ipmatch.setIpProtocol(Uint8.valueOf(58));
2328 match.setIpMatch(ipmatch.build());
2330 final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2332 icmpv6match.setIcmpv6Type(Uint8.valueOf(135));
2333 icmpv6match.setIcmpv6Code(Uint8.ONE);
2334 match.setIcmpv6Match(icmpv6match.build());
2339 private static MatchBuilder createToSMatch() {
2340 final MatchBuilder match = new MatchBuilder();
2341 final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2342 final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2343 final EtherType type = new EtherType(Uint32.valueOf(0x0800));
2344 ethmatch.setEthernetType(ethtype.setType(type).build());
2345 match.setEthernetMatch(ethmatch.build());
2347 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2348 ipmatch.setIpProtocol(Uint8.valueOf(6));
2349 final Dscp dscp = new Dscp(Uint8.valueOf(8));
2350 ipmatch.setIpDscp(dscp);
2351 match.setIpMatch(ipmatch.build());
2355 private static MatchBuilder createL4TCPMatch() {
2356 final MatchBuilder match = new MatchBuilder();
2358 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2359 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2360 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2361 eth.setEthernetType(ethTypeBuilder.build());
2362 match.setEthernetMatch(eth.build());
2364 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2365 ipmatch.setIpProtocol(Uint8.valueOf(6));
2366 match.setIpMatch(ipmatch.build());
2368 final PortNumber srcport = new PortNumber(Uint16.valueOf(1213));
2369 final PortNumber dstport = new PortNumber(Uint16.valueOf(646));
2370 final TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
2371 tcpmatch.setTcpSourcePort(srcport);
2372 tcpmatch.setTcpDestinationPort(dstport);
2373 match.setLayer4Match(tcpmatch.build());
2378 private static MatchBuilder createL4UDPMatch() {
2379 final MatchBuilder match = new MatchBuilder();
2381 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2382 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2383 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2384 eth.setEthernetType(ethTypeBuilder.build());
2385 match.setEthernetMatch(eth.build());
2387 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2388 ipmatch.setIpProtocol(Uint8.valueOf(17));
2389 match.setIpMatch(ipmatch.build());
2391 final PortNumber srcport = new PortNumber(Uint16.valueOf(1325));
2392 final PortNumber dstport = new PortNumber(Uint16.valueOf(42));
2393 final UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
2394 udpmatch.setUdpDestinationPort(dstport);
2395 udpmatch.setUdpSourcePort(srcport);
2396 match.setLayer4Match(udpmatch.build());
2401 private static MatchBuilder createL4SCTPMatch() {
2402 final MatchBuilder match = new MatchBuilder();
2404 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2405 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2406 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2407 eth.setEthernetType(ethTypeBuilder.build());
2408 match.setEthernetMatch(eth.build());
2410 final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2411 ipmatch.setIpProtocol(Uint8.valueOf(132));
2412 match.setIpMatch(ipmatch.build());
2414 final SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
2415 final PortNumber srcport = new PortNumber(Uint16.valueOf(1435));
2416 final PortNumber dstport = new PortNumber(Uint16.valueOf(22));
2417 sctpmatch.setSctpSourcePort(srcport);
2418 sctpmatch.setSctpDestinationPort(dstport);
2419 match.setLayer4Match(sctpmatch.build());
2424 private static MatchBuilder createMetadataMatch() {
2425 final MatchBuilder match = new MatchBuilder();
2426 final MetadataBuilder metadata = new MetadataBuilder(); // metadata match
2427 metadata.setMetadata(Uint64.valueOf(500));
2428 metadata.setMetadataMask(Uint64.valueOf(0xFFFFFF00_00000101L));
2429 match.setMetadata(metadata.build());
2434 private static MatchBuilder createMplsMatch() {
2435 final MatchBuilder match = new MatchBuilder();
2437 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2438 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2439 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x8847)));
2440 eth.setEthernetType(ethTypeBuilder.build());
2441 match.setEthernetMatch(eth.build());
2443 final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
2445 protomatch.setMplsLabel(Uint32.valueOf(36008));
2446 protomatch.setMplsTc(Uint8.valueOf(4));
2447 protomatch.setMplsBos(Uint8.ONE);
2448 match.setProtocolMatchFields(protomatch.build());
2454 private static MatchBuilder createPbbMatch() {
2455 final MatchBuilder match = new MatchBuilder();
2457 final EthernetMatchBuilder eth = new EthernetMatchBuilder();
2458 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2459 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x88E7)));
2460 eth.setEthernetType(ethTypeBuilder.build());
2461 match.setEthernetMatch(eth.build());
2463 final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
2465 protomatch.setPbb(new PbbBuilder().setPbbIsid(Uint32.valueOf(4)).setPbbMask(Uint32.valueOf(0x10000)).build());
2466 match.setProtocolMatchFields(protomatch.build());
2472 private static MatchBuilder createTunnelIDMatch() {
2473 final MatchBuilder match = new MatchBuilder();
2474 final TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
2475 tunnel.setTunnelId(Uint64.valueOf(10668));
2476 tunnel.setTunnelMask(Uint64.valueOf(0xFFFFFF00_00000101L));
2477 match.setTunnel(tunnel.build());
2483 * Test match for TCP_Flags.
2485 * @return match containing Ethertype (0x0800), IP Protocol (TCP), TCP_Flag (SYN)
2487 //FIXME: move to extensible support
2488 private static MatchBuilder createTcpFlagMatch() {
2489 final MatchBuilder match = new MatchBuilder();
2492 final EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
2493 final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2494 ethTypeBuilder.setType(new EtherType(Uint32.valueOf(0x0800)));
2495 ethernetType.setEthernetType(ethTypeBuilder.build());
2496 match.setEthernetMatch(ethernetType.build());
2498 // TCP Protocol Match
2499 final IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
2500 ipMatch.setIpProtocol(Uint8.valueOf(6));
2501 match.setIpMatch(ipMatch.build());
2504 final PortNumber dstPort = new PortNumber(Uint16.valueOf(80));
2505 final TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
2506 tcpMatch.setTcpDestinationPort(dstPort);
2507 match.setLayer4Match(tcpMatch.build());
2509 * Defined TCP Flag values in OVS v2.1+
2510 * TCP_FIN 0x001 / TCP_SYN 0x002 / TCP_RST 0x004
2511 * TCP_PSH 0x008 / TCP_ACK 0x010 / TCP_URG 0x020
2512 * TCP_ECE 0x040 / TCP_CWR 0x080 / TCP_NS 0x100
2514 final TcpFlagsMatchBuilder tcpFlagsMatch = new TcpFlagsMatchBuilder();
2515 tcpFlagsMatch.setTcpFlags(Uint16.valueOf(0x002));
2516 match.setTcpFlagsMatch(tcpFlagsMatch.build());
2521 @SuppressWarnings("checkstyle:MethodName")
2522 public void _removeMDFlow(final CommandInterpreter ci) {
2523 final ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
2524 final NodeBuilder tn = createTestNode(ci.nextArgument());
2525 final String flowtype = ci.nextArgument();
2527 if (flowtype.equals("fTM")) {
2528 tf = createtablemiss();
2530 tf = createTestFlow(tn, flowtype, ci.nextArgument());
2532 final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.key())
2533 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
2534 .child(Flow.class, tf.key());
2535 modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
2536 modification.commit().addCallback(new FutureCallback<CommitInfo>() {
2538 public void onSuccess(final CommitInfo notUsed) {
2539 ci.println("Status of Group Data Loaded Transaction: success.");
2543 public void onFailure(final Throwable throwable) {
2544 LOG.error("Status of Group Data Loaded Transaction : failure.", throwable);
2545 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
2547 }, MoreExecutors.directExecutor());
2553 * @param ci arguments: switchId flowType tableNum, e.g.: addMDFlow openflow:1 f1 42
2555 @SuppressWarnings("checkstyle:MethodName")
2556 public void _addMDFlow(final CommandInterpreter ci) {
2557 final NodeBuilder tn = createTestNode(ci.nextArgument());
2558 final String flowtype = ci.nextArgument();
2560 if (flowtype.equals("fTM")) {
2561 tf = createtablemiss();
2563 tf = createTestFlow(tn, flowtype, ci.nextArgument());
2565 writeFlow(ci, tf, tn);
2568 private void writeFlow(final CommandInterpreter ci, final FlowBuilder flow, final NodeBuilder nodeBuilder) {
2569 final ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
2570 final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
2571 .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class)
2572 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.key());
2573 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION,
2574 nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
2575 modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, flow.build());
2576 modification.commit().addCallback(new FutureCallback<CommitInfo>() {
2578 public void onSuccess(final CommitInfo notUsed) {
2579 ci.println("Status of Group Data Loaded Transaction: success.");
2583 public void onFailure(final Throwable throwable) {
2584 LOG.error("Status of Group Data Loaded Transaction : failure.", throwable);
2585 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
2587 }, MoreExecutors.directExecutor());
2590 @SuppressWarnings("checkstyle:MethodName")
2591 public void _modifyMDFlow(final CommandInterpreter ci) {
2592 final NodeBuilder tn = createTestNode(ci.nextArgument());
2593 final FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
2594 tf.setFlowName(UPDATED_FLOW_NAME);
2595 writeFlow(ci, tf, tn);
2596 tf.setFlowName(ORIGINAL_FLOW_NAME);
2597 writeFlow(ci, tf, tn);
2601 public String getHelp() {
2606 * usage testSwitchFlows <numberOfSwitches> <numberOfFlows> <warmup iterations> <Number Of Threads>
2607 * ex: _perfFlowTest 10 5 1 2
2609 @SuppressWarnings("checkstyle:MethodName")
2610 public void _perfFlowTest(final CommandInterpreter ci) {
2612 final String numberOfSwtichesStr = ci.nextArgument();
2613 final String numberOfFlowsStr = ci.nextArgument();
2614 final String warmupIterationsStr = ci.nextArgument();
2615 final String threadCountStr = ci.nextArgument();
2616 final String warmUpStr = ci.nextArgument();
2618 int numberOfSwtiches = 0;
2619 int numberOfFlows = 0;
2620 int warmupIterations = 0;
2621 boolean warmUpIterations = false;
2623 int threadCount = 0;
2624 if (numberOfSwtichesStr != null && !numberOfSwtichesStr.trim().equals("")) {
2625 numberOfSwtiches = Integer.parseInt(numberOfSwtichesStr);
2627 numberOfSwtiches = 2;
2630 if (numberOfFlowsStr != null && !numberOfFlowsStr.trim().equals("")) {
2631 numberOfFlows = Integer.parseInt(numberOfFlowsStr);
2636 if (warmupIterationsStr != null && !warmupIterationsStr.trim().equals("")) {
2637 warmupIterations = Integer.parseInt(warmupIterationsStr);
2639 warmupIterations = 2;
2642 if (threadCountStr != null && !threadCountStr.trim().equals("")) {
2643 threadCount = Integer.parseInt(threadCountStr);
2647 if (warmUpStr != null && !warmUpStr.trim().equals("") && warmUpStr.trim().equals("true")) {
2648 warmUpIterations = true;
2650 warmUpIterations = false;
2652 ci.println("* Test Configurations*");
2653 ci.println("* numberOfSwtiches:::" + numberOfSwtiches + "");
2654 ci.println("* numberOfFlows:::" + numberOfFlows + "");
2655 ci.println("* warmupIterations:::" + warmupIterations + "");
2656 ci.println("* Number of Threads :::" + threadCount + "");
2657 ci.println("* Warmup Required? :::" + warmUpIterations + "");
2659 String dataPath = "openflow:1";
2662 final String tableId = "0";
2663 if (warmUpIterations) {
2664 ci.println("----Warmup Started-----");
2665 for (int j = 1; j <= warmupIterations; j++) {
2666 for (int i = 1; i <= numberOfSwtiches; i++) {
2667 dataPath = "openflow:" + i;
2668 tn = createTestNode(dataPath);
2669 for (int flow = 1; flow < numberOfFlows; flow++) {
2670 tf = createTestFlowPerfTest("f1", tableId, flow);
2671 writeFlow(ci, tf, tn);
2676 ci.println("----Warmup Done-----");
2679 final ExecutorService executor = Executors.newFixedThreadPool(threadCount);
2681 for (int t = 0; t < threadCount; t++) {
2683 final Runnable tRunnable = new TestFlowThread(numberOfSwtiches, numberOfFlows, ci, t, tableID);
2684 executor.execute(tRunnable);
2686 executor.shutdown();
2687 executor.awaitTermination(1, TimeUnit.SECONDS);
2688 } catch (InterruptedException e) {
2689 ci.println("Exception:" + e.getMessage());
2693 public class TestFlowThread implements Runnable {
2695 int numberOfSwitches;
2697 CommandInterpreter ci;
2701 TestFlowThread(final int numberOfSwtiches, final int numberOfFlows, final CommandInterpreter ci,
2702 final int threadNumber, final int tableID) {
2703 numberOfSwitches = numberOfSwtiches;
2704 this.numberOfFlows = numberOfFlows;
2706 theadNumber = threadNumber;
2707 this.tableID = tableID;
2715 public void executeFlow() {
2717 String dataPath = "openflow:1";
2720 //String tableId = "0";
2722 ci.println("New Thread started with id: ID_" + theadNumber);
2723 int totalNumberOfFlows = 0;
2724 final long startTime = System.currentTimeMillis();
2726 for (int i = 1; i <= numberOfSwitches; i++) {
2727 dataPath = "openflow:" + i;
2728 tn = createTestNode(dataPath);
2729 for (int flow2 = 1; flow2 <= numberOfFlows; flow2++) {
2730 tf = createTestFlowPerfTest("f1", "" + tableID, flow2);
2731 writeFlow(ci, tf, tn);
2732 totalNumberOfFlows++;
2735 final long endTime = System.currentTimeMillis();
2736 final long timeInSeconds = Math.round((endTime - startTime) / 1000.0F);
2737 if (timeInSeconds > 0) {
2738 ci.println("Total flows added in Thread:" + theadNumber + ": Flows/Sec::"
2739 + Math.round((float)totalNumberOfFlows / timeInSeconds));
2741 ci.println("Total flows added in Thread:" + theadNumber + ": Flows/Sec::" + totalNumberOfFlows);
2748 * usage testAllFlows <dp>
2749 * ex: _perfFlowTest 1
2751 @SuppressWarnings({ "checkstyle:MethodName", "checkstyle:IllegalCatch" })
2752 public void _testAllFlows(final CommandInterpreter ci) {
2753 String dataPathID = ci.nextArgument();
2754 final int numberOfFlows = 82;
2755 if (dataPathID == null || dataPathID.trim().equals("")) {
2758 ci.println("* Test All Flows *");
2759 ci.println("* dataPathID:::" + dataPathID + "");
2760 final String dataPath = "openflow:" + dataPathID;
2761 final String tableId = "0";
2762 final NodeBuilder tn = createTestNode(dataPath);
2764 for (int flow = 1; flow < numberOfFlows; flow++) {
2765 final String flowID = "f" + flow;
2767 tf = createTestFlow(tn, flowID, tableId);
2768 writeFlow(ci, tf, tn);
2769 } catch (RuntimeException e) {
2770 ci.println("--Test Failed--Issue found while adding flow" + flow);