2 * Copyright © 2017 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.netvirt.sfc.classifier.utils;
10 import java.math.BigInteger;
11 import java.util.ArrayList;
12 import java.util.List;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg0;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlowBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.ExtensionBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.DstChoice;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshMdtypeCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshNpCaseBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc1CaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc2CaseBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc4CaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNsiCaseBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNspCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCaseBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIdCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4DstCaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.group.buckets.bucket.action.action.NxActionRegLoadNodesNodeGroupBucketsBucketActionsCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.group.buckets.bucket.action.action.NxActionRegMoveNodesNodeGroupBucketsBucketActionsCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionPopNshNodesNodeTableFlowApplyActionsCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionPushNshNodesNodeTableFlowApplyActionsCaseBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionResubmitNodesNodeTableFlowWriteActionsCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.pop.nsh.grouping.NxPopNsh;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.pop.nsh.grouping.NxPopNshBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.push.nsh.grouping.NxPushNsh;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.push.nsh.grouping.NxPushNshBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.Dst;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.DstBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMove;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMoveBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.SrcBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.resubmit.grouping.NxResubmitBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.SrcChoice;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc4CaseBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxRegCaseBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCaseBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxEncapEthTypeKey;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNshc1Key;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNshc2Key;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNsiKey;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNspKey;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxTunIdKey;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxTunIpv4DstKey;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.encap.eth.type.grouping.NxmNxEncapEthTypeBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._1.grouping.NxmNxNshc1Builder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._2.grouping.NxmNxNshc2Builder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsi.grouping.NxmNxNsiBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsp.grouping.NxmNxNspBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.tun.id.grouping.NxmNxTunIdBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.tun.ipv4.dst.grouping.NxmNxTunIpv4DstBuilder;
95 public final class OpenFlow13Utils {
96 public static final int ETHERTYPE_NSH = 0x894f;
97 public static final short TUN_GPE_NP_NSH = 0x4;
99 private OpenFlow13Utils() {
102 public static MatchBuilder getNspMatch(long nsp) {
103 MatchBuilder mb = new MatchBuilder();
104 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
105 .setNxmNxNsp(new NxmNxNspBuilder().setValue(nsp).build()).build();
106 addExtension(mb, NxmNxNspKey.class, am);
111 public static void addMatchTunId(MatchBuilder match, long value) {
112 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
113 .setNxmNxTunId(new NxmNxTunIdBuilder().setValue(BigInteger.valueOf(value)).build()).build();
114 addExtension(match, NxmNxTunIdKey.class, am);
117 public static void addMatchTunDstIp(MatchBuilder match, Ipv4Address ipv4Address) {
118 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
119 .setNxmNxTunIpv4Dst(new NxmNxTunIpv4DstBuilder().setIpv4Address(ipv4Address).build()).build();
120 addExtension(match, NxmNxTunIpv4DstKey.class, am);
123 public static void addMatchEthNsh(MatchBuilder match) {
124 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
125 .setNxmNxEncapEthType(new NxmNxEncapEthTypeBuilder().setValue(ETHERTYPE_NSH).build()).build();
126 addExtension(match, NxmNxEncapEthTypeKey.class, am);
129 public static void addMatchInPort(MatchBuilder match, NodeId nodeId, long inPort) {
130 match.setInPort(new NodeConnectorId(nodeId.getValue() + ":" + inPort));
133 public static void addMatchNsp(MatchBuilder match, long nsp) {
134 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
135 .setNxmNxNsp(new NxmNxNspBuilder().setValue(nsp).build()).build();
136 addExtension(match, NxmNxNspKey.class, am);
139 public static void addMatchNsi(MatchBuilder match, short nsi) {
140 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
141 .setNxmNxNsi(new NxmNxNsiBuilder().setNsi(nsi).build()).build();
142 addExtension(match, NxmNxNsiKey.class, am);
145 public static void addMatchNshNsc1(MatchBuilder match, long nsc) {
146 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
147 .setNxmNxNshc1(new NxmNxNshc1Builder().setValue(nsc).build()).build();
148 addExtension(match, NxmNxNshc1Key.class, am);
151 public static void addMatchNshNsc2(MatchBuilder match, long nsc) {
152 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
153 .setNxmNxNshc2(new NxmNxNshc2Builder().setValue(nsc).build()).build();
154 addExtension(match, NxmNxNshc2Key.class, am);
157 private static void addExtension(MatchBuilder match, Class<? extends ExtensionKey> extensionKey,
158 NxAugMatchNodesNodeTableFlow am) {
159 GeneralAugMatchNodesNodeTableFlow existingAugmentations = match
160 .augmentation(GeneralAugMatchNodesNodeTableFlow.class);
161 List<ExtensionList> extensions = null;
162 if (existingAugmentations != null) {
163 extensions = existingAugmentations.getExtensionList();
165 if (extensions == null) {
166 extensions = new ArrayList<>();
169 extensions.add(new ExtensionListBuilder().setExtensionKey(extensionKey)
170 .setExtension(new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class, am).build())
173 GeneralAugMatchNodesNodeTableFlow generalAugMatchNodesNode = new GeneralAugMatchNodesNodeTableFlowBuilder()
174 .setExtensionList(extensions).build();
175 match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, generalAugMatchNodesNode);
178 public static Action createActionResubmitTable(final short toTable, int order) {
179 return createActionBuilder(order)
180 .setAction(new NxActionResubmitNodesNodeTableFlowWriteActionsCaseBuilder()
181 .setNxResubmit(new NxResubmitBuilder()
188 public static Action createActionNxLoadTunIpv4Dst(long value, int order) {
189 ActionBuilder ab = createActionBuilder(order);
190 ab.setAction(nxLoadRegAction(new DstNxTunIpv4DstCaseBuilder().setNxTunIpv4Dst(Boolean.TRUE).build(),
191 BigInteger.valueOf(value), 31, false));
196 public static Action createActionNxLoadTunId(long value, int order) {
197 ActionBuilder ab = createActionBuilder(order);
198 ab.setAction(nxLoadRegAction(new DstNxTunIdCaseBuilder().setNxTunId(Boolean.TRUE).build(),
199 BigInteger.valueOf(value), 31, false));
204 public static Action createActionNxLoadNshMdtype(short value, int order) {
205 ActionBuilder ab = createActionBuilder(order);
206 ab.setAction(nxLoadRegAction(new DstNxNshMdtypeCaseBuilder().setNxNshMdtype(Boolean.TRUE).build(),
207 BigInteger.valueOf(value), 7, false));
212 public static Action createActionNxLoadNp(short value, int order) {
213 ActionBuilder ab = createActionBuilder(order);
214 ab.setAction(nxLoadRegAction(new DstNxNshNpCaseBuilder().setNxNshNp(Boolean.TRUE).build(),
215 BigInteger.valueOf(value), 7, false));
220 public static Action createActionNxLoadNsp(int value, int order) {
221 ActionBuilder ab = createActionBuilder(order);
222 ab.setAction(nxLoadRegAction(new DstNxNspCaseBuilder().setNxNspDst(Boolean.TRUE).build(),
223 BigInteger.valueOf(value), 23, false));
228 public static Action createActionNxLoadNsi(short value, int order) {
229 ActionBuilder ab = createActionBuilder(order);
230 ab.setAction(nxLoadRegAction(new DstNxNsiCaseBuilder().setNxNsiDst(Boolean.TRUE).build(),
231 BigInteger.valueOf(value), 7, false));
236 public static Action createActionNxLoadNshc1(long value, int order) {
237 ActionBuilder ab = createActionBuilder(order);
238 ab.setAction(nxLoadRegAction(new DstNxNshc1CaseBuilder().setNxNshc1Dst(Boolean.TRUE).build(),
239 BigInteger.valueOf(value), 31, false));
244 public static Action createActionNxLoadNshc2(long value, int order) {
245 ActionBuilder ab = createActionBuilder(order);
246 ab.setAction(nxLoadRegAction(new DstNxNshc2CaseBuilder().setNxNshc2Dst(Boolean.TRUE).build(),
247 BigInteger.valueOf(value), 31, false));
252 public static Action createActionNxPushNsh(int order) {
253 NxPushNshBuilder builder = new NxPushNshBuilder();
254 NxPushNsh nxPushNsh = builder.build();
256 ActionBuilder ab = createActionBuilder(order);
257 ab.setAction(new NxActionPushNshNodesNodeTableFlowApplyActionsCaseBuilder().setNxPushNsh(nxPushNsh).build());
262 public static Action createActionNxPopNsh(int order) {
263 NxPopNshBuilder builder = new NxPopNshBuilder();
264 NxPopNsh nxPopNsh = builder.build();
266 ActionBuilder ab = createActionBuilder(order);
267 ab.setAction(new NxActionPopNshNodesNodeTableFlowApplyActionsCaseBuilder().setNxPopNsh(nxPopNsh).build());
272 public static Action createActionNxMoveTunIdToNsc2Register(int order) {
273 ActionBuilder ab = createActionBuilder(order);
274 ab.setAction(nxMoveRegAction(new SrcNxTunIdCaseBuilder().setNxTunId(Boolean.TRUE).build(),
275 new DstNxNshc2CaseBuilder().setNxNshc2Dst(Boolean.TRUE).build(), 31, false));
280 public static Action createActionNxMoveReg0ToNsc1Register(int order) {
281 ActionBuilder ab = createActionBuilder(order);
282 ab.setAction(nxMoveRegAction(new SrcNxRegCaseBuilder().setNxReg(NxmNxReg0.class).build(),
283 new DstNxNshc1CaseBuilder().setNxNshc1Dst(Boolean.TRUE).build(), 31, false));
288 public static Action createActionNxMoveReg6ToNsc4Register(int order) {
289 ActionBuilder ab = createActionBuilder(order);
290 ab.setAction(nxMoveRegAction(new SrcNxRegCaseBuilder().setNxReg(NxmNxReg6.class).build(),
291 new DstNxNshc4CaseBuilder().setNxNshc4Dst(Boolean.TRUE).build(), 31, false));
296 public static Action createActionNxMoveNsc4ToReg6Register(int order) {
297 ActionBuilder ab = createActionBuilder(order);
298 ab.setAction(nxMoveRegAction(new SrcNxNshc4CaseBuilder().setNxNshc4Dst(Boolean.TRUE).build(),
299 new DstNxRegCaseBuilder().setNxReg(NxmNxReg6.class).build(), 31, false));
304 public static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxLoadRegAction(
305 DstChoice dstChoice, BigInteger value, int endOffset, boolean groupBucket) {
306 NxRegLoad regLoad = new NxRegLoadBuilder()
307 .setDst(new DstBuilder().setDstChoice(dstChoice).setStart(0).setEnd(endOffset).build()).setValue(value)
311 return new NxActionRegLoadNodesNodeGroupBucketsBucketActionsCaseBuilder().setNxRegLoad(regLoad).build();
313 return new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegLoad(regLoad).build();
317 public static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxMoveRegAction(
318 SrcChoice srcChoice, DstChoice dstChoice, int endOffset, boolean groupBucket) {
319 NxRegMove nxRegMove = new NxRegMoveBuilder()
320 .setSrc(new SrcBuilder().setSrcChoice(srcChoice).setStart(0).setEnd(endOffset).build())
321 .setDst(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira
322 .action.rev140714.nx.action.reg.move.grouping.nx.reg.move.DstBuilder()
323 .setDstChoice(dstChoice).setStart(0).setEnd(endOffset).build())
327 return new NxActionRegMoveNodesNodeGroupBucketsBucketActionsCaseBuilder().setNxRegMove(nxRegMove).build();
329 return new NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegMove(nxRegMove).build();
333 public static Action createActionOutPort(final String portUri, final int order) {
334 OutputActionBuilder output = new OutputActionBuilder();
335 Uri value = new Uri(portUri);
336 output.setOutputNodeConnector(value);
337 ActionBuilder ab = createActionBuilder(order);
338 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
343 public static ActionBuilder createActionBuilder(int order) {
344 ActionBuilder ab = new ActionBuilder();
346 ab.withKey(new ActionKey(order));
351 public static InstructionsBuilder wrapActionsIntoApplyActionsInstruction(List<Action> theActions) {
352 // Create an Apply Action
353 ApplyActionsBuilder aab = new ApplyActionsBuilder();
354 aab.setAction(theActions);
356 // Wrap our Apply Action in an Instruction
357 InstructionBuilder ib = new InstructionBuilder();
358 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
360 ib.withKey(new InstructionKey(0));
362 // Put our Instruction in a list of Instructions
363 List<Instruction> instructions = new ArrayList<>();
364 instructions.add(ib.build());
365 return new InstructionsBuilder().setInstruction(instructions);
368 public static FlowBuilder createFlowBuilder(final short table, final int priority, final BigInteger cookieValue,
369 final String flowName, final String flowIdStr, MatchBuilder match,
370 InstructionsBuilder isb) {
371 FlowBuilder flow = new FlowBuilder();
372 flow.setId(new FlowId(flowIdStr));
373 flow.withKey(new FlowKey(new FlowId(flowIdStr)));
374 flow.setTableId(table);
375 flow.setFlowName(flowName);
376 flow.setCookie(new FlowCookie(cookieValue));
377 flow.setCookieMask(new FlowCookie(cookieValue));
378 flow.setContainerName(null);
379 flow.setStrict(false);
380 flow.setMatch(match.build());
381 flow.setInstructions(isb.build());
382 flow.setPriority(priority);
383 flow.setHardTimeout(0);
384 flow.setIdleTimeout(0);
385 flow.setFlags(new FlowModFlags(false, false, false, false, false));
386 if (null == flow.isBarrier()) {
387 flow.setBarrier(Boolean.FALSE);
393 public static InstructionsBuilder appendGotoTableInstruction(InstructionsBuilder isb, short nextTableId) {
394 if (isb.getInstruction() == null) {
395 isb.setInstruction(new ArrayList<>());
397 isb.getInstruction().add(createGotoTableInstruction(nextTableId, isb.getInstruction().size()));
401 public static Instruction createGotoTableInstruction(short nextTableId, int order) {
402 GoToTableBuilder gotoIngress = createActionGotoTable(nextTableId);
404 return new InstructionBuilder().withKey(new InstructionKey(order)).setOrder(order)
405 .setInstruction(new GoToTableCaseBuilder().setGoToTable(gotoIngress.build()).build()).build();
408 public static GoToTableBuilder createActionGotoTable(final short toTable) {
409 GoToTableBuilder gotoTb = new GoToTableBuilder();
410 gotoTb.setTableId(toTable);
415 public static NxRegLoad createNxLoadReg0(long value) {
416 Dst dst = new DstBuilder()
417 .setDstChoice(new DstNxRegCaseBuilder().setNxReg(NxmNxReg0.class).build())
421 return new NxRegLoadBuilder()
423 .setValue(BigInteger.valueOf(value))
427 public static Action createAction(
428 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action, int order) {
429 return new ActionBuilder()
431 .withKey(new ActionKey(order))