2 * Copyright (c) 2014 Ericsson India Global Services Pvt Ltd. 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 * Contributor: hema.gopalkrishnan@ericsson.com
10 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
12 import org.opendaylight.openflowplugin.openflow.md.OFConstants;
13 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwDstReactor;
14 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwSrcReactor;
15 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
16 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
17 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
18 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
19 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowVersion;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCase;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanAction;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstAction;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcAction;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosAction;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueAction;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdAction;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpAction;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.CommonPort;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
141 import org.opendaylight.yangtools.yang.binding.Augmentation;
142 import org.slf4j.Logger;
143 import org.slf4j.LoggerFactory;
145 import java.math.BigInteger;
146 import java.util.ArrayList;
147 import java.util.List;
150 * @author usha@ericsson Action List:This class takes data from SAL layer and
151 * converts into OF Data
152 * @author avishnoi@in.ibm.com Added convertor for OF bucket actions to SAL
156 public final class ActionConvertor {
157 private static final Logger logger = LoggerFactory.getLogger(ActionConvertor.class);
159 private ActionConvertor() {
164 * Translates SAL actions into OF Library actions
165 * @param actions SAL actions
166 * @param version Openflow protocol version used
168 * @return OF Library actions
170 public static List<Action> getActions(
171 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions,
172 short version, BigInteger datapathid)
175 List<Action> actionsList = new ArrayList<>();
178 for (int actionItem = 0; actionItem < actions.size(); actionItem++) {
180 ActionBuilder actionBuilder = new ActionBuilder();
182 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = actions.get(
183 actionItem).getAction();
185 if (action instanceof OutputActionCase)
186 ofAction = salToOFOutputAction(action, actionBuilder, version);
187 else if (action instanceof GroupActionCase)
188 ofAction = SalToOFGroupAction(action, actionBuilder);
189 else if (action instanceof CopyTtlOutCase)
190 ofAction = SalToOFCopyTTLIOut(actionBuilder);
191 else if (action instanceof CopyTtlInCase)
192 ofAction = SalToOFCopyTTLIIn(actionBuilder);
193 else if (action instanceof SetMplsTtlActionCase)
194 ofAction = SalToOFSetMplsTtl(action, actionBuilder);
195 else if (action instanceof DecMplsTtlCase)
196 ofAction = SalToOFDecMplsTtl(actionBuilder);
197 else if (action instanceof PushVlanActionCase)
198 ofAction = SalToOFPushVlanAction(action, actionBuilder);
199 else if (action instanceof PopVlanActionCase)
200 ofAction = (version == OFConstants.OFP_VERSION_1_0) ? SalToOFStripVlan(actionBuilder, version)
201 : SalToOFPopVlan(actionBuilder);
202 else if (action instanceof PushMplsActionCase)
203 ofAction = SalToOFPushMplsAction(action, actionBuilder);
204 else if (action instanceof PopMplsActionCase)
205 ofAction = SalToOFPopMpls(action, actionBuilder);
206 else if (action instanceof SetQueueActionCase)
207 ofAction = SalToOFSetQueue(action, actionBuilder);
208 else if (action instanceof SetNwTtlActionCase)
209 ofAction = SalToOFSetNwTtl(action, actionBuilder);
210 else if (action instanceof DecNwTtlCase)
211 ofAction = SalToOFDecNwTtl(actionBuilder);
212 else if (action instanceof SetFieldCase)
213 ofAction = SalToOFSetField(action, actionBuilder, version, datapathid);
214 else if (action instanceof PushPbbActionCase)
215 ofAction = SalToOFPushPbbAction(action, actionBuilder);
216 else if (action instanceof PopPbbActionCase)
217 ofAction = SalToOFPopPBB(actionBuilder);
218 else if (action instanceof ExperimenterAction)
219 ofAction = SalToOFExperimenter(action, actionBuilder);
222 else if (action instanceof SetVlanIdActionCase)
223 ofAction = SalToOFSetVlanId(action, actionBuilder, version);
224 else if (action instanceof SetVlanPcpActionCase)
225 ofAction = SalToOFSetVlanpcp(action, actionBuilder, version);
226 else if (action instanceof StripVlanActionCase)
227 ofAction = SalToOFStripVlan(actionBuilder, version);
228 else if (action instanceof SetDlSrcActionCase)
229 ofAction = SalToOFSetDlSrc(action, actionBuilder, version);
230 else if (action instanceof SetDlDstActionCase)
231 ofAction = SalToOFSetDlDst(action, actionBuilder, version);
232 else if (action instanceof SetNwSrcActionCase)
233 ofAction = SalToOFSetNwSrc(action, actionBuilder, version);
234 else if (action instanceof SetNwDstActionCase)
235 ofAction = SalToOFSetNwDst(action, actionBuilder, version);
236 else if (action instanceof SetTpSrcActionCase)
237 ofAction = SalToOFSetTpSrc(action, actionBuilder, version);
238 else if (action instanceof SetTpDstActionCase)
239 ofAction = SalToOFSetTpDst(action, actionBuilder, version);
240 else if (action instanceof SetNwTosActionCase)
241 ofAction = SalToOFSetNwTos(action, actionBuilder, version);
243 if (ofAction != null) {
244 actionsList.add(ofAction);
250 private static Action SalToOFSetField(
251 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
252 ActionBuilder actionBuilder, short version, BigInteger datapathid) {
254 SetFieldCase setFieldCase = (SetFieldCase) action;
255 org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match = setFieldCase
258 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
259 MatchReactor.getInstance().convert(match, version, oxmFieldsActionBuilder, datapathid);
262 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
264 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
265 return actionBuilder.build();
268 private static Action SalToOFDecNwTtl(ActionBuilder actionBuilder) {
270 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class);
271 return emtpyAction(actionBuilder);
274 private static Action SalToOFPushMplsAction(
275 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
276 ActionBuilder actionBuilder) {
277 PushMplsActionCase pushMplsActionCase = (PushMplsActionCase) action;
278 actionBuilder.setType(PushMpls.class);
280 return SalToOFPushAction(pushMplsActionCase.getPushMplsAction().getEthernetType(), actionBuilder);
283 private static Action SalToOFPushPbbAction(
284 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
285 ActionBuilder actionBuilder) {
286 PushPbbActionCase pushPbbActionCase = (PushPbbActionCase) action;
287 actionBuilder.setType(PushPbb.class);
289 return SalToOFPushAction(pushPbbActionCase.getPushPbbAction().getEthernetType(), actionBuilder);
292 private static Action SalToOFPushVlanAction(
293 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
294 ActionBuilder actionBuilder) {
295 PushVlanActionCase pushVlanActionCase = (PushVlanActionCase) action;
296 PushVlanAction pushVlanAction = pushVlanActionCase.getPushVlanAction();
297 actionBuilder.setType(PushVlan.class);
299 return SalToOFPushAction(pushVlanAction.getEthernetType(), actionBuilder);
302 private static Action SalToOFSetNwTtl(
303 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
304 ActionBuilder actionBuilder) {
305 SetNwTtlActionCase nwTtlActionCase = (SetNwTtlActionCase) action;
306 NwTtlActionBuilder nwTtlActionBuilder = new NwTtlActionBuilder();
307 nwTtlActionBuilder.setNwTtl(nwTtlActionCase.getSetNwTtlAction().getNwTtl());
308 actionBuilder.setType(SetNwTtl.class);
309 actionBuilder.addAugmentation(NwTtlAction.class, nwTtlActionBuilder.build());
310 return actionBuilder.build();
313 private static Action SalToOFSetQueue(
314 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
315 ActionBuilder actionBuilder) {
316 SetQueueActionCase setQueueActionCase = (SetQueueActionCase) action;
317 SetQueueAction setQueueAction = setQueueActionCase.getSetQueueAction();
319 QueueIdActionBuilder queueIdActionBuilder = new QueueIdActionBuilder();
320 queueIdActionBuilder.setQueueId(setQueueAction.getQueueId());
321 actionBuilder.setType(SetQueue.class);
322 actionBuilder.addAugmentation(QueueIdAction.class, queueIdActionBuilder.build());
324 return actionBuilder.build();
327 private static Action SalToOFPopMpls(
328 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
329 ActionBuilder actionBuilder) {
330 PopMplsActionCase popMplsActionCase = (PopMplsActionCase) action;
331 actionBuilder.setType(PopMpls.class);
333 return SalToOFPushAction(popMplsActionCase.getPopMplsAction().getEthernetType(), actionBuilder);
336 private static Action SalToOFPopVlan(ActionBuilder actionBuilder) {
337 actionBuilder.setType(PopVlan.class);
338 return emtpyAction(actionBuilder);
341 private static Action SalToOFPopPBB(ActionBuilder actionBuilder) {
342 actionBuilder.setType(PopPbb.class);
343 return emtpyAction(actionBuilder);
346 private static Action SalToOFExperimenter(
347 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
348 ActionBuilder actionBuilder) {
349 ExperimenterActionBuilder experimenterActionBuilder = new ExperimenterActionBuilder();
350 experimenterActionBuilder.setExperimenter(((ExperimenterAction) action).getExperimenter());
351 actionBuilder.setType(Experimenter.class);
354 ExperimenterAction.class,
355 (Augmentation<Action>) experimenterActionBuilder);
356 return actionBuilder.build();
359 private static Action SalToOFSetVlanId(
360 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
361 ActionBuilder actionBuilder, short version) {
363 SetVlanIdActionCase setvlanidcase = (SetVlanIdActionCase) action;
364 SetVlanIdAction setvlanidaction = setvlanidcase.getSetVlanIdAction();
366 if (version == OFConstants.OFP_VERSION_1_0) {
368 VlanVidActionBuilder vlanidActionBuilder = new VlanVidActionBuilder();
369 vlanidActionBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
371 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid.class);
372 actionBuilder.addAugmentation(VlanVidAction.class, vlanidActionBuilder.build());
373 return actionBuilder.build();
374 } else if (version >= OFConstants.OFP_VERSION_1_3) {
375 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
377 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
378 List<MatchEntries> matchEntriesList = new ArrayList<>();
379 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
380 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
381 matchEntriesBuilder.setOxmMatchField(VlanVid.class);
382 VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
383 vlanVidBuilder.setCfiBit(true);
384 vlanVidBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
385 matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
386 matchEntriesBuilder.setHasMask(false);
387 matchEntriesList.add(matchEntriesBuilder.build());
388 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
389 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
390 return actionBuilder.build();
392 logger.error("Unknown Action Type for the Version", version);
397 private static Action SalToOFSetVlanpcp(
398 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
399 ActionBuilder actionBuilder, short version) {
401 SetVlanPcpActionCase setvlanpcpcase = (SetVlanPcpActionCase) action;
402 SetVlanPcpAction setvlanpcpaction = setvlanpcpcase.getSetVlanPcpAction();
404 if (version == OFConstants.OFP_VERSION_1_0) {
405 VlanPcpActionBuilder vlanpcpActionBuilder = new VlanPcpActionBuilder();
406 vlanpcpActionBuilder.setVlanPcp(setvlanpcpaction.getVlanPcp().getValue());
408 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp.class);
409 actionBuilder.addAugmentation(VlanPcpAction.class, vlanpcpActionBuilder.build());
410 return actionBuilder.build();
411 } else if (version >= OFConstants.OFP_VERSION_1_3) {
412 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
414 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
415 List<MatchEntries> matchEntriesList = new ArrayList<>();
416 matchEntriesList.add(MatchConvertorImpl.toOfVlanPcp(setvlanpcpaction.getVlanPcp()));
417 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
418 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
419 return actionBuilder.build();
421 logger.error("Unknown Action Type for the Version", version);
426 private static Action SalToOFStripVlan(ActionBuilder actionBuilder, short version) {
427 if (version == OFConstants.OFP_VERSION_1_0) {
429 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class);
431 return emtpyAction(actionBuilder);
432 } else if (version >= OFConstants.OFP_VERSION_1_3) {
433 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
435 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
436 List<MatchEntries> matchEntriesList = new ArrayList<>();
437 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
438 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
439 matchEntriesBuilder.setOxmMatchField(VlanVid.class);
440 VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
441 vlanVidBuilder.setCfiBit(true);
442 vlanVidBuilder.setVlanVid(new Integer(0x0000));
443 matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
444 matchEntriesBuilder.setHasMask(false);
445 matchEntriesList.add(matchEntriesBuilder.build());
446 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
447 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
448 return actionBuilder.build();
450 logger.error("Unknown Action Type for the Version", version);
455 private static Action SalToOFSetDlSrc(
456 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
457 ActionBuilder actionBuilder, short version) {
459 SetDlSrcActionCase setdlsrccase = (SetDlSrcActionCase) action;
460 SetDlSrcAction setdlsrcaction = setdlsrccase.getSetDlSrcAction();
462 if (version == OFConstants.OFP_VERSION_1_0) {
463 DlAddressActionBuilder dladdressactionbuilder = new DlAddressActionBuilder();
464 dladdressactionbuilder.setDlAddress(setdlsrcaction.getAddress());
466 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc.class);
467 actionBuilder.addAugmentation(DlAddressAction.class, dladdressactionbuilder.build());
468 return actionBuilder.build();
469 } else if (version >= OFConstants.OFP_VERSION_1_3) {
470 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
472 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
473 List<MatchEntries> matchEntriesList = new ArrayList<>();
474 matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthSrc.class, setdlsrcaction.getAddress(), null));
475 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
476 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
477 return actionBuilder.build();
479 logger.error("Unknown Action Type for the Version", version);
485 private static Action SalToOFSetDlDst(
486 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
487 ActionBuilder actionBuilder, short version) {
489 SetDlDstActionCase setdldstcase = (SetDlDstActionCase) action;
490 SetDlDstAction setdldstaction = setdldstcase.getSetDlDstAction();
492 if (version == OFConstants.OFP_VERSION_1_0) {
493 DlAddressActionBuilder dladdressactionbuilder = new DlAddressActionBuilder();
494 dladdressactionbuilder.setDlAddress(setdldstaction.getAddress());
496 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst.class);
497 actionBuilder.addAugmentation(DlAddressAction.class, dladdressactionbuilder.build());
498 return actionBuilder.build();
499 } else if (version >= OFConstants.OFP_VERSION_1_3) {
500 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
502 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
503 List<MatchEntries> matchEntriesList = new ArrayList<>();
504 matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthDst.class, setdldstaction.getAddress(), null));
505 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
506 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
507 return actionBuilder.build();
509 logger.error("Unknown Action Type for the Version", version);
515 protected static Action SalToOFSetNwSrc(
516 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
517 ActionBuilder actionBuilder, short version) {
520 ActionSetNwSrcReactor.getInstance().convert((SetNwSrcActionCase) action, version, actionBuilder, null);
521 } catch (Exception e) {
522 logger.error(e.getMessage(), e);
526 return actionBuilder.build();
529 protected static Action SalToOFSetNwDst(
530 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
531 ActionBuilder actionBuilder, short version) {
534 ActionSetNwDstReactor.getInstance().convert((SetNwDstActionCase) action, version, actionBuilder, null);
535 } catch (Exception e) {
536 logger.error(e.getMessage(), e);
540 return actionBuilder.build();
543 private static Action SalToOFSetNwTos(
544 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
545 ActionBuilder actionBuilder, short version) {
547 SetNwTosActionCase setnwtoscase = (SetNwTosActionCase) action;
548 SetNwTosAction setnwtosaction = setnwtoscase.getSetNwTosAction();
550 if (version == OFConstants.OFP_VERSION_1_0) {
551 NwTosActionBuilder tosBuilder = new NwTosActionBuilder();
552 tosBuilder.setNwTos(setnwtosaction.getTos().shortValue());
553 actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build());
555 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos.class);
557 return actionBuilder.build();
558 } else if (version >= OFConstants.OFP_VERSION_1_3) {
559 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
561 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
562 List<MatchEntries> matchEntriesList = new ArrayList<>();
563 matchEntriesList.add(MatchConvertorImpl.toOfIpDscp(new Dscp(setnwtosaction.getTos().shortValue())));
564 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
565 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
566 return actionBuilder.build();
568 logger.error("Unknown Action Type for the Version", version);
574 private static Action SalToOFSetTpSrc(
575 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
576 ActionBuilder actionBuilder, short version) {
578 if (version == OFConstants.OFP_VERSION_1_0) {
579 SetTpSrcActionCase settpsrccase = (SetTpSrcActionCase) action;
580 SetTpSrcAction settpsrcaction = settpsrccase.getSetTpSrcAction();
582 PortActionBuilder settpsrc = new PortActionBuilder();
583 PortNumber port = new PortNumber(settpsrcaction.getPort().getValue().longValue());
584 settpsrc.setPort(port);
587 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc.class);
588 actionBuilder.addAugmentation(PortAction.class, settpsrc.build());
589 return actionBuilder.build();
591 logger.error("Unknown Action Type for the Version", version);
595 private static Action SalToOFSetTpDst(
596 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
597 ActionBuilder actionBuilder, short version) {
599 if (version == OFConstants.OFP_VERSION_1_0) {
600 SetTpDstActionCase settpdstcase = (SetTpDstActionCase) action;
601 SetTpDstAction settpdstaction = settpdstcase.getSetTpDstAction();
602 PortActionBuilder settpdst = new PortActionBuilder();
603 PortNumber port = new PortNumber(settpdstaction.getPort().getValue().longValue());
604 settpdst.setPort(port);
607 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst.class);
608 actionBuilder.addAugmentation(PortAction.class, settpdst.build());
609 return actionBuilder.build();
611 logger.error("Unknown Action Type for the Version", version);
615 private static Action SalToOFGroupAction(
616 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
617 ActionBuilder actionBuilder) {
619 GroupActionCase groupActionCase = (GroupActionCase) action;
620 GroupAction groupAction = groupActionCase.getGroupAction();
622 GroupIdActionBuilder groupIdBuilder = new GroupIdActionBuilder();
623 groupIdBuilder.setGroupId(groupAction.getGroupId());
624 actionBuilder.setType(Group.class);
625 actionBuilder.addAugmentation(GroupIdAction.class, groupIdBuilder.build());
626 return actionBuilder.build();
629 private static Action SalToOFPushAction(Integer ethernetType, ActionBuilder actionBuilder) {
630 EthertypeActionBuilder ethertypeActionBuilder = new EthertypeActionBuilder();
631 ethertypeActionBuilder.setEthertype(new EtherType(ethernetType));
634 actionBuilder.addAugmentation(EthertypeAction.class, ethertypeActionBuilder.build());
635 return actionBuilder.build();
638 private static Action SalToOFDecMplsTtl(ActionBuilder actionBuilder) {
640 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class);
641 return emtpyAction(actionBuilder);
644 private static Action SalToOFSetMplsTtl(
645 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
646 ActionBuilder actionBuilder) {
647 SetMplsTtlActionCase mplsTtlActionCase = (SetMplsTtlActionCase) action;
648 SetMplsTtlAction mplsTtlAction = mplsTtlActionCase.getSetMplsTtlAction();
650 MplsTtlActionBuilder mplsTtlActionBuilder = new MplsTtlActionBuilder();
651 mplsTtlActionBuilder.setMplsTtl(mplsTtlAction.getMplsTtl()/* SAL */);
653 actionBuilder.setType(SetMplsTtl.class);
654 actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtlActionBuilder.build());
655 return actionBuilder.build();
658 private static Action SalToOFCopyTTLIIn(ActionBuilder actionBuilder) {
660 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class);
661 return emtpyAction(actionBuilder);
664 private static Action SalToOFCopyTTLIOut(ActionBuilder actionBuilder) {
666 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class);
667 return emtpyAction(actionBuilder);
671 private static Action emtpyAction(ActionBuilder actionBuilder) {
672 return actionBuilder.build();
675 private static Action salToOFOutputAction(
676 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
677 ActionBuilder actionBuilder, short version) {
679 OutputActionCase outputActionCase = ((OutputActionCase) action);
680 OutputAction outputAction = outputActionCase.getOutputAction();
681 PortActionBuilder portAction = new PortActionBuilder();
682 MaxLengthActionBuilder maxLenActionBuilder = new MaxLengthActionBuilder();
683 if (outputAction.getMaxLength() != null) {
684 maxLenActionBuilder.setMaxLength(outputAction.getMaxLength());
686 maxLenActionBuilder.setMaxLength(new Integer(0));
688 actionBuilder.addAugmentation(MaxLengthAction.class, maxLenActionBuilder.build());
690 Uri uri = outputAction.getOutputNodeConnector();
692 OpenflowVersion ofVersion = OpenflowVersion.get(version);
693 Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(ofVersion, uri.getValue());
694 if (OpenflowPortsUtil.checkPortValidity(ofVersion, portNumber)) {
695 portAction.setPort(new PortNumber(portNumber));
697 logger.error("Invalid Port specified "+ portNumber + " for Output Action for OF version:"+ ofVersion);
700 actionBuilder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
701 actionBuilder.addAugmentation(PortAction.class, portAction.build());
702 return actionBuilder.build();
707 * Method to convert OF actions associated with bucket to SAL Actions.
710 * @param ofVersion current ofp version
711 * @return List of converted SAL Actions.
713 public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> toMDSalActions(
714 List<Action> actionList, OpenflowVersion ofVersion) {
716 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> bucketActions = new ArrayList<>();
717 for (Action action : actionList) {
718 if (action.getType().equals(
719 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class)) {
720 bucketActions.add(ofToSALOutputAction(ofVersion, action));
722 } else if (action.getType().equals(
723 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class)) {
724 bucketActions.add(ofToSALGroupAction(action));
726 } else if (action.getType().equals(
727 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class)) {
728 CopyTtlOutBuilder copyTtlOutaction = new CopyTtlOutBuilder();
729 bucketActions.add(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyTtlOutaction.build()).build());
731 } else if (action.getType().equals(
732 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class)) {
733 CopyTtlInBuilder copyTtlInaction = new CopyTtlInBuilder();
734 bucketActions.add(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInaction.build()).build());
736 } else if (action.getType().equals(
737 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class)) {
738 bucketActions.add(ofToSALSetMplsTtl(action));
740 } else if (action.getType().equals(
741 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class)) {
742 DecMplsTtlBuilder decMplsTtl = new DecMplsTtlBuilder();
743 bucketActions.add(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtl.build()).build());
745 } else if (action.getType().equals(
746 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class)) {
747 bucketActions.add(ofToSALPushVlanAction(action));
749 } else if (action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)
750 || action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class)) {
751 // OF1.0 nodes will emit StripVlan and OF1.3+ will emit StripVlan/PopVlan, convert both to PopVlan for SAL
752 PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
753 bucketActions.add(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
755 } else if (action.getType().equals(
756 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class)) {
757 bucketActions.add(ofToSALPushMplsAction(action));
759 } else if (action.getType().equals(
760 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class)) {
761 bucketActions.add(ofToSALPopMplsAction(action));
763 } else if (action.getType().equals(
764 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class)) {
765 bucketActions.add(ofToSALSetQueue(action));
767 } else if (action.getType().equals(
768 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class)) {
769 bucketActions.add(ofToSALSetNwTtl(action));
771 } else if (action.getType().equals(
772 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class)) {
773 DecNwTtlBuilder decNwTtl = new DecNwTtlBuilder();
774 bucketActions.add(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl.build()).build());
776 } else if (action.getType().equals(
777 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class)) {
778 bucketActions.add(new SetFieldCaseBuilder().setSetField(MatchConvertorImpl.fromOFSetFieldToSALSetFieldAction(action, ofVersion))
780 } else if (action.getType().equals(
781 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class)) {
782 bucketActions.add(ofToSALPushPbbAction(action));
784 } else if (action.getType().equals(
785 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb.class)) {
786 PopPbbActionBuilder popPbb = new PopPbbActionBuilder();
787 bucketActions.add(new PopPbbActionCaseBuilder().setPopPbbAction(popPbb.build()).build());
789 } else if (action.getType().equals(
790 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) {
791 // bucketActions.add(ofToSALExperimenter(action));
792 // TODO: Need to explore/discuss on how to handle experimenter
797 return bucketActions;
801 * Method converts OF Output action object to SAL Output action object.
805 * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.
806 * action.rev130731.actions.actions.list.Action
808 * @return OutputAction
810 public static OutputActionCase ofToSALOutputAction(OpenflowVersion ofVersion, Action action) {
811 OutputActionBuilder outputAction = new OutputActionBuilder();
812 PortAction port = action.getAugmentation(PortAction.class);
814 CommonPort.PortNumber protocolAgnosticPort = OpenflowPortsUtil.getProtocolAgnosticPort(
815 ofVersion, port.getPort().getValue());
816 String portNumberAsString = OpenflowPortsUtil.portNumberToString(protocolAgnosticPort);
817 outputAction.setOutputNodeConnector(new Uri(portNumberAsString));
819 logger.error("Provided action is not OF Output action, no associated port found!");
822 MaxLengthAction length = action.getAugmentation(MaxLengthAction.class);
823 if (length != null) {
824 outputAction.setMaxLength(length.getMaxLength());
826 logger.error("Provided action is not OF Output action, no associated length found!");
829 return new OutputActionCaseBuilder().setOutputAction(outputAction.build()).build();
833 * Method converts OF GroupAction object to SAL GroupAction object
836 * @return GroupAction
838 public static GroupActionCase ofToSALGroupAction(Action action) {
840 GroupActionBuilder groupAction = new GroupActionBuilder();
842 GroupIdAction groupId = action.getAugmentation(GroupIdAction.class);
843 groupAction.setGroupId(groupId.getGroupId());
845 return new GroupActionCaseBuilder().setGroupAction(groupAction.build()).build();
849 * Method converts OF SetMplsTTL action object to SAL SetMplsTTL action
855 public static SetMplsTtlActionCase ofToSALSetMplsTtl(Action action) {
857 SetMplsTtlActionBuilder mplsTtlAction = new SetMplsTtlActionBuilder();
858 MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class);
859 mplsTtlAction.setMplsTtl(mplsTtl.getMplsTtl());
860 return new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(mplsTtlAction.build()).build();
864 * Method converts OF Pushvlan action to SAL PushVlan action.
867 * @return PushVlanAction
869 public static PushVlanActionCase ofToSALPushVlanAction(Action action) {
871 PushVlanActionBuilder pushVlanAction = new PushVlanActionBuilder();
873 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
874 pushVlanAction.setEthernetType(etherType.getEthertype().getValue());
876 return new PushVlanActionCaseBuilder().setPushVlanAction(pushVlanAction.build()).build();
880 * Method converts OF PushMpls action to SAL PushMpls action.
883 * @return PushMplsAction
885 public static PushMplsActionCase ofToSALPushMplsAction(Action action) {
887 PushMplsActionBuilder pushMplsAction = new PushMplsActionBuilder();
889 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
890 pushMplsAction.setEthernetType(etherType.getEthertype().getValue());
892 return new PushMplsActionCaseBuilder().setPushMplsAction(pushMplsAction.build()).build();
896 * Method converts OF PopMpls action to SAL PopMpls action.
899 * @return PopMplsActionCase
901 public static PopMplsActionCase ofToSALPopMplsAction(Action action) {
903 PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder();
905 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
906 popMplsAction.setEthernetType(etherType.getEthertype().getValue());
908 return new PopMplsActionCaseBuilder().setPopMplsAction(popMplsAction.build()).build();
912 * Method converts OF SetQueue action to SAL SetQueue action.
915 * @return SetQueueAction
917 public static SetQueueActionCase ofToSALSetQueue(Action action) {
919 SetQueueActionBuilder setQueueAction = new SetQueueActionBuilder();
921 QueueIdAction queueId = action.getAugmentation(QueueIdAction.class);
922 setQueueAction.setQueueId(queueId.getQueueId());
924 return new SetQueueActionCaseBuilder().setSetQueueAction(setQueueAction.build()).build();
928 * Method converts OF SetNwTtl action to SAL SetNwTtl action.
931 * @return SetNwTtlAction
933 public static SetNwTtlActionCase ofToSALSetNwTtl(Action action) {
935 SetNwTtlActionBuilder setNwTtl = new SetNwTtlActionBuilder();
936 NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class);
937 setNwTtl.setNwTtl(nwTtl.getNwTtl());
939 return new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtl.build()).build();
943 * Method converts OF Pushvlan action to SAL PushVlan action.
946 * @return PushVlanAction
948 public static PushPbbActionCase ofToSALPushPbbAction(Action action) {
950 PushPbbActionBuilder pushPbbAction = new PushPbbActionBuilder();
952 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
953 pushPbbAction.setEthernetType(etherType.getEthertype().getValue());
955 return new PushPbbActionCaseBuilder().setPushPbbAction(pushPbbAction.build()).build();
958 public static Object ofToSALExperimenter(Action action) {
960 ExperimenterAction ExperimenterAction = action.getAugmentation(ExperimenterAction.class);
964 * TODO: Need to explore/discuss about how to handle experimenter