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.openflow.augments.rev131002.DlAddressAction;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
140 import org.opendaylight.yangtools.yang.binding.Augmentation;
141 import org.slf4j.Logger;
142 import org.slf4j.LoggerFactory;
144 import java.math.BigInteger;
145 import java.util.ArrayList;
146 import java.util.List;
149 * @author usha@ericsson Action List:This class takes data from SAL layer and
150 * converts into OF Data
151 * @author avishnoi@in.ibm.com Added convertor for OF bucket actions to SAL
155 public final class ActionConvertor {
156 private static final Logger logger = LoggerFactory.getLogger(ActionConvertor.class);
157 private static final String PREFIX_SEPARATOR = "/";
158 final private static Long MAXPortOF13 = new Long(4294967040L); // 0xffffff00
159 final private static Long MAXPortOF10 = new Long(0xff00);
161 private ActionConvertor() {
166 * Translates SAL actions into OF Library actions
167 * @param actions SAL actions
168 * @param version Openflow protocol version used
170 * @return OF Library actions
172 public static List<Action> getActions(
173 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions,
174 short version, BigInteger datapathid)
177 List<Action> actionsList = new ArrayList<>();
180 for (int actionItem = 0; actionItem < actions.size(); actionItem++) {
182 ActionBuilder actionBuilder = new ActionBuilder();
184 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = actions.get(
185 actionItem).getAction();
187 if (action instanceof OutputActionCase)
188 ofAction = salToOFOutputAction(action, actionBuilder, version);
189 else if (action instanceof GroupActionCase)
190 ofAction = SalToOFGroupAction(action, actionBuilder);
191 else if (action instanceof CopyTtlOutCase)
192 ofAction = SalToOFCopyTTLIOut(actionBuilder);
193 else if (action instanceof CopyTtlInCase)
194 ofAction = SalToOFCopyTTLIIn(actionBuilder);
195 else if (action instanceof SetMplsTtlActionCase)
196 ofAction = SalToOFSetMplsTtl(action, actionBuilder);
197 else if (action instanceof DecMplsTtlCase)
198 ofAction = SalToOFDecMplsTtl(actionBuilder);
199 else if (action instanceof PushVlanActionCase)
200 ofAction = SalToOFPushVlanAction(action, actionBuilder);
201 else if (action instanceof PopVlanActionCase)
202 ofAction = (version == OFConstants.OFP_VERSION_1_0) ? SalToOFStripVlan(actionBuilder, version)
203 : SalToOFPopVlan(actionBuilder);
204 else if (action instanceof PushMplsActionCase)
205 ofAction = SalToOFPushMplsAction(action, actionBuilder);
206 else if (action instanceof PopMplsActionCase)
207 ofAction = SalToOFPopMpls(action, actionBuilder);
208 else if (action instanceof SetQueueActionCase)
209 ofAction = SalToOFSetQueue(action, actionBuilder);
210 else if (action instanceof SetNwTtlActionCase)
211 ofAction = SalToOFSetNwTtl(action, actionBuilder);
212 else if (action instanceof DecNwTtlCase)
213 ofAction = SalToOFDecNwTtl(actionBuilder);
214 else if (action instanceof SetFieldCase)
215 ofAction = SalToOFSetField(action, actionBuilder, version, datapathid);
216 else if (action instanceof PushPbbActionCase)
217 ofAction = SalToOFPushPbbAction(action, actionBuilder);
218 else if (action instanceof PopPbbActionCase)
219 ofAction = SalToOFPopPBB(actionBuilder);
220 else if (action instanceof ExperimenterAction)
221 ofAction = SalToOFExperimenter(action, actionBuilder);
224 else if (action instanceof SetVlanIdActionCase)
225 ofAction = SalToOFSetVlanId(action, actionBuilder, version);
226 else if (action instanceof SetVlanPcpActionCase)
227 ofAction = SalToOFSetVlanpcp(action, actionBuilder, version);
228 else if (action instanceof StripVlanActionCase)
229 ofAction = SalToOFStripVlan(actionBuilder, version);
230 else if (action instanceof SetDlSrcActionCase)
231 ofAction = SalToOFSetDlSrc(action, actionBuilder, version);
232 else if (action instanceof SetDlDstActionCase)
233 ofAction = SalToOFSetDlDst(action, actionBuilder, version);
234 else if (action instanceof SetNwSrcActionCase)
235 ofAction = SalToOFSetNwSrc(action, actionBuilder, version);
236 else if (action instanceof SetNwDstActionCase)
237 ofAction = SalToOFSetNwDst(action, actionBuilder, version);
238 else if (action instanceof SetTpSrcActionCase)
239 ofAction = SalToOFSetTpSrc(action, actionBuilder, version);
240 else if (action instanceof SetTpDstActionCase)
241 ofAction = SalToOFSetTpDst(action, actionBuilder, version);
242 else if (action instanceof SetNwTosActionCase)
243 ofAction = SalToOFSetNwTos(action, actionBuilder, version);
245 if (ofAction != null) {
246 actionsList.add(ofAction);
252 private static Action SalToOFSetField(
253 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
254 ActionBuilder actionBuilder, short version, BigInteger datapathid) {
256 SetFieldCase setFieldCase = (SetFieldCase) action;
257 org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match = setFieldCase
260 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
261 MatchReactor.getInstance().convert(match, version, oxmFieldsActionBuilder, datapathid);
264 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
266 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
267 return actionBuilder.build();
270 private static Action SalToOFDecNwTtl(ActionBuilder actionBuilder) {
272 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class);
273 return emtpyAction(actionBuilder);
276 private static Action SalToOFPushMplsAction(
277 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
278 ActionBuilder actionBuilder) {
279 PushMplsActionCase pushMplsActionCase = (PushMplsActionCase) action;
280 actionBuilder.setType(PushMpls.class);
282 return SalToOFPushAction(pushMplsActionCase.getPushMplsAction().getEthernetType(), actionBuilder);
285 private static Action SalToOFPushPbbAction(
286 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
287 ActionBuilder actionBuilder) {
288 PushPbbActionCase pushPbbActionCase = (PushPbbActionCase) action;
289 actionBuilder.setType(PushPbb.class);
291 return SalToOFPushAction(pushPbbActionCase.getPushPbbAction().getEthernetType(), actionBuilder);
294 private static Action SalToOFPushVlanAction(
295 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
296 ActionBuilder actionBuilder) {
297 PushVlanActionCase pushVlanActionCase = (PushVlanActionCase) action;
298 PushVlanAction pushVlanAction = pushVlanActionCase.getPushVlanAction();
299 actionBuilder.setType(PushVlan.class);
301 return SalToOFPushAction(pushVlanAction.getEthernetType(), actionBuilder);
304 private static Action SalToOFSetNwTtl(
305 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
306 ActionBuilder actionBuilder) {
307 SetNwTtlActionCase nwTtlActionCase = (SetNwTtlActionCase) action;
308 NwTtlActionBuilder nwTtlActionBuilder = new NwTtlActionBuilder();
309 nwTtlActionBuilder.setNwTtl(nwTtlActionCase.getSetNwTtlAction().getNwTtl());
310 actionBuilder.setType(SetNwTtl.class);
311 actionBuilder.addAugmentation(NwTtlAction.class, nwTtlActionBuilder.build());
312 return actionBuilder.build();
315 private static Action SalToOFSetQueue(
316 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
317 ActionBuilder actionBuilder) {
318 SetQueueActionCase setQueueActionCase = (SetQueueActionCase) action;
319 SetQueueAction setQueueAction = setQueueActionCase.getSetQueueAction();
321 QueueIdActionBuilder queueIdActionBuilder = new QueueIdActionBuilder();
322 queueIdActionBuilder.setQueueId(setQueueAction.getQueueId());
323 actionBuilder.setType(SetQueue.class);
324 actionBuilder.addAugmentation(QueueIdAction.class, queueIdActionBuilder.build());
326 return actionBuilder.build();
329 private static Action SalToOFPopMpls(
330 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
331 ActionBuilder actionBuilder) {
332 PopMplsActionCase popMplsActionCase = (PopMplsActionCase) action;
333 actionBuilder.setType(PopMpls.class);
335 return SalToOFPushAction(popMplsActionCase.getPopMplsAction().getEthernetType(), actionBuilder);
338 private static Action SalToOFPopVlan(ActionBuilder actionBuilder) {
339 actionBuilder.setType(PopVlan.class);
340 return emtpyAction(actionBuilder);
343 private static Action SalToOFPopPBB(ActionBuilder actionBuilder) {
344 actionBuilder.setType(PopPbb.class);
345 return emtpyAction(actionBuilder);
348 private static Action SalToOFExperimenter(
349 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
350 ActionBuilder actionBuilder) {
351 ExperimenterActionBuilder experimenterActionBuilder = new ExperimenterActionBuilder();
352 experimenterActionBuilder.setExperimenter(((ExperimenterAction) action).getExperimenter());
353 actionBuilder.setType(Experimenter.class);
356 ExperimenterAction.class,
357 (Augmentation<Action>) experimenterActionBuilder);
358 return actionBuilder.build();
361 private static Action SalToOFSetVlanId(
362 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
363 ActionBuilder actionBuilder, short version) {
365 SetVlanIdActionCase setvlanidcase = (SetVlanIdActionCase) action;
366 SetVlanIdAction setvlanidaction = setvlanidcase.getSetVlanIdAction();
368 if (version == OFConstants.OFP_VERSION_1_0) {
370 VlanVidActionBuilder vlanidActionBuilder = new VlanVidActionBuilder();
371 vlanidActionBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
373 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid.class);
374 actionBuilder.addAugmentation(VlanVidAction.class, vlanidActionBuilder.build());
375 return actionBuilder.build();
376 } else if (version >= OFConstants.OFP_VERSION_1_3) {
377 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
379 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
380 List<MatchEntries> matchEntriesList = new ArrayList<>();
381 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
382 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
383 matchEntriesBuilder.setOxmMatchField(VlanVid.class);
384 VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
385 vlanVidBuilder.setCfiBit(true);
386 vlanVidBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
387 matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
388 matchEntriesBuilder.setHasMask(false);
389 matchEntriesList.add(matchEntriesBuilder.build());
390 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
391 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
392 return actionBuilder.build();
394 logger.error("Unknown Action Type for the Version", version);
399 private static Action SalToOFSetVlanpcp(
400 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
401 ActionBuilder actionBuilder, short version) {
403 SetVlanPcpActionCase setvlanpcpcase = (SetVlanPcpActionCase) action;
404 SetVlanPcpAction setvlanpcpaction = setvlanpcpcase.getSetVlanPcpAction();
406 if (version == OFConstants.OFP_VERSION_1_0) {
407 VlanPcpActionBuilder vlanpcpActionBuilder = new VlanPcpActionBuilder();
408 vlanpcpActionBuilder.setVlanPcp(setvlanpcpaction.getVlanPcp().getValue());
410 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp.class);
411 actionBuilder.addAugmentation(VlanPcpAction.class, vlanpcpActionBuilder.build());
412 return actionBuilder.build();
413 } else if (version >= OFConstants.OFP_VERSION_1_3) {
414 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
416 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
417 List<MatchEntries> matchEntriesList = new ArrayList<>();
418 matchEntriesList.add(MatchConvertorImpl.toOfVlanPcp(setvlanpcpaction.getVlanPcp()));
419 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
420 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
421 return actionBuilder.build();
423 logger.error("Unknown Action Type for the Version", version);
428 private static Action SalToOFStripVlan(ActionBuilder actionBuilder, short version) {
429 if (version == OFConstants.OFP_VERSION_1_0) {
431 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class);
433 return emtpyAction(actionBuilder);
434 } else if (version >= OFConstants.OFP_VERSION_1_3) {
435 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
437 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
438 List<MatchEntries> matchEntriesList = new ArrayList<>();
439 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
440 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
441 matchEntriesBuilder.setOxmMatchField(VlanVid.class);
442 VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
443 vlanVidBuilder.setCfiBit(true);
444 vlanVidBuilder.setVlanVid(new Integer(0x0000));
445 matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
446 matchEntriesBuilder.setHasMask(false);
447 matchEntriesList.add(matchEntriesBuilder.build());
448 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
449 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
450 return actionBuilder.build();
452 logger.error("Unknown Action Type for the Version", version);
457 private static Action SalToOFSetDlSrc(
458 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
459 ActionBuilder actionBuilder, short version) {
461 SetDlSrcActionCase setdlsrccase = (SetDlSrcActionCase) action;
462 SetDlSrcAction setdlsrcaction = setdlsrccase.getSetDlSrcAction();
464 if (version == OFConstants.OFP_VERSION_1_0) {
465 DlAddressActionBuilder dladdressactionbuilder = new DlAddressActionBuilder();
466 dladdressactionbuilder.setDlAddress(setdlsrcaction.getAddress());
468 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc.class);
469 actionBuilder.addAugmentation(DlAddressAction.class, dladdressactionbuilder.build());
470 return actionBuilder.build();
471 } else if (version >= OFConstants.OFP_VERSION_1_3) {
472 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
474 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
475 List<MatchEntries> matchEntriesList = new ArrayList<>();
476 matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthSrc.class, setdlsrcaction.getAddress(), null));
477 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
478 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
479 return actionBuilder.build();
481 logger.error("Unknown Action Type for the Version", version);
487 private static Action SalToOFSetDlDst(
488 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
489 ActionBuilder actionBuilder, short version) {
491 SetDlDstActionCase setdldstcase = (SetDlDstActionCase) action;
492 SetDlDstAction setdldstaction = setdldstcase.getSetDlDstAction();
494 if (version == OFConstants.OFP_VERSION_1_0) {
495 DlAddressActionBuilder dladdressactionbuilder = new DlAddressActionBuilder();
496 dladdressactionbuilder.setDlAddress(setdldstaction.getAddress());
498 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst.class);
499 actionBuilder.addAugmentation(DlAddressAction.class, dladdressactionbuilder.build());
500 return actionBuilder.build();
501 } else if (version >= OFConstants.OFP_VERSION_1_3) {
502 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
504 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
505 List<MatchEntries> matchEntriesList = new ArrayList<>();
506 matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthDst.class, setdldstaction.getAddress(), null));
507 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
508 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
509 return actionBuilder.build();
511 logger.error("Unknown Action Type for the Version", version);
517 protected static Action SalToOFSetNwSrc(
518 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
519 ActionBuilder actionBuilder, short version) {
522 ActionSetNwSrcReactor.getInstance().convert((SetNwSrcActionCase) action, version, actionBuilder, null);
523 } catch (Exception e) {
524 logger.error(e.getMessage(), e);
528 return actionBuilder.build();
531 protected static Action SalToOFSetNwDst(
532 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
533 ActionBuilder actionBuilder, short version) {
536 ActionSetNwDstReactor.getInstance().convert((SetNwDstActionCase) action, version, actionBuilder, null);
537 } catch (Exception e) {
538 logger.error(e.getMessage(), e);
542 return actionBuilder.build();
545 private static Action SalToOFSetNwTos(
546 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
547 ActionBuilder actionBuilder, short version) {
549 SetNwTosActionCase setnwtoscase = (SetNwTosActionCase) action;
550 SetNwTosAction setnwtosaction = setnwtoscase.getSetNwTosAction();
552 if (version == OFConstants.OFP_VERSION_1_0) {
553 NwTosActionBuilder tosBuilder = new NwTosActionBuilder();
554 tosBuilder.setNwTos(setnwtosaction.getTos().shortValue());
555 actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build());
557 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos.class);
559 return actionBuilder.build();
560 } else if (version >= OFConstants.OFP_VERSION_1_3) {
561 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
563 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
564 List<MatchEntries> matchEntriesList = new ArrayList<>();
565 matchEntriesList.add(MatchConvertorImpl.toOfIpDscp(new Dscp(setnwtosaction.getTos().shortValue())));
566 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
567 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
568 return actionBuilder.build();
570 logger.error("Unknown Action Type for the Version", version);
576 private static Action SalToOFSetTpSrc(
577 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
578 ActionBuilder actionBuilder, short version) {
580 if (version == OFConstants.OFP_VERSION_1_0) {
581 SetTpSrcActionCase settpsrccase = (SetTpSrcActionCase) action;
582 SetTpSrcAction settpsrcaction = settpsrccase.getSetTpSrcAction();
584 PortActionBuilder settpsrc = new PortActionBuilder();
585 PortNumber port = new PortNumber(settpsrcaction.getPort().getValue().longValue());
586 settpsrc.setPort(port);
589 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc.class);
590 actionBuilder.addAugmentation(PortAction.class, settpsrc.build());
591 return actionBuilder.build();
593 logger.error("Unknown Action Type for the Version", version);
597 private static Action SalToOFSetTpDst(
598 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
599 ActionBuilder actionBuilder, short version) {
601 if (version == OFConstants.OFP_VERSION_1_0) {
602 SetTpDstActionCase settpdstcase = (SetTpDstActionCase) action;
603 SetTpDstAction settpdstaction = settpdstcase.getSetTpDstAction();
604 PortActionBuilder settpdst = new PortActionBuilder();
605 PortNumber port = new PortNumber(settpdstaction.getPort().getValue().longValue());
606 settpdst.setPort(port);
609 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst.class);
610 actionBuilder.addAugmentation(PortAction.class, settpdst.build());
611 return actionBuilder.build();
613 logger.error("Unknown Action Type for the Version", version);
617 private static Action SalToOFGroupAction(
618 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
619 ActionBuilder actionBuilder) {
621 GroupActionCase groupActionCase = (GroupActionCase) action;
622 GroupAction groupAction = groupActionCase.getGroupAction();
624 GroupIdActionBuilder groupIdBuilder = new GroupIdActionBuilder();
625 groupIdBuilder.setGroupId(groupAction.getGroupId());
626 actionBuilder.setType(Group.class);
627 actionBuilder.addAugmentation(GroupIdAction.class, groupIdBuilder.build());
628 return actionBuilder.build();
631 private static Action SalToOFPushAction(Integer ethernetType, ActionBuilder actionBuilder) {
632 EthertypeActionBuilder ethertypeActionBuilder = new EthertypeActionBuilder();
633 ethertypeActionBuilder.setEthertype(new EtherType(ethernetType));
636 actionBuilder.addAugmentation(EthertypeAction.class, ethertypeActionBuilder.build());
637 return actionBuilder.build();
640 private static Action SalToOFDecMplsTtl(ActionBuilder actionBuilder) {
642 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class);
643 return emtpyAction(actionBuilder);
646 private static Action SalToOFSetMplsTtl(
647 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
648 ActionBuilder actionBuilder) {
649 SetMplsTtlActionCase mplsTtlActionCase = (SetMplsTtlActionCase) action;
650 SetMplsTtlAction mplsTtlAction = mplsTtlActionCase.getSetMplsTtlAction();
652 MplsTtlActionBuilder mplsTtlActionBuilder = new MplsTtlActionBuilder();
653 mplsTtlActionBuilder.setMplsTtl(mplsTtlAction.getMplsTtl()/* SAL */);
655 actionBuilder.setType(SetMplsTtl.class);
656 actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtlActionBuilder.build());
657 return actionBuilder.build();
660 private static Action SalToOFCopyTTLIIn(ActionBuilder actionBuilder) {
662 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class);
663 return emtpyAction(actionBuilder);
666 private static Action SalToOFCopyTTLIOut(ActionBuilder actionBuilder) {
668 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class);
669 return emtpyAction(actionBuilder);
673 private static Action emtpyAction(ActionBuilder actionBuilder) {
674 return actionBuilder.build();
677 private static Action salToOFOutputAction(
678 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
679 ActionBuilder actionBuilder, short version) {
681 OutputActionCase outputActionCase = ((OutputActionCase) action);
682 OutputAction outputAction = outputActionCase.getOutputAction();
683 PortActionBuilder portAction = new PortActionBuilder();
684 MaxLengthActionBuilder maxLenActionBuilder = new MaxLengthActionBuilder();
685 if (outputAction.getMaxLength() != null) {
686 maxLenActionBuilder.setMaxLength(outputAction.getMaxLength());
688 maxLenActionBuilder.setMaxLength(new Integer(0));
690 actionBuilder.addAugmentation(MaxLengthAction.class, maxLenActionBuilder.build());
692 Uri uri = outputAction.getOutputNodeConnector();
694 OpenflowVersion ofVersion = OpenflowVersion.get(version);
695 Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(ofVersion, uri.getValue());
696 if (portNumber != null && (OpenflowPortsUtil.isPortReserved(ofVersion, portNumber) || portNumber < OpenflowPortsUtil.getMaxPortForVersion(ofVersion)) ) {
697 portAction.setPort(new PortNumber(portNumber));
699 logger.error("Invalid Port specified "+ portNumber + " for Output Action for OF version:"+ ofVersion);
702 actionBuilder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
703 actionBuilder.addAugmentation(PortAction.class, portAction.build());
704 return actionBuilder.build();
709 * Method to convert OF actions associated with bucket to SAL Actions.
712 * @param ofVersion current ofp version
713 * @return List of converted SAL Actions.
715 public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> toMDSalActions(
716 List<Action> actionList, OpenflowVersion ofVersion) {
718 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> bucketActions = new ArrayList<>();
719 for (Action action : actionList) {
720 if (action.getType().equals(
721 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class)) {
722 bucketActions.add(ofToSALOutputAction(action));
724 } else if (action.getType().equals(
725 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class)) {
726 bucketActions.add(ofToSALGroupAction(action));
728 } else if (action.getType().equals(
729 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class)) {
730 CopyTtlOutBuilder copyTtlOutaction = new CopyTtlOutBuilder();
731 bucketActions.add(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyTtlOutaction.build()).build());
733 } else if (action.getType().equals(
734 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class)) {
735 CopyTtlInBuilder copyTtlInaction = new CopyTtlInBuilder();
736 bucketActions.add(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInaction.build()).build());
738 } else if (action.getType().equals(
739 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class)) {
740 bucketActions.add(ofToSALSetMplsTtl(action));
742 } else if (action.getType().equals(
743 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class)) {
744 DecMplsTtlBuilder decMplsTtl = new DecMplsTtlBuilder();
745 bucketActions.add(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtl.build()).build());
747 } else if (action.getType().equals(
748 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class)) {
749 bucketActions.add(ofToSALPushVlanAction(action));
751 } else if (action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)
752 || action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class)) {
753 // OF1.0 nodes will emit StripVlan and OF1.3+ will emit StripVlan/PopVlan, convert both to PopVlan for SAL
754 PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
755 bucketActions.add(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
757 } else if (action.getType().equals(
758 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class)) {
759 bucketActions.add(ofToSALPushMplsAction(action));
761 } else if (action.getType().equals(
762 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class)) {
763 bucketActions.add(ofToSALPopMplsAction(action));
765 } else if (action.getType().equals(
766 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class)) {
767 bucketActions.add(ofToSALSetQueue(action));
769 } else if (action.getType().equals(
770 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class)) {
771 bucketActions.add(ofToSALSetNwTtl(action));
773 } else if (action.getType().equals(
774 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class)) {
775 DecNwTtlBuilder decNwTtl = new DecNwTtlBuilder();
776 bucketActions.add(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl.build()).build());
778 } else if (action.getType().equals(
779 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class)) {
780 bucketActions.add(new SetFieldCaseBuilder().setSetField(MatchConvertorImpl.fromOFSetFieldToSALSetFieldAction(action, ofVersion))
782 } else if (action.getType().equals(
783 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class)) {
784 bucketActions.add(ofToSALPushPbbAction(action));
786 } else if (action.getType().equals(
787 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb.class)) {
788 PopPbbActionBuilder popPbb = new PopPbbActionBuilder();
789 bucketActions.add(new PopPbbActionCaseBuilder().setPopPbbAction(popPbb.build()).build());
791 } else if (action.getType().equals(
792 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) {
793 // bucketActions.add(ofToSALExperimenter(action));
794 // TODO: Need to explore/discuss on how to handle experimenter
799 return bucketActions;
803 * Method converts OF Output action object to SAL Output action object.
806 * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.
807 * action.rev130731.actions.actions.list.Action
808 * @return OutputAction
810 public static OutputActionCase ofToSALOutputAction(Action action) {
812 OutputActionBuilder outputAction = new OutputActionBuilder();
813 PortAction port = action.getAugmentation(PortAction.class);
815 outputAction.setOutputNodeConnector(new Uri(port.getPort().getValue().toString()));
817 logger.error("Provided action is not OF Output action, no associated port found!");
820 MaxLengthAction length = action.getAugmentation(MaxLengthAction.class);
821 if (length != null) {
822 outputAction.setMaxLength(length.getMaxLength());
824 logger.error("Provided action is not OF Output action, no associated length found!");
827 return new OutputActionCaseBuilder().setOutputAction(outputAction.build()).build();
831 * Method converts OF GroupAction object to SAL GroupAction object
834 * @return GroupAction
836 public static GroupActionCase ofToSALGroupAction(Action action) {
838 GroupActionBuilder groupAction = new GroupActionBuilder();
840 GroupIdAction groupId = action.getAugmentation(GroupIdAction.class);
841 groupAction.setGroupId(groupId.getGroupId());
843 return new GroupActionCaseBuilder().setGroupAction(groupAction.build()).build();
847 * Method converts OF SetMplsTTL action object to SAL SetMplsTTL action
853 public static SetMplsTtlActionCase ofToSALSetMplsTtl(Action action) {
855 SetMplsTtlActionBuilder mplsTtlAction = new SetMplsTtlActionBuilder();
856 MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class);
857 mplsTtlAction.setMplsTtl(mplsTtl.getMplsTtl());
858 return new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(mplsTtlAction.build()).build();
862 * Method converts OF Pushvlan action to SAL PushVlan action.
865 * @return PushVlanAction
867 public static PushVlanActionCase ofToSALPushVlanAction(Action action) {
869 PushVlanActionBuilder pushVlanAction = new PushVlanActionBuilder();
871 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
872 pushVlanAction.setEthernetType(etherType.getEthertype().getValue());
874 return new PushVlanActionCaseBuilder().setPushVlanAction(pushVlanAction.build()).build();
878 * Method converts OF PushMpls action to SAL PushMpls action.
881 * @return PushMplsAction
883 public static PushMplsActionCase ofToSALPushMplsAction(Action action) {
885 PushMplsActionBuilder pushMplsAction = new PushMplsActionBuilder();
887 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
888 pushMplsAction.setEthernetType(etherType.getEthertype().getValue());
890 return new PushMplsActionCaseBuilder().setPushMplsAction(pushMplsAction.build()).build();
894 * Method converts OF PopMpls action to SAL PopMpls action.
897 * @return PopMplsActionCase
899 public static PopMplsActionCase ofToSALPopMplsAction(Action action) {
901 PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder();
903 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
904 popMplsAction.setEthernetType(etherType.getEthertype().getValue());
906 return new PopMplsActionCaseBuilder().setPopMplsAction(popMplsAction.build()).build();
910 * Method converts OF SetQueue action to SAL SetQueue action.
913 * @return SetQueueAction
915 public static SetQueueActionCase ofToSALSetQueue(Action action) {
917 SetQueueActionBuilder setQueueAction = new SetQueueActionBuilder();
919 QueueIdAction queueId = action.getAugmentation(QueueIdAction.class);
920 setQueueAction.setQueueId(queueId.getQueueId());
922 return new SetQueueActionCaseBuilder().setSetQueueAction(setQueueAction.build()).build();
926 * Method converts OF SetNwTtl action to SAL SetNwTtl action.
929 * @return SetNwTtlAction
931 public static SetNwTtlActionCase ofToSALSetNwTtl(Action action) {
933 SetNwTtlActionBuilder setNwTtl = new SetNwTtlActionBuilder();
934 NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class);
935 setNwTtl.setNwTtl(nwTtl.getNwTtl());
937 return new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtl.build()).build();
941 * Method converts OF Pushvlan action to SAL PushVlan action.
944 * @return PushVlanAction
946 public static PushPbbActionCase ofToSALPushPbbAction(Action action) {
948 PushPbbActionBuilder pushPbbAction = new PushPbbActionBuilder();
950 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
951 pushPbbAction.setEthernetType(etherType.getEthertype().getValue());
953 return new PushPbbActionCaseBuilder().setPushPbbAction(pushPbbAction.build()).build();
956 public static Object ofToSALExperimenter(Action action) {
958 ExperimenterAction ExperimenterAction = action.getAugmentation(ExperimenterAction.class);
962 * TODO: Need to explore/discuss about how to handle experimenter