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 java.math.BigInteger;
13 import java.util.ArrayList;
14 import java.util.List;
16 import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
17 import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
18 import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
19 import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
20 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
21 import org.opendaylight.openflowplugin.openflow.md.OFConstants;
22 import org.opendaylight.openflowplugin.openflow.md.core.extension.ActionExtensionHelper;
23 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwDstReactor;
24 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwSrcReactor;
25 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
26 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
27 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
28 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
29 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
30 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
31 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowVersion;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
33 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCase;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanAction;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstAction;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcAction;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosAction;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueAction;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdAction;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpAction;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.CommonPort;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionGrouping;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
153 import org.slf4j.Logger;
154 import org.slf4j.LoggerFactory;
156 import com.google.common.collect.Ordering;
159 * @author usha@ericsson Action List:This class takes data from SAL layer and
160 * converts into OF Data
161 * @author avishnoi@in.ibm.com Added convertor for OF bucket actions to SAL
164 public final class ActionConvertor {
165 private static final Logger logger = LoggerFactory.getLogger(ActionConvertor.class);
167 private ActionConvertor() {
172 * Translates SAL actions into OF Library actions
174 * @param actions SAL actions
175 * @param version Openflow protocol version used
177 * @return OF Library actions
179 public static List<Action> getActions(
180 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions,
181 short version, BigInteger datapathid) {
182 List<Action> actionsList = new ArrayList<>();
185 actions = Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>toInstance())
186 .sortedCopy(actions);
188 for (int actionItem = 0; actionItem < actions.size(); actionItem++) {
190 ActionBuilder actionBuilder = new ActionBuilder();
192 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = actions.get(
193 actionItem).getAction();
195 if (action instanceof OutputActionCase)
196 ofAction = salToOFOutputAction(action, actionBuilder, version);
197 else if (action instanceof GroupActionCase)
198 ofAction = SalToOFGroupAction(action, actionBuilder);
199 else if (action instanceof CopyTtlOutCase)
200 ofAction = SalToOFCopyTTLIOut(actionBuilder);
201 else if (action instanceof CopyTtlInCase)
202 ofAction = SalToOFCopyTTLIIn(actionBuilder);
203 else if (action instanceof SetMplsTtlActionCase)
204 ofAction = SalToOFSetMplsTtl(action, actionBuilder);
205 else if (action instanceof DecMplsTtlCase)
206 ofAction = SalToOFDecMplsTtl(actionBuilder);
207 else if (action instanceof PushVlanActionCase)
208 ofAction = SalToOFPushVlanAction(action, actionBuilder);
209 else if (action instanceof PopVlanActionCase)
210 ofAction = (version == OFConstants.OFP_VERSION_1_0) ? SalToOFStripVlan(actionBuilder, version)
211 : SalToOFPopVlan(actionBuilder);
212 else if (action instanceof PushMplsActionCase)
213 ofAction = SalToOFPushMplsAction(action, actionBuilder);
214 else if (action instanceof PopMplsActionCase)
215 ofAction = SalToOFPopMpls(action, actionBuilder);
216 else if (action instanceof SetQueueActionCase)
217 ofAction = SalToOFSetQueue(action, actionBuilder);
218 else if (action instanceof SetNwTtlActionCase)
219 ofAction = SalToOFSetNwTtl(action, actionBuilder);
220 else if (action instanceof DecNwTtlCase)
221 ofAction = SalToOFDecNwTtl(actionBuilder);
222 else if (action instanceof SetFieldCase)
223 ofAction = SalToOFSetField(action, actionBuilder, version, datapathid);
224 else if (action instanceof PushPbbActionCase)
225 ofAction = SalToOFPushPbbAction(action, actionBuilder);
226 else if (action instanceof PopPbbActionCase)
227 ofAction = SalToOFPopPBB(actionBuilder);
230 else if (action instanceof SetVlanIdActionCase)
231 ofAction = SalToOFSetVlanId(action, actionBuilder, version);
232 else if (action instanceof SetVlanPcpActionCase)
233 ofAction = SalToOFSetVlanpcp(action, actionBuilder, version);
234 else if (action instanceof StripVlanActionCase)
235 ofAction = SalToOFStripVlan(actionBuilder, version);
236 else if (action instanceof SetDlSrcActionCase)
237 ofAction = SalToOFSetDlSrc(action, actionBuilder, version);
238 else if (action instanceof SetDlDstActionCase)
239 ofAction = SalToOFSetDlDst(action, actionBuilder, version);
240 else if (action instanceof SetNwSrcActionCase)
241 ofAction = SalToOFSetNwSrc(action, actionBuilder, version);
242 else if (action instanceof SetNwDstActionCase)
243 ofAction = SalToOFSetNwDst(action, actionBuilder, version);
244 else if (action instanceof SetTpSrcActionCase)
245 ofAction = SalToOFSetTpSrc(action, actionBuilder, version);
246 else if (action instanceof SetTpDstActionCase)
247 ofAction = SalToOFSetTpDst(action, actionBuilder, version);
248 else if (action instanceof SetNwTosActionCase)
249 ofAction = SalToOFSetNwTos(action, actionBuilder, version);
250 else if (action instanceof GeneralExtensionGrouping) {
253 * TODO: EXTENSION PROPOSAL (action, MD-SAL to OFJava)
254 * - we might need sessionContext as converter input
258 GeneralExtensionGrouping extensionCaseGrouping = (GeneralExtensionGrouping) action;
259 Extension extAction = extensionCaseGrouping.getExtension();
260 ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(extensionCaseGrouping.getExtensionKey(), version);
261 ConvertorToOFJava<Action> convertor =
262 OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
263 if (convertor != null) {
264 ofAction = convertor.convert(extAction);
268 TypeVersionKey<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> key =
269 new TypeVersionKey<>(
270 (Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>) action.getImplementedInterface(),
272 ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action> convertor =
273 OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
274 if (convertor != null) {
275 ofAction = convertor.convert(action);
279 if (ofAction != null) {
280 actionsList.add(ofAction);
286 private static Action SalToOFSetField(
287 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
288 ActionBuilder actionBuilder, short version, BigInteger datapathid) {
290 SetFieldCase setFieldCase = (SetFieldCase) action;
291 org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match = setFieldCase
294 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
295 MatchReactor.getInstance().convert(match, version, oxmFieldsActionBuilder, datapathid);
298 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
300 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
301 return actionBuilder.build();
304 private static Action SalToOFDecNwTtl(ActionBuilder actionBuilder) {
306 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class);
307 return emtpyAction(actionBuilder);
310 private static Action SalToOFPushMplsAction(
311 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
312 ActionBuilder actionBuilder) {
313 PushMplsActionCase pushMplsActionCase = (PushMplsActionCase) action;
314 actionBuilder.setType(PushMpls.class);
316 return SalToOFPushAction(pushMplsActionCase.getPushMplsAction().getEthernetType(), actionBuilder);
319 private static Action SalToOFPushPbbAction(
320 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
321 ActionBuilder actionBuilder) {
322 PushPbbActionCase pushPbbActionCase = (PushPbbActionCase) action;
323 actionBuilder.setType(PushPbb.class);
325 return SalToOFPushAction(pushPbbActionCase.getPushPbbAction().getEthernetType(), actionBuilder);
328 private static Action SalToOFPushVlanAction(
329 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
330 ActionBuilder actionBuilder) {
331 PushVlanActionCase pushVlanActionCase = (PushVlanActionCase) action;
332 PushVlanAction pushVlanAction = pushVlanActionCase.getPushVlanAction();
333 actionBuilder.setType(PushVlan.class);
335 return SalToOFPushAction(pushVlanAction.getEthernetType(), actionBuilder);
338 private static Action SalToOFSetNwTtl(
339 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
340 ActionBuilder actionBuilder) {
341 SetNwTtlActionCase nwTtlActionCase = (SetNwTtlActionCase) action;
342 NwTtlActionBuilder nwTtlActionBuilder = new NwTtlActionBuilder();
343 nwTtlActionBuilder.setNwTtl(nwTtlActionCase.getSetNwTtlAction().getNwTtl());
344 actionBuilder.setType(SetNwTtl.class);
345 actionBuilder.addAugmentation(NwTtlAction.class, nwTtlActionBuilder.build());
346 return actionBuilder.build();
349 private static Action SalToOFSetQueue(
350 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
351 ActionBuilder actionBuilder) {
352 SetQueueActionCase setQueueActionCase = (SetQueueActionCase) action;
353 SetQueueAction setQueueAction = setQueueActionCase.getSetQueueAction();
355 QueueIdActionBuilder queueIdActionBuilder = new QueueIdActionBuilder();
356 queueIdActionBuilder.setQueueId(setQueueAction.getQueueId());
357 actionBuilder.setType(SetQueue.class);
358 actionBuilder.addAugmentation(QueueIdAction.class, queueIdActionBuilder.build());
360 return actionBuilder.build();
363 private static Action SalToOFPopMpls(
364 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
365 ActionBuilder actionBuilder) {
366 PopMplsActionCase popMplsActionCase = (PopMplsActionCase) action;
367 actionBuilder.setType(PopMpls.class);
369 return SalToOFPushAction(popMplsActionCase.getPopMplsAction().getEthernetType(), actionBuilder);
372 private static Action SalToOFPopVlan(ActionBuilder actionBuilder) {
373 actionBuilder.setType(PopVlan.class);
374 return emtpyAction(actionBuilder);
377 private static Action SalToOFPopPBB(ActionBuilder actionBuilder) {
378 actionBuilder.setType(PopPbb.class);
379 return emtpyAction(actionBuilder);
382 private static Action SalToOFSetVlanId(
383 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
384 ActionBuilder actionBuilder, short version) {
386 SetVlanIdActionCase setvlanidcase = (SetVlanIdActionCase) action;
387 SetVlanIdAction setvlanidaction = setvlanidcase.getSetVlanIdAction();
389 if (version == OFConstants.OFP_VERSION_1_0) {
391 VlanVidActionBuilder vlanidActionBuilder = new VlanVidActionBuilder();
392 vlanidActionBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
394 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid.class);
395 actionBuilder.addAugmentation(VlanVidAction.class, vlanidActionBuilder.build());
396 return actionBuilder.build();
397 } else if (version >= OFConstants.OFP_VERSION_1_3) {
398 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
400 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
401 List<MatchEntries> matchEntriesList = new ArrayList<>();
402 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
403 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
404 matchEntriesBuilder.setOxmMatchField(VlanVid.class);
405 VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
406 vlanVidBuilder.setCfiBit(true);
407 vlanVidBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
408 matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
409 matchEntriesBuilder.setHasMask(false);
410 matchEntriesList.add(matchEntriesBuilder.build());
411 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
412 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
413 return actionBuilder.build();
415 logger.error("Unknown Action Type for the Version", version);
420 private static Action SalToOFSetVlanpcp(
421 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
422 ActionBuilder actionBuilder, short version) {
424 SetVlanPcpActionCase setvlanpcpcase = (SetVlanPcpActionCase) action;
425 SetVlanPcpAction setvlanpcpaction = setvlanpcpcase.getSetVlanPcpAction();
427 if (version == OFConstants.OFP_VERSION_1_0) {
428 VlanPcpActionBuilder vlanpcpActionBuilder = new VlanPcpActionBuilder();
429 vlanpcpActionBuilder.setVlanPcp(setvlanpcpaction.getVlanPcp().getValue());
431 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp.class);
432 actionBuilder.addAugmentation(VlanPcpAction.class, vlanpcpActionBuilder.build());
433 return actionBuilder.build();
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 matchEntriesList.add(MatchConvertorImpl.toOfVlanPcp(setvlanpcpaction.getVlanPcp()));
440 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
441 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
442 return actionBuilder.build();
444 logger.error("Unknown Action Type for the Version", version);
449 private static Action SalToOFStripVlan(ActionBuilder actionBuilder, short version) {
450 if (version == OFConstants.OFP_VERSION_1_0) {
452 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class);
454 return emtpyAction(actionBuilder);
455 } else if (version >= OFConstants.OFP_VERSION_1_3) {
456 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
458 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
459 List<MatchEntries> matchEntriesList = new ArrayList<>();
460 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
461 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
462 matchEntriesBuilder.setOxmMatchField(VlanVid.class);
463 VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
464 vlanVidBuilder.setCfiBit(true);
465 vlanVidBuilder.setVlanVid(0x0000);
466 matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
467 matchEntriesBuilder.setHasMask(false);
468 matchEntriesList.add(matchEntriesBuilder.build());
469 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
470 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
471 return actionBuilder.build();
473 logger.error("Unknown Action Type for the Version", version);
478 private static Action SalToOFSetDlSrc(
479 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
480 ActionBuilder actionBuilder, short version) {
482 SetDlSrcActionCase setdlsrccase = (SetDlSrcActionCase) action;
483 SetDlSrcAction setdlsrcaction = setdlsrccase.getSetDlSrcAction();
485 if (version == OFConstants.OFP_VERSION_1_0) {
486 DlAddressActionBuilder dladdressactionbuilder = new DlAddressActionBuilder();
487 dladdressactionbuilder.setDlAddress(setdlsrcaction.getAddress());
489 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc.class);
490 actionBuilder.addAugmentation(DlAddressAction.class, dladdressactionbuilder.build());
491 return actionBuilder.build();
492 } else if (version >= OFConstants.OFP_VERSION_1_3) {
493 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
495 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
496 List<MatchEntries> matchEntriesList = new ArrayList<>();
497 matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthSrc.class, setdlsrcaction.getAddress(), null));
498 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
499 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
500 return actionBuilder.build();
502 logger.error("Unknown Action Type for the Version", version);
508 private static Action SalToOFSetDlDst(
509 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
510 ActionBuilder actionBuilder, short version) {
512 SetDlDstActionCase setdldstcase = (SetDlDstActionCase) action;
513 SetDlDstAction setdldstaction = setdldstcase.getSetDlDstAction();
515 if (version == OFConstants.OFP_VERSION_1_0) {
516 DlAddressActionBuilder dladdressactionbuilder = new DlAddressActionBuilder();
517 dladdressactionbuilder.setDlAddress(setdldstaction.getAddress());
519 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst.class);
520 actionBuilder.addAugmentation(DlAddressAction.class, dladdressactionbuilder.build());
521 return actionBuilder.build();
522 } else if (version >= OFConstants.OFP_VERSION_1_3) {
523 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
525 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
526 List<MatchEntries> matchEntriesList = new ArrayList<>();
527 matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthDst.class, setdldstaction.getAddress(), null));
528 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
529 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
530 return actionBuilder.build();
532 logger.error("Unknown Action Type for the Version", version);
538 protected static Action SalToOFSetNwSrc(
539 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
540 ActionBuilder actionBuilder, short version) {
543 ActionSetNwSrcReactor.getInstance().convert((SetNwSrcActionCase) action, version, actionBuilder, null);
544 } catch (Exception e) {
545 logger.error(e.getMessage(), e);
549 return actionBuilder.build();
552 protected static Action SalToOFSetNwDst(
553 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
554 ActionBuilder actionBuilder, short version) {
557 ActionSetNwDstReactor.getInstance().convert((SetNwDstActionCase) action, version, actionBuilder, null);
558 } catch (Exception e) {
559 logger.error(e.getMessage(), e);
563 return actionBuilder.build();
566 private static Action SalToOFSetNwTos(
567 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
568 ActionBuilder actionBuilder, short version) {
570 SetNwTosActionCase setnwtoscase = (SetNwTosActionCase) action;
571 SetNwTosAction setnwtosaction = setnwtoscase.getSetNwTosAction();
573 if (version == OFConstants.OFP_VERSION_1_0) {
574 NwTosActionBuilder tosBuilder = new NwTosActionBuilder();
575 tosBuilder.setNwTos(setnwtosaction.getTos().shortValue());
576 actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build());
578 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos.class);
580 return actionBuilder.build();
581 } else if (version >= OFConstants.OFP_VERSION_1_3) {
582 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
584 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
585 List<MatchEntries> matchEntriesList = new ArrayList<>();
586 matchEntriesList.add(MatchConvertorImpl.toOfIpDscp(new Dscp(setnwtosaction.getTos().shortValue())));
587 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
588 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
589 return actionBuilder.build();
591 logger.error("Unknown Action Type for the Version", version);
597 private static Action SalToOFSetTpSrc(
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 SetTpSrcActionCase settpsrccase = (SetTpSrcActionCase) action;
603 SetTpSrcAction settpsrcaction = settpsrccase.getSetTpSrcAction();
605 PortActionBuilder settpsrc = new PortActionBuilder();
606 PortNumber port = new PortNumber(settpsrcaction.getPort().getValue().longValue());
607 settpsrc.setPort(port);
610 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc.class);
611 actionBuilder.addAugmentation(PortAction.class, settpsrc.build());
612 return actionBuilder.build();
614 logger.error("Unknown Action Type for the Version", version);
618 private static Action SalToOFSetTpDst(
619 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
620 ActionBuilder actionBuilder, short version) {
622 if (version == OFConstants.OFP_VERSION_1_0) {
623 SetTpDstActionCase settpdstcase = (SetTpDstActionCase) action;
624 SetTpDstAction settpdstaction = settpdstcase.getSetTpDstAction();
625 PortActionBuilder settpdst = new PortActionBuilder();
626 PortNumber port = new PortNumber(settpdstaction.getPort().getValue().longValue());
627 settpdst.setPort(port);
630 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst.class);
631 actionBuilder.addAugmentation(PortAction.class, settpdst.build());
632 return actionBuilder.build();
634 logger.error("Unknown Action Type for the Version", version);
638 private static Action SalToOFGroupAction(
639 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
640 ActionBuilder actionBuilder) {
642 GroupActionCase groupActionCase = (GroupActionCase) action;
643 GroupAction groupAction = groupActionCase.getGroupAction();
645 GroupIdActionBuilder groupIdBuilder = new GroupIdActionBuilder();
646 groupIdBuilder.setGroupId(groupAction.getGroupId());
647 actionBuilder.setType(Group.class);
648 actionBuilder.addAugmentation(GroupIdAction.class, groupIdBuilder.build());
649 return actionBuilder.build();
652 private static Action SalToOFPushAction(Integer ethernetType, ActionBuilder actionBuilder) {
653 EthertypeActionBuilder ethertypeActionBuilder = new EthertypeActionBuilder();
654 if (ethernetType != null) {
655 ethertypeActionBuilder.setEthertype(new EtherType(ethernetType));
659 actionBuilder.addAugmentation(EthertypeAction.class, ethertypeActionBuilder.build());
660 return actionBuilder.build();
663 private static Action SalToOFDecMplsTtl(ActionBuilder actionBuilder) {
665 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class);
666 return emtpyAction(actionBuilder);
669 private static Action SalToOFSetMplsTtl(
670 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
671 ActionBuilder actionBuilder) {
672 SetMplsTtlActionCase mplsTtlActionCase = (SetMplsTtlActionCase) action;
673 SetMplsTtlAction mplsTtlAction = mplsTtlActionCase.getSetMplsTtlAction();
675 MplsTtlActionBuilder mplsTtlActionBuilder = new MplsTtlActionBuilder();
676 mplsTtlActionBuilder.setMplsTtl(mplsTtlAction.getMplsTtl()/* SAL */);
678 actionBuilder.setType(SetMplsTtl.class);
679 actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtlActionBuilder.build());
680 return actionBuilder.build();
683 private static Action SalToOFCopyTTLIIn(ActionBuilder actionBuilder) {
685 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class);
686 return emtpyAction(actionBuilder);
689 private static Action SalToOFCopyTTLIOut(ActionBuilder actionBuilder) {
691 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class);
692 return emtpyAction(actionBuilder);
696 private static Action emtpyAction(ActionBuilder actionBuilder) {
697 return actionBuilder.build();
700 private static Action salToOFOutputAction(
701 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
702 ActionBuilder actionBuilder, short version) {
704 OutputActionCase outputActionCase = ((OutputActionCase) action);
705 OutputAction outputAction = outputActionCase.getOutputAction();
706 PortActionBuilder portAction = new PortActionBuilder();
707 MaxLengthActionBuilder maxLenActionBuilder = new MaxLengthActionBuilder();
708 if (outputAction.getMaxLength() != null) {
709 maxLenActionBuilder.setMaxLength(outputAction.getMaxLength());
711 maxLenActionBuilder.setMaxLength(0);
713 actionBuilder.addAugmentation(MaxLengthAction.class, maxLenActionBuilder.build());
715 Uri uri = outputAction.getOutputNodeConnector();
717 OpenflowVersion ofVersion = OpenflowVersion.get(version);
718 Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(ofVersion, uri.getValue());
719 if (OpenflowPortsUtil.checkPortValidity(ofVersion, portNumber)) {
720 portAction.setPort(new PortNumber(portNumber));
722 logger.error("Invalid Port specified " + portNumber + " for Output Action for OF version:" + ofVersion);
725 actionBuilder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
726 actionBuilder.addAugmentation(PortAction.class, portAction.build());
727 return actionBuilder.build();
732 * Method to convert OF actions associated with bucket to SAL Actions.
735 * @param ofVersion current ofp version
736 * @param actionPath TODO
737 * @return List of converted SAL Actions.
739 public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> toMDSalActions(
740 List<Action> actionList, OpenflowVersion ofVersion, ActionPath actionPath) {
742 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> bucketActions = new ArrayList<>();
743 for (Action action : actionList) {
744 if (action.getType().equals(
745 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class)) {
746 bucketActions.add(ofToSALOutputAction(ofVersion, action));
748 } else if (action.getType().equals(
749 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class)) {
750 bucketActions.add(ofToSALGroupAction(action));
752 } else if (action.getType().equals(
753 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class)) {
754 CopyTtlOutBuilder copyTtlOutaction = new CopyTtlOutBuilder();
755 bucketActions.add(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyTtlOutaction.build()).build());
757 } else if (action.getType().equals(
758 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class)) {
759 CopyTtlInBuilder copyTtlInaction = new CopyTtlInBuilder();
760 bucketActions.add(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInaction.build()).build());
762 } else if (action.getType().equals(
763 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class)) {
764 bucketActions.add(ofToSALSetMplsTtl(action));
766 } else if (action.getType().equals(
767 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class)) {
768 DecMplsTtlBuilder decMplsTtl = new DecMplsTtlBuilder();
769 bucketActions.add(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtl.build()).build());
771 } else if (action.getType().equals(
772 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class)) {
773 bucketActions.add(ofToSALPushVlanAction(action));
775 } else if (action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)
776 || action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class)) {
777 // OF1.0 nodes will emit StripVlan and OF1.3+ will emit StripVlan/PopVlan, convert both to PopVlan for SAL
778 PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
779 bucketActions.add(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
781 } else if (action.getType().equals(
782 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class)) {
783 bucketActions.add(ofToSALPushMplsAction(action));
785 } else if (action.getType().equals(
786 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class)) {
787 bucketActions.add(ofToSALPopMplsAction(action));
789 } else if (action.getType().equals(
790 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class)) {
791 bucketActions.add(ofToSALSetQueue(action));
793 } else if (action.getType().equals(
794 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class)) {
795 bucketActions.add(ofToSALSetNwTtl(action));
797 } else if (action.getType().equals(
798 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class)) {
799 DecNwTtlBuilder decNwTtl = new DecNwTtlBuilder();
800 bucketActions.add(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl.build()).build());
802 } else if (action.getType().equals(
803 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class)) {
804 bucketActions.add(new SetFieldCaseBuilder().setSetField(MatchConvertorImpl.fromOFSetFieldToSALSetFieldAction(action, ofVersion))
806 } else if (action.getType().equals(
807 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class)) {
808 bucketActions.add(ofToSALPushPbbAction(action));
810 } else if (action.getType().equals(
811 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb.class)) {
812 PopPbbActionBuilder popPbb = new PopPbbActionBuilder();
813 bucketActions.add(new PopPbbActionCaseBuilder().setPopPbbAction(popPbb.build()).build());
815 } else if (action.getType().equals(
816 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) {
818 * TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
819 * - we might also need a way on how to identify exact type of augmentation to be
820 * used as match can be bound to multiple models
822 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action processedAction =
823 ActionExtensionHelper.processAlienAction(action, ofVersion, actionPath);
824 if (processedAction != null) {
825 bucketActions.add(processedAction);
829 return bucketActions;
833 * Method converts OF Output action object to SAL Output action object.
837 * @param action org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.
838 * action.rev130731.actions.actions.list.Action
839 * @return OutputAction
841 public static OutputActionCase ofToSALOutputAction(OpenflowVersion ofVersion, Action action) {
842 OutputActionBuilder outputAction = new OutputActionBuilder();
843 PortAction port = action.getAugmentation(PortAction.class);
845 CommonPort.PortNumber protocolAgnosticPort = OpenflowPortsUtil.getProtocolAgnosticPort(
846 ofVersion, port.getPort().getValue());
847 String portNumberAsString = OpenflowPortsUtil.portNumberToString(protocolAgnosticPort);
848 outputAction.setOutputNodeConnector(new Uri(portNumberAsString));
850 logger.error("Provided action is not OF Output action, no associated port found!");
853 MaxLengthAction length = action.getAugmentation(MaxLengthAction.class);
854 if (length != null) {
855 outputAction.setMaxLength(length.getMaxLength());
857 logger.error("Provided action is not OF Output action, no associated length found!");
860 return new OutputActionCaseBuilder().setOutputAction(outputAction.build()).build();
864 * Method converts OF GroupAction object to SAL GroupAction object
867 * @return GroupAction
869 public static GroupActionCase ofToSALGroupAction(Action action) {
871 GroupActionBuilder groupAction = new GroupActionBuilder();
873 GroupIdAction groupId = action.getAugmentation(GroupIdAction.class);
874 groupAction.setGroupId(groupId.getGroupId());
876 return new GroupActionCaseBuilder().setGroupAction(groupAction.build()).build();
880 * Method converts OF SetMplsTTL action object to SAL SetMplsTTL action
886 public static SetMplsTtlActionCase ofToSALSetMplsTtl(Action action) {
888 SetMplsTtlActionBuilder mplsTtlAction = new SetMplsTtlActionBuilder();
889 MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class);
890 mplsTtlAction.setMplsTtl(mplsTtl.getMplsTtl());
891 return new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(mplsTtlAction.build()).build();
895 * Method converts OF Pushvlan action to SAL PushVlan action.
898 * @return PushVlanAction
900 public static PushVlanActionCase ofToSALPushVlanAction(Action action) {
902 PushVlanActionBuilder pushVlanAction = new PushVlanActionBuilder();
904 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
905 pushVlanAction.setEthernetType(etherType.getEthertype().getValue());
907 return new PushVlanActionCaseBuilder().setPushVlanAction(pushVlanAction.build()).build();
911 * Method converts OF PushMpls action to SAL PushMpls action.
914 * @return PushMplsAction
916 public static PushMplsActionCase ofToSALPushMplsAction(Action action) {
918 PushMplsActionBuilder pushMplsAction = new PushMplsActionBuilder();
920 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
921 pushMplsAction.setEthernetType(etherType.getEthertype().getValue());
923 return new PushMplsActionCaseBuilder().setPushMplsAction(pushMplsAction.build()).build();
927 * Method converts OF PopMpls action to SAL PopMpls action.
930 * @return PopMplsActionCase
932 public static PopMplsActionCase ofToSALPopMplsAction(Action action) {
934 PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder();
936 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
937 popMplsAction.setEthernetType(etherType.getEthertype().getValue());
939 return new PopMplsActionCaseBuilder().setPopMplsAction(popMplsAction.build()).build();
943 * Method converts OF SetQueue action to SAL SetQueue action.
946 * @return SetQueueAction
948 public static SetQueueActionCase ofToSALSetQueue(Action action) {
950 SetQueueActionBuilder setQueueAction = new SetQueueActionBuilder();
952 QueueIdAction queueId = action.getAugmentation(QueueIdAction.class);
953 setQueueAction.setQueueId(queueId.getQueueId());
955 return new SetQueueActionCaseBuilder().setSetQueueAction(setQueueAction.build()).build();
959 * Method converts OF SetNwTtl action to SAL SetNwTtl action.
962 * @return SetNwTtlAction
964 public static SetNwTtlActionCase ofToSALSetNwTtl(Action action) {
966 SetNwTtlActionBuilder setNwTtl = new SetNwTtlActionBuilder();
967 NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class);
968 setNwTtl.setNwTtl(nwTtl.getNwTtl());
970 return new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtl.build()).build();
974 * Method converts OF Pushvlan action to SAL PushVlan action.
977 * @return PushVlanAction
979 public static PushPbbActionCase ofToSALPushPbbAction(Action action) {
981 PushPbbActionBuilder pushPbbAction = new PushPbbActionBuilder();
983 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
984 pushPbbAction.setEthernetType(etherType.getEthertype().getValue());
986 return new PushPbbActionCaseBuilder().setPushPbbAction(pushPbbAction.build()).build();