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.l2.types.rev130827.EtherType;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetType;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.PacketTypeMatch;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.PacketTypeMatchBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg0;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg2;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlowBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.ExtensionBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.DstChoice;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc1CaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc2CaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNshc4CaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNsiCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxNspCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCase;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxRegCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIdCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxTunIpv4DstCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.group.buckets.bucket.action.action.NxActionRegLoadNodesNodeGroupBucketsBucketActionsCaseBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.group.buckets.bucket.action.action.NxActionRegMoveNodesNodeGroupBucketsBucketActionsCaseBuilder;
64 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.NxActionDecapNodesNodeTableFlowApplyActionsCaseBuilder;
65 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.NxActionEncapNodesNodeTableFlowApplyActionsCaseBuilder;
66 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;
67 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;
68 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;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.decap.grouping.NxDecap;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.decap.grouping.NxDecapBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.encap.grouping.NxEncap;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.encap.grouping.NxEncapBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.Dst;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.DstBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMove;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMoveBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.SrcBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.resubmit.grouping.NxResubmitBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.SrcChoice;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxNshc4CaseBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxRegCaseBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCaseBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNsiKey;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxNspKey;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxReg2Key;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxTunIdKey;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxTunIpv4DstKey;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsi.grouping.NxmNxNsiBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nsp.grouping.NxmNxNspBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.reg.grouping.NxmNxReg;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.reg.grouping.NxmNxRegBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.tun.id.grouping.NxmNxTunIdBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.tun.ipv4.dst.grouping.NxmNxTunIpv4DstBuilder;
98 import org.opendaylight.yangtools.yang.common.Empty;
100 public final class OpenFlow13Utils {
101 public static final long ETHERTYPE_NSH = 0x894f;
102 public static final long PACKET_TYPE_NSH = 0x1894f;
103 public static final long PACKET_TYPE_ETH = 0;
105 private OpenFlow13Utils() {
108 public static void addMatchTunId(MatchBuilder match, long value) {
109 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
110 .setNxmNxTunId(new NxmNxTunIdBuilder().setValue(BigInteger.valueOf(value)).build()).build();
111 addExtension(match, NxmNxTunIdKey.class, am);
114 public static void addMatchTunDstIp(MatchBuilder match, Ipv4Address ipv4Address) {
115 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
116 .setNxmNxTunIpv4Dst(new NxmNxTunIpv4DstBuilder().setIpv4Address(ipv4Address).build()).build();
117 addExtension(match, NxmNxTunIpv4DstKey.class, am);
120 public static void addMatchEthNsh(MatchBuilder match) {
121 EtherType etherType = new EtherType(ETHERTYPE_NSH);
122 EthernetType ethernetType = new EthernetTypeBuilder().setType(etherType).build();
123 EthernetMatch ethernetMatch = new EthernetMatchBuilder().setEthernetType(ethernetType).build();
124 match.setEthernetMatch(ethernetMatch);
127 public static void addMatchPacketTypeNsh(MatchBuilder match) {
128 PacketTypeMatch packetTypeMatch = new PacketTypeMatchBuilder().setPacketType(PACKET_TYPE_NSH).build();
129 match.setPacketTypeMatch(packetTypeMatch);
132 public static void addMatchInPort(MatchBuilder match, NodeId nodeId, long inPort) {
133 match.setInPort(new NodeConnectorId(nodeId.getValue() + ":" + inPort));
136 public static void addMatchNsp(MatchBuilder match, long nsp) {
137 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
138 .setNxmNxNsp(new NxmNxNspBuilder().setValue(nsp).build()).build();
139 addExtension(match, NxmNxNspKey.class, am);
142 public static void addMatchNsi(MatchBuilder match, short nsi) {
143 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder()
144 .setNxmNxNsi(new NxmNxNsiBuilder().setNsi(nsi).build()).build();
145 addExtension(match, NxmNxNsiKey.class, am);
148 public static void addMatchReg2(MatchBuilder match, long value) {
149 NxmNxReg nxmNxReg = new NxmNxRegBuilder().setReg(NxmNxReg2.class).setValue(value).build();
150 NxAugMatchNodesNodeTableFlow am = new NxAugMatchNodesNodeTableFlowBuilder().setNxmNxReg(nxmNxReg).build();
151 addExtension(match, NxmNxReg2Key.class, am);
154 private static void addExtension(MatchBuilder match, Class<? extends ExtensionKey> extensionKey,
155 NxAugMatchNodesNodeTableFlow am) {
156 GeneralAugMatchNodesNodeTableFlow existingAugmentations = match
157 .augmentation(GeneralAugMatchNodesNodeTableFlow.class);
158 List<ExtensionList> extensions = null;
159 if (existingAugmentations != null) {
160 extensions = existingAugmentations.getExtensionList();
162 if (extensions == null) {
163 extensions = new ArrayList<>();
166 extensions.add(new ExtensionListBuilder().setExtensionKey(extensionKey)
167 .setExtension(new ExtensionBuilder().addAugmentation(NxAugMatchNodesNodeTableFlow.class, am).build())
170 GeneralAugMatchNodesNodeTableFlow generalAugMatchNodesNode = new GeneralAugMatchNodesNodeTableFlowBuilder()
171 .setExtensionList(extensions).build();
172 match.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, generalAugMatchNodesNode);
175 public static Action createActionResubmitTable(final short toTable, int order) {
176 return createActionBuilder(order)
177 .setAction(new NxActionResubmitNodesNodeTableFlowWriteActionsCaseBuilder()
178 .setNxResubmit(new NxResubmitBuilder()
185 public static Action createActionNxLoadTunIpv4Dst(long value, int order) {
186 ActionBuilder ab = createActionBuilder(order);
187 ab.setAction(nxLoadRegAction(new DstNxTunIpv4DstCaseBuilder().setNxTunIpv4Dst(Empty.getInstance()).build(),
188 BigInteger.valueOf(value), 0,31, false));
193 public static Action createActionNxLoadTunId(long value, int order) {
194 ActionBuilder ab = createActionBuilder(order);
195 ab.setAction(nxLoadRegAction(new DstNxTunIdCaseBuilder().setNxTunId(Empty.getInstance()).build(),
196 BigInteger.valueOf(value), 0,31, false));
201 public static Action createActionNxEncapNsh(int order) {
202 return createActionNxEncap(order, PACKET_TYPE_NSH);
205 public static Action createActionNxEncapEthernet(int order) {
206 return createActionNxEncap(order, PACKET_TYPE_ETH);
209 private static Action createActionNxEncap(int order, long packetType) {
210 NxEncap nxEncap = new NxEncapBuilder().setPacketType(packetType).build();
211 ActionBuilder ab = createActionBuilder(order);
212 ab.setAction(new NxActionEncapNodesNodeTableFlowApplyActionsCaseBuilder().setNxEncap(nxEncap).build());
216 public static Action createActionNxDecap(int order) {
217 NxDecap nxDecap = new NxDecapBuilder().build();
218 ActionBuilder ab = createActionBuilder(order);
219 ab.setAction(new NxActionDecapNodesNodeTableFlowApplyActionsCaseBuilder().setNxDecap(nxDecap).build());
223 public static Action createActionNxMoveTunIdToNsc2Register(int order) {
224 ActionBuilder ab = createActionBuilder(order);
225 ab.setAction(nxMoveRegAction(new SrcNxTunIdCaseBuilder().setNxTunId(Empty.getInstance()).build(), 0, 31,
226 new DstNxNshc2CaseBuilder().setNxNshc2Dst(Empty.getInstance()).build(), 0, 31,
232 public static Action createActionNxMoveReg0ToNsc1Register(int order) {
233 ActionBuilder ab = createActionBuilder(order);
234 ab.setAction(nxMoveRegAction(
235 new SrcNxRegCaseBuilder().setNxReg(NxmNxReg0.class).build(), 0, 31,
236 new DstNxNshc1CaseBuilder().setNxNshc1Dst(Empty.getInstance()).build(), 0,31,
242 public static Action createActionNxMoveReg6ToNsc4Register(int order) {
243 ActionBuilder ab = createActionBuilder(order);
244 ab.setAction(nxMoveRegAction(new SrcNxRegCaseBuilder().setNxReg(NxmNxReg6.class).build(), 0, 31,
245 new DstNxNshc4CaseBuilder().setNxNshc4Dst(Empty.getInstance()).build(), 0, 31,
251 public static Action createActionNxMoveNsc4ToReg6Register(int order) {
252 ActionBuilder ab = createActionBuilder(order);
253 ab.setAction(nxMoveRegAction(new SrcNxNshc4CaseBuilder().setNxNshc4Dst(Empty.getInstance()).build(), 0, 31,
254 new DstNxRegCaseBuilder().setNxReg(NxmNxReg6.class).build(), 0, 31,
260 public static Action createActionNxLoadNspToReg2High(long value, int order) {
261 ActionBuilder ab = createActionBuilder(order);
262 DstNxRegCase dstNxRegCase = new DstNxRegCaseBuilder().setNxReg(NxmNxReg2.class).build();
264 // Load NSP to the 3 most significant bytes
265 nxLoadRegAction(dstNxRegCase, BigInteger.valueOf(value), 8, 31, false));
269 public static Action createActionNxMoveReg2HighToNsp(int order) {
270 ActionBuilder ab = createActionBuilder(order);
271 ab.setAction(nxMoveRegAction(
272 // Move NSP from the 3 most significant bytes
273 new SrcNxRegCaseBuilder().setNxReg(NxmNxReg2.class).build(), 8, 31,
274 new DstNxNspCaseBuilder().setNxNspDst(Empty.getInstance()).build(), 0, 23,
280 public static Action createActionNxLoadNsiToReg2Low(long value, int order) {
281 ActionBuilder ab = createActionBuilder(order);
282 DstNxRegCase dstNxRegCase = new DstNxRegCaseBuilder().setNxReg(NxmNxReg2.class).build();
284 // Load NSI to the least significant byte
285 nxLoadRegAction(dstNxRegCase, BigInteger.valueOf(value), 0, 7, false));
289 public static Action createActionNxMoveReg2LowToNsi(int order) {
290 ActionBuilder ab = createActionBuilder(order);
291 ab.setAction(nxMoveRegAction(
292 // Move NSI from the least significant byte
293 new SrcNxRegCaseBuilder().setNxReg(NxmNxReg2.class).build(), 0, 7,
294 new DstNxNsiCaseBuilder().setNxNsiDst(Empty.getInstance()).build(), 0, 7,
300 public static Action createActionNxLoadReg2(long value, int order) {
301 ActionBuilder ab = createActionBuilder(order);
302 DstNxRegCase dstNxRegCase = new DstNxRegCaseBuilder().setNxReg(NxmNxReg2.class).build();
304 nxLoadRegAction(dstNxRegCase, BigInteger.valueOf(value), 0, 31, false));
309 private static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxLoadRegAction(
310 DstChoice dstChoice, BigInteger value, int startOffset, int endOffset, boolean groupBucket) {
311 Dst dst = new DstBuilder().setDstChoice(dstChoice).setStart(startOffset).setEnd(endOffset).build();
312 NxRegLoad regLoad = new NxRegLoadBuilder().setDst(dst).setValue(value).build();
315 return new NxActionRegLoadNodesNodeGroupBucketsBucketActionsCaseBuilder().setNxRegLoad(regLoad).build();
317 return new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegLoad(regLoad).build();
321 public static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action nxMoveRegAction(
322 SrcChoice srcChoice, int srcStartOffset, int srcEndOffset,
323 DstChoice dstChoice, int dstStartOffset, int dstEndOffset,
324 boolean groupBucket) {
326 NxRegMove nxRegMove = new NxRegMoveBuilder()
327 .setSrc(new SrcBuilder().setSrcChoice(srcChoice).setStart(srcStartOffset).setEnd(srcEndOffset).build())
328 .setDst(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira
329 .action.rev140714.nx.action.reg.move.grouping.nx.reg.move.DstBuilder()
330 .setDstChoice(dstChoice).setStart(dstStartOffset).setEnd(dstEndOffset).build())
334 return new NxActionRegMoveNodesNodeGroupBucketsBucketActionsCaseBuilder().setNxRegMove(nxRegMove).build();
336 return new NxActionRegMoveNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegMove(nxRegMove).build();
340 public static Action createActionOutPort(final String portUri, final int order) {
341 OutputActionBuilder output = new OutputActionBuilder();
342 Uri value = new Uri(portUri);
343 output.setOutputNodeConnector(value);
344 ActionBuilder ab = createActionBuilder(order);
345 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
350 public static ActionBuilder createActionBuilder(int order) {
351 ActionBuilder ab = new ActionBuilder();
353 ab.withKey(new ActionKey(order));
358 public static InstructionsBuilder wrapActionsIntoApplyActionsInstruction(List<Action> theActions) {
359 // Create an Apply Action
360 ApplyActionsBuilder aab = new ApplyActionsBuilder();
361 aab.setAction(theActions);
363 // Wrap our Apply Action in an Instruction
364 InstructionBuilder ib = new InstructionBuilder();
365 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
367 ib.withKey(new InstructionKey(0));
369 // Put our Instruction in a list of Instructions
370 List<Instruction> instructions = new ArrayList<>();
371 instructions.add(ib.build());
372 return new InstructionsBuilder().setInstruction(instructions);
375 public static FlowBuilder createFlowBuilder(final short table, final int priority, final BigInteger cookieValue,
376 final String flowName, final String flowIdStr, MatchBuilder match,
377 InstructionsBuilder isb) {
378 FlowBuilder flow = new FlowBuilder();
379 flow.setId(new FlowId(flowIdStr));
380 flow.withKey(new FlowKey(new FlowId(flowIdStr)));
381 flow.setTableId(table);
382 flow.setFlowName(flowName);
383 flow.setCookie(new FlowCookie(cookieValue));
384 flow.setCookieMask(new FlowCookie(cookieValue));
385 flow.setContainerName(null);
386 flow.setStrict(false);
387 flow.setMatch(match.build());
388 flow.setInstructions(isb.build());
389 flow.setPriority(priority);
390 flow.setHardTimeout(0);
391 flow.setIdleTimeout(0);
392 flow.setFlags(new FlowModFlags(false, false, false, false, false));
393 if (null == flow.isBarrier()) {
394 flow.setBarrier(Boolean.FALSE);
400 public static InstructionsBuilder appendGotoTableInstruction(InstructionsBuilder isb, short nextTableId) {
401 if (isb.getInstruction() == null) {
402 isb.setInstruction(new ArrayList<>());
404 isb.getInstruction().add(createGotoTableInstruction(nextTableId, isb.getInstruction().size()));
408 public static Instruction createGotoTableInstruction(short nextTableId, int order) {
409 GoToTableBuilder gotoIngress = createActionGotoTable(nextTableId);
411 return new InstructionBuilder().withKey(new InstructionKey(order)).setOrder(order)
412 .setInstruction(new GoToTableCaseBuilder().setGoToTable(gotoIngress.build()).build()).build();
415 public static GoToTableBuilder createActionGotoTable(final short toTable) {
416 GoToTableBuilder gotoTb = new GoToTableBuilder();
417 gotoTb.setTableId(toTable);
422 public static NxRegLoad createNxLoadReg0(long value) {
423 Dst dst = new DstBuilder()
424 .setDstChoice(new DstNxRegCaseBuilder().setNxReg(NxmNxReg0.class).build())
428 return new NxRegLoadBuilder()
430 .setValue(BigInteger.valueOf(value))
434 public static Action createAction(
435 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action, int order) {
436 return new ActionBuilder()
438 .withKey(new ActionKey(order))