Bug-1307 - unit test failing (NPE)
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / ActionConvertor.java
1 /**
2  * Copyright (c) 2014 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
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
7  *
8  * Contributor: hema.gopalkrishnan@ericsson.com
9  */
10 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
11
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.*;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanAction;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstAction;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcAction;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosAction;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueAction;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdAction;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpAction;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.CommonPort;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.*;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.*;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
63 import org.opendaylight.yangtools.yang.binding.Augmentation;
64 import org.slf4j.Logger;
65 import org.slf4j.LoggerFactory;
66
67 import java.math.BigInteger;
68 import java.util.ArrayList;
69 import java.util.List;
70
71 /**
72  * @author usha@ericsson Action List:This class takes data from SAL layer and
73  *         converts into OF Data
74  * @author avishnoi@in.ibm.com Added convertor for OF bucket actions to SAL
75  *         actions
76  */
77 public final class ActionConvertor {
78     private static final Logger logger = LoggerFactory.getLogger(ActionConvertor.class);
79
80     private ActionConvertor() {
81         // NOOP
82     }
83
84     /**
85      * Translates SAL actions into OF Library actions
86      *
87      * @param actions    SAL actions
88      * @param version    Openflow protocol version used
89      * @param datapathid
90      * @return OF Library actions
91      */
92     public static List<Action> getActions(
93             List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions,
94             short version, BigInteger datapathid)
95
96     {
97         List<Action> actionsList = new ArrayList<>();
98         Action ofAction;
99
100         for (int actionItem = 0; actionItem < actions.size(); actionItem++) {
101             ofAction = null;
102             ActionBuilder actionBuilder = new ActionBuilder();
103
104             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = actions.get(
105                     actionItem).getAction();
106
107             if (action instanceof OutputActionCase)
108                 ofAction = salToOFOutputAction(action, actionBuilder, version);
109             else if (action instanceof GroupActionCase)
110                 ofAction = SalToOFGroupAction(action, actionBuilder);
111             else if (action instanceof CopyTtlOutCase)
112                 ofAction = SalToOFCopyTTLIOut(actionBuilder);
113             else if (action instanceof CopyTtlInCase)
114                 ofAction = SalToOFCopyTTLIIn(actionBuilder);
115             else if (action instanceof SetMplsTtlActionCase)
116                 ofAction = SalToOFSetMplsTtl(action, actionBuilder);
117             else if (action instanceof DecMplsTtlCase)
118                 ofAction = SalToOFDecMplsTtl(actionBuilder);
119             else if (action instanceof PushVlanActionCase)
120                 ofAction = SalToOFPushVlanAction(action, actionBuilder);
121             else if (action instanceof PopVlanActionCase)
122                 ofAction = (version == OFConstants.OFP_VERSION_1_0) ? SalToOFStripVlan(actionBuilder, version)
123                         : SalToOFPopVlan(actionBuilder);
124             else if (action instanceof PushMplsActionCase)
125                 ofAction = SalToOFPushMplsAction(action, actionBuilder);
126             else if (action instanceof PopMplsActionCase)
127                 ofAction = SalToOFPopMpls(action, actionBuilder);
128             else if (action instanceof SetQueueActionCase)
129                 ofAction = SalToOFSetQueue(action, actionBuilder);
130             else if (action instanceof SetNwTtlActionCase)
131                 ofAction = SalToOFSetNwTtl(action, actionBuilder);
132             else if (action instanceof DecNwTtlCase)
133                 ofAction = SalToOFDecNwTtl(actionBuilder);
134             else if (action instanceof SetFieldCase)
135                 ofAction = SalToOFSetField(action, actionBuilder, version, datapathid);
136             else if (action instanceof PushPbbActionCase)
137                 ofAction = SalToOFPushPbbAction(action, actionBuilder);
138             else if (action instanceof PopPbbActionCase)
139                 ofAction = SalToOFPopPBB(actionBuilder);
140             else if (action instanceof ExperimenterAction)
141                 ofAction = SalToOFExperimenter(action, actionBuilder);
142
143                 // 1.0 Actions
144             else if (action instanceof SetVlanIdActionCase)
145                 ofAction = SalToOFSetVlanId(action, actionBuilder, version);
146             else if (action instanceof SetVlanPcpActionCase)
147                 ofAction = SalToOFSetVlanpcp(action, actionBuilder, version);
148             else if (action instanceof StripVlanActionCase)
149                 ofAction = SalToOFStripVlan(actionBuilder, version);
150             else if (action instanceof SetDlSrcActionCase)
151                 ofAction = SalToOFSetDlSrc(action, actionBuilder, version);
152             else if (action instanceof SetDlDstActionCase)
153                 ofAction = SalToOFSetDlDst(action, actionBuilder, version);
154             else if (action instanceof SetNwSrcActionCase)
155                 ofAction = SalToOFSetNwSrc(action, actionBuilder, version);
156             else if (action instanceof SetNwDstActionCase)
157                 ofAction = SalToOFSetNwDst(action, actionBuilder, version);
158             else if (action instanceof SetTpSrcActionCase)
159                 ofAction = SalToOFSetTpSrc(action, actionBuilder, version);
160             else if (action instanceof SetTpDstActionCase)
161                 ofAction = SalToOFSetTpDst(action, actionBuilder, version);
162             else if (action instanceof SetNwTosActionCase)
163                 ofAction = SalToOFSetNwTos(action, actionBuilder, version);
164
165             if (ofAction != null) {
166                 actionsList.add(ofAction);
167             }
168         }
169         return actionsList;
170     }
171
172     private static Action SalToOFSetField(
173             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
174             ActionBuilder actionBuilder, short version, BigInteger datapathid) {
175
176         SetFieldCase setFieldCase = (SetFieldCase) action;
177         org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match = setFieldCase
178                 .getSetField();
179
180         OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
181         MatchReactor.getInstance().convert(match, version, oxmFieldsActionBuilder, datapathid);
182
183         actionBuilder
184                 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
185
186         actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
187         return actionBuilder.build();
188     }
189
190     private static Action SalToOFDecNwTtl(ActionBuilder actionBuilder) {
191         actionBuilder
192                 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class);
193         return emtpyAction(actionBuilder);
194     }
195
196     private static Action SalToOFPushMplsAction(
197             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
198             ActionBuilder actionBuilder) {
199         PushMplsActionCase pushMplsActionCase = (PushMplsActionCase) action;
200         actionBuilder.setType(PushMpls.class);
201
202         return SalToOFPushAction(pushMplsActionCase.getPushMplsAction().getEthernetType(), actionBuilder);
203     }
204
205     private static Action SalToOFPushPbbAction(
206             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
207             ActionBuilder actionBuilder) {
208         PushPbbActionCase pushPbbActionCase = (PushPbbActionCase) action;
209         actionBuilder.setType(PushPbb.class);
210
211         return SalToOFPushAction(pushPbbActionCase.getPushPbbAction().getEthernetType(), actionBuilder);
212     }
213
214     private static Action SalToOFPushVlanAction(
215             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
216             ActionBuilder actionBuilder) {
217         PushVlanActionCase pushVlanActionCase = (PushVlanActionCase) action;
218         PushVlanAction pushVlanAction = pushVlanActionCase.getPushVlanAction();
219         actionBuilder.setType(PushVlan.class);
220
221         return SalToOFPushAction(pushVlanAction.getEthernetType(), actionBuilder);
222     }
223
224     private static Action SalToOFSetNwTtl(
225             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
226             ActionBuilder actionBuilder) {
227         SetNwTtlActionCase nwTtlActionCase = (SetNwTtlActionCase) action;
228         NwTtlActionBuilder nwTtlActionBuilder = new NwTtlActionBuilder();
229         nwTtlActionBuilder.setNwTtl(nwTtlActionCase.getSetNwTtlAction().getNwTtl());
230         actionBuilder.setType(SetNwTtl.class);
231         actionBuilder.addAugmentation(NwTtlAction.class, nwTtlActionBuilder.build());
232         return actionBuilder.build();
233     }
234
235     private static Action SalToOFSetQueue(
236             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
237             ActionBuilder actionBuilder) {
238         SetQueueActionCase setQueueActionCase = (SetQueueActionCase) action;
239         SetQueueAction setQueueAction = setQueueActionCase.getSetQueueAction();
240
241         QueueIdActionBuilder queueIdActionBuilder = new QueueIdActionBuilder();
242         queueIdActionBuilder.setQueueId(setQueueAction.getQueueId());
243         actionBuilder.setType(SetQueue.class);
244         actionBuilder.addAugmentation(QueueIdAction.class, queueIdActionBuilder.build());
245
246         return actionBuilder.build();
247     }
248
249     private static Action SalToOFPopMpls(
250             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
251             ActionBuilder actionBuilder) {
252         PopMplsActionCase popMplsActionCase = (PopMplsActionCase) action;
253         actionBuilder.setType(PopMpls.class);
254
255         return SalToOFPushAction(popMplsActionCase.getPopMplsAction().getEthernetType(), actionBuilder);
256     }
257
258     private static Action SalToOFPopVlan(ActionBuilder actionBuilder) {
259         actionBuilder.setType(PopVlan.class);
260         return emtpyAction(actionBuilder);
261     }
262
263     private static Action SalToOFPopPBB(ActionBuilder actionBuilder) {
264         actionBuilder.setType(PopPbb.class);
265         return emtpyAction(actionBuilder);
266     }
267
268     private static Action SalToOFExperimenter(
269             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
270             ActionBuilder actionBuilder) {
271         ExperimenterActionBuilder experimenterActionBuilder = new ExperimenterActionBuilder();
272         experimenterActionBuilder.setExperimenter(((ExperimenterAction) action).getExperimenter());
273         actionBuilder.setType(Experimenter.class);
274         actionBuilder
275                 .addAugmentation(
276                         ExperimenterAction.class,
277                         (Augmentation<Action>) experimenterActionBuilder);
278         return actionBuilder.build();
279     }
280
281     private static Action SalToOFSetVlanId(
282             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
283             ActionBuilder actionBuilder, short version) {
284
285         SetVlanIdActionCase setvlanidcase = (SetVlanIdActionCase) action;
286         SetVlanIdAction setvlanidaction = setvlanidcase.getSetVlanIdAction();
287
288         if (version == OFConstants.OFP_VERSION_1_0) {
289
290             VlanVidActionBuilder vlanidActionBuilder = new VlanVidActionBuilder();
291             vlanidActionBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
292             actionBuilder
293                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid.class);
294             actionBuilder.addAugmentation(VlanVidAction.class, vlanidActionBuilder.build());
295             return actionBuilder.build();
296         } else if (version >= OFConstants.OFP_VERSION_1_3) {
297             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
298             actionBuilder
299                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
300             List<MatchEntries> matchEntriesList = new ArrayList<>();
301             MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
302             matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
303             matchEntriesBuilder.setOxmMatchField(VlanVid.class);
304             VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
305             vlanVidBuilder.setCfiBit(true);
306             vlanVidBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
307             matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
308             matchEntriesBuilder.setHasMask(false);
309             matchEntriesList.add(matchEntriesBuilder.build());
310             oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
311             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
312             return actionBuilder.build();
313         } else {
314             logger.error("Unknown Action Type for the Version", version);
315             return null;
316         }
317     }
318
319     private static Action SalToOFSetVlanpcp(
320             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
321             ActionBuilder actionBuilder, short version) {
322
323         SetVlanPcpActionCase setvlanpcpcase = (SetVlanPcpActionCase) action;
324         SetVlanPcpAction setvlanpcpaction = setvlanpcpcase.getSetVlanPcpAction();
325
326         if (version == OFConstants.OFP_VERSION_1_0) {
327             VlanPcpActionBuilder vlanpcpActionBuilder = new VlanPcpActionBuilder();
328             vlanpcpActionBuilder.setVlanPcp(setvlanpcpaction.getVlanPcp().getValue());
329             actionBuilder
330                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp.class);
331             actionBuilder.addAugmentation(VlanPcpAction.class, vlanpcpActionBuilder.build());
332             return actionBuilder.build();
333         } else if (version >= OFConstants.OFP_VERSION_1_3) {
334             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
335             actionBuilder
336                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
337             List<MatchEntries> matchEntriesList = new ArrayList<>();
338             matchEntriesList.add(MatchConvertorImpl.toOfVlanPcp(setvlanpcpaction.getVlanPcp()));
339             oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
340             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
341             return actionBuilder.build();
342         } else {
343             logger.error("Unknown Action Type for the Version", version);
344             return null;
345         }
346     }
347
348     private static Action SalToOFStripVlan(ActionBuilder actionBuilder, short version) {
349         if (version == OFConstants.OFP_VERSION_1_0) {
350             actionBuilder
351                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class);
352
353             return emtpyAction(actionBuilder);
354         } else if (version >= OFConstants.OFP_VERSION_1_3) {
355             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
356             actionBuilder
357                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
358             List<MatchEntries> matchEntriesList = new ArrayList<>();
359             MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
360             matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
361             matchEntriesBuilder.setOxmMatchField(VlanVid.class);
362             VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
363             vlanVidBuilder.setCfiBit(true);
364             vlanVidBuilder.setVlanVid(new Integer(0x0000));
365             matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
366             matchEntriesBuilder.setHasMask(false);
367             matchEntriesList.add(matchEntriesBuilder.build());
368             oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
369             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
370             return actionBuilder.build();
371         } else {
372             logger.error("Unknown Action Type for the Version", version);
373             return null;
374         }
375     }
376
377     private static Action SalToOFSetDlSrc(
378             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
379             ActionBuilder actionBuilder, short version) {
380
381         SetDlSrcActionCase setdlsrccase = (SetDlSrcActionCase) action;
382         SetDlSrcAction setdlsrcaction = setdlsrccase.getSetDlSrcAction();
383
384         if (version == OFConstants.OFP_VERSION_1_0) {
385             DlAddressActionBuilder dladdressactionbuilder = new DlAddressActionBuilder();
386             dladdressactionbuilder.setDlAddress(setdlsrcaction.getAddress());
387             actionBuilder
388                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc.class);
389             actionBuilder.addAugmentation(DlAddressAction.class, dladdressactionbuilder.build());
390             return actionBuilder.build();
391         } else if (version >= OFConstants.OFP_VERSION_1_3) {
392             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
393             actionBuilder
394                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
395             List<MatchEntries> matchEntriesList = new ArrayList<>();
396             matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthSrc.class, setdlsrcaction.getAddress(), null));
397             oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
398             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
399             return actionBuilder.build();
400         } else {
401             logger.error("Unknown Action Type for the Version", version);
402             return null;
403         }
404
405     }
406
407     private static Action SalToOFSetDlDst(
408             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
409             ActionBuilder actionBuilder, short version) {
410
411         SetDlDstActionCase setdldstcase = (SetDlDstActionCase) action;
412         SetDlDstAction setdldstaction = setdldstcase.getSetDlDstAction();
413
414         if (version == OFConstants.OFP_VERSION_1_0) {
415             DlAddressActionBuilder dladdressactionbuilder = new DlAddressActionBuilder();
416             dladdressactionbuilder.setDlAddress(setdldstaction.getAddress());
417             actionBuilder
418                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst.class);
419             actionBuilder.addAugmentation(DlAddressAction.class, dladdressactionbuilder.build());
420             return actionBuilder.build();
421         } else if (version >= OFConstants.OFP_VERSION_1_3) {
422             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
423             actionBuilder
424                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
425             List<MatchEntries> matchEntriesList = new ArrayList<>();
426             matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthDst.class, setdldstaction.getAddress(), null));
427             oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
428             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
429             return actionBuilder.build();
430         } else {
431             logger.error("Unknown Action Type for the Version", version);
432             return null;
433         }
434
435     }
436
437     protected static Action SalToOFSetNwSrc(
438             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
439             ActionBuilder actionBuilder, short version) {
440
441         try {
442             ActionSetNwSrcReactor.getInstance().convert((SetNwSrcActionCase) action, version, actionBuilder, null);
443         } catch (Exception e) {
444             logger.error(e.getMessage(), e);
445             return null;
446         }
447
448         return actionBuilder.build();
449     }
450
451     protected static Action SalToOFSetNwDst(
452             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
453             ActionBuilder actionBuilder, short version) {
454
455         try {
456             ActionSetNwDstReactor.getInstance().convert((SetNwDstActionCase) action, version, actionBuilder, null);
457         } catch (Exception e) {
458             logger.error(e.getMessage(), e);
459             return null;
460         }
461
462         return actionBuilder.build();
463     }
464
465     private static Action SalToOFSetNwTos(
466             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
467             ActionBuilder actionBuilder, short version) {
468
469         SetNwTosActionCase setnwtoscase = (SetNwTosActionCase) action;
470         SetNwTosAction setnwtosaction = setnwtoscase.getSetNwTosAction();
471
472         if (version == OFConstants.OFP_VERSION_1_0) {
473             NwTosActionBuilder tosBuilder = new NwTosActionBuilder();
474             tosBuilder.setNwTos(setnwtosaction.getTos().shortValue());
475             actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build());
476             actionBuilder
477                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos.class);
478
479             return actionBuilder.build();
480         } else if (version >= OFConstants.OFP_VERSION_1_3) {
481             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
482             actionBuilder
483                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
484             List<MatchEntries> matchEntriesList = new ArrayList<>();
485             matchEntriesList.add(MatchConvertorImpl.toOfIpDscp(new Dscp(setnwtosaction.getTos().shortValue())));
486             oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
487             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
488             return actionBuilder.build();
489         } else {
490             logger.error("Unknown Action Type for the Version", version);
491             return null;
492         }
493
494     }
495
496     private static Action SalToOFSetTpSrc(
497             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
498             ActionBuilder actionBuilder, short version) {
499
500         if (version == OFConstants.OFP_VERSION_1_0) {
501             SetTpSrcActionCase settpsrccase = (SetTpSrcActionCase) action;
502             SetTpSrcAction settpsrcaction = settpsrccase.getSetTpSrcAction();
503
504             PortActionBuilder settpsrc = new PortActionBuilder();
505             PortNumber port = new PortNumber(settpsrcaction.getPort().getValue().longValue());
506             settpsrc.setPort(port);
507
508             actionBuilder
509                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc.class);
510             actionBuilder.addAugmentation(PortAction.class, settpsrc.build());
511             return actionBuilder.build();
512         }
513         logger.error("Unknown Action Type for the Version", version);
514         return null;
515     }
516
517     private static Action SalToOFSetTpDst(
518             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
519             ActionBuilder actionBuilder, short version) {
520
521         if (version == OFConstants.OFP_VERSION_1_0) {
522             SetTpDstActionCase settpdstcase = (SetTpDstActionCase) action;
523             SetTpDstAction settpdstaction = settpdstcase.getSetTpDstAction();
524             PortActionBuilder settpdst = new PortActionBuilder();
525             PortNumber port = new PortNumber(settpdstaction.getPort().getValue().longValue());
526             settpdst.setPort(port);
527
528             actionBuilder
529                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst.class);
530             actionBuilder.addAugmentation(PortAction.class, settpdst.build());
531             return actionBuilder.build();
532         }
533         logger.error("Unknown Action Type for the Version", version);
534         return null;
535     }
536
537     private static Action SalToOFGroupAction(
538             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
539             ActionBuilder actionBuilder) {
540
541         GroupActionCase groupActionCase = (GroupActionCase) action;
542         GroupAction groupAction = groupActionCase.getGroupAction();
543
544         GroupIdActionBuilder groupIdBuilder = new GroupIdActionBuilder();
545         groupIdBuilder.setGroupId(groupAction.getGroupId());
546         actionBuilder.setType(Group.class);
547         actionBuilder.addAugmentation(GroupIdAction.class, groupIdBuilder.build());
548         return actionBuilder.build();
549     }
550
551     private static Action SalToOFPushAction(Integer ethernetType, ActionBuilder actionBuilder) {
552         EthertypeActionBuilder ethertypeActionBuilder = new EthertypeActionBuilder();
553         if (ethernetType != null) {
554             ethertypeActionBuilder.setEthertype(new EtherType(ethernetType));
555         }
556
557         /* OF */
558         actionBuilder.addAugmentation(EthertypeAction.class, ethertypeActionBuilder.build());
559         return actionBuilder.build();
560     }
561
562     private static Action SalToOFDecMplsTtl(ActionBuilder actionBuilder) {
563         actionBuilder
564                 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class);
565         return emtpyAction(actionBuilder);
566     }
567
568     private static Action SalToOFSetMplsTtl(
569             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
570             ActionBuilder actionBuilder) {
571         SetMplsTtlActionCase mplsTtlActionCase = (SetMplsTtlActionCase) action;
572         SetMplsTtlAction mplsTtlAction = mplsTtlActionCase.getSetMplsTtlAction();
573
574         MplsTtlActionBuilder mplsTtlActionBuilder = new MplsTtlActionBuilder();
575         mplsTtlActionBuilder.setMplsTtl(mplsTtlAction.getMplsTtl()/* SAL */);
576         /* OF */
577         actionBuilder.setType(SetMplsTtl.class);
578         actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtlActionBuilder.build());
579         return actionBuilder.build();
580     }
581
582     private static Action SalToOFCopyTTLIIn(ActionBuilder actionBuilder) {
583         actionBuilder
584                 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class);
585         return emtpyAction(actionBuilder);
586     }
587
588     private static Action SalToOFCopyTTLIOut(ActionBuilder actionBuilder) {
589         actionBuilder
590                 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class);
591         return emtpyAction(actionBuilder);
592
593     }
594
595     private static Action emtpyAction(ActionBuilder actionBuilder) {
596         return actionBuilder.build();
597     }
598
599     private static Action salToOFOutputAction(
600             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
601             ActionBuilder actionBuilder, short version) {
602
603         OutputActionCase outputActionCase = ((OutputActionCase) action);
604         OutputAction outputAction = outputActionCase.getOutputAction();
605         PortActionBuilder portAction = new PortActionBuilder();
606         MaxLengthActionBuilder maxLenActionBuilder = new MaxLengthActionBuilder();
607         if (outputAction.getMaxLength() != null) {
608             maxLenActionBuilder.setMaxLength(outputAction.getMaxLength());
609         } else {
610             maxLenActionBuilder.setMaxLength(new Integer(0));
611         }
612         actionBuilder.addAugmentation(MaxLengthAction.class, maxLenActionBuilder.build());
613
614         Uri uri = outputAction.getOutputNodeConnector();
615
616         OpenflowVersion ofVersion = OpenflowVersion.get(version);
617         Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(ofVersion, uri.getValue());
618         if (OpenflowPortsUtil.checkPortValidity(ofVersion, portNumber)) {
619             portAction.setPort(new PortNumber(portNumber));
620         } else {
621             logger.error("Invalid Port specified " + portNumber + " for Output Action for OF version:" + ofVersion);
622         }
623
624         actionBuilder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
625         actionBuilder.addAugmentation(PortAction.class, portAction.build());
626         return actionBuilder.build();
627
628     }
629
630     /**
631      * Method to convert OF actions associated with bucket to SAL Actions.
632      *
633      * @param actionList
634      * @param ofVersion  current ofp version
635      * @return List of converted SAL Actions.
636      */
637     public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> toMDSalActions(
638             List<Action> actionList, OpenflowVersion ofVersion) {
639
640         List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> bucketActions = new ArrayList<>();
641         for (Action action : actionList) {
642             if (action.getType().equals(
643                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class)) {
644                 bucketActions.add(ofToSALOutputAction(ofVersion, action));
645
646             } else if (action.getType().equals(
647                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class)) {
648                 bucketActions.add(ofToSALGroupAction(action));
649
650             } else if (action.getType().equals(
651                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class)) {
652                 CopyTtlOutBuilder copyTtlOutaction = new CopyTtlOutBuilder();
653                 bucketActions.add(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyTtlOutaction.build()).build());
654
655             } else if (action.getType().equals(
656                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class)) {
657                 CopyTtlInBuilder copyTtlInaction = new CopyTtlInBuilder();
658                 bucketActions.add(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInaction.build()).build());
659
660             } else if (action.getType().equals(
661                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class)) {
662                 bucketActions.add(ofToSALSetMplsTtl(action));
663
664             } else if (action.getType().equals(
665                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class)) {
666                 DecMplsTtlBuilder decMplsTtl = new DecMplsTtlBuilder();
667                 bucketActions.add(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtl.build()).build());
668
669             } else if (action.getType().equals(
670                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class)) {
671                 bucketActions.add(ofToSALPushVlanAction(action));
672
673             } else if (action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)
674                     || action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class)) {
675                 // OF1.0 nodes will emit StripVlan and OF1.3+ will emit StripVlan/PopVlan, convert both to PopVlan for SAL
676                 PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
677                 bucketActions.add(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
678
679             } else if (action.getType().equals(
680                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class)) {
681                 bucketActions.add(ofToSALPushMplsAction(action));
682
683             } else if (action.getType().equals(
684                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class)) {
685                 bucketActions.add(ofToSALPopMplsAction(action));
686
687             } else if (action.getType().equals(
688                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class)) {
689                 bucketActions.add(ofToSALSetQueue(action));
690
691             } else if (action.getType().equals(
692                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class)) {
693                 bucketActions.add(ofToSALSetNwTtl(action));
694
695             } else if (action.getType().equals(
696                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class)) {
697                 DecNwTtlBuilder decNwTtl = new DecNwTtlBuilder();
698                 bucketActions.add(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl.build()).build());
699
700             } else if (action.getType().equals(
701                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class)) {
702                 bucketActions.add(new SetFieldCaseBuilder().setSetField(MatchConvertorImpl.fromOFSetFieldToSALSetFieldAction(action, ofVersion))
703                         .build());
704             } else if (action.getType().equals(
705                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class)) {
706                 bucketActions.add(ofToSALPushPbbAction(action));
707
708             } else if (action.getType().equals(
709                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb.class)) {
710                 PopPbbActionBuilder popPbb = new PopPbbActionBuilder();
711                 bucketActions.add(new PopPbbActionCaseBuilder().setPopPbbAction(popPbb.build()).build());
712
713             } else if (action.getType().equals(
714                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) {
715                 // bucketActions.add(ofToSALExperimenter(action));
716                 // TODO: Need to explore/discuss on how to handle experimenter
717                 // case.
718             }
719
720         }
721         return bucketActions;
722     }
723
724     /**
725      * Method converts OF Output action object to SAL Output action object.
726      *
727      * @param ofVersion
728      * @param ofVersion
729      * @param action    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.
730      *                  action.rev130731.actions.actions.list.Action
731      * @return OutputAction
732      */
733     public static OutputActionCase ofToSALOutputAction(OpenflowVersion ofVersion, Action action) {
734         OutputActionBuilder outputAction = new OutputActionBuilder();
735         PortAction port = action.getAugmentation(PortAction.class);
736         if (port != null) {
737             CommonPort.PortNumber protocolAgnosticPort = OpenflowPortsUtil.getProtocolAgnosticPort(
738                     ofVersion, port.getPort().getValue());
739             String portNumberAsString = OpenflowPortsUtil.portNumberToString(protocolAgnosticPort);
740             outputAction.setOutputNodeConnector(new Uri(portNumberAsString));
741         } else {
742             logger.error("Provided action is not OF Output action, no associated port found!");
743         }
744
745         MaxLengthAction length = action.getAugmentation(MaxLengthAction.class);
746         if (length != null) {
747             outputAction.setMaxLength(length.getMaxLength());
748         } else {
749             logger.error("Provided action is not OF Output action, no associated length found!");
750         }
751
752         return new OutputActionCaseBuilder().setOutputAction(outputAction.build()).build();
753     }
754
755     /**
756      * Method converts OF GroupAction object to SAL GroupAction object
757      *
758      * @param action
759      * @return GroupAction
760      */
761     public static GroupActionCase ofToSALGroupAction(Action action) {
762
763         GroupActionBuilder groupAction = new GroupActionBuilder();
764
765         GroupIdAction groupId = action.getAugmentation(GroupIdAction.class);
766         groupAction.setGroupId(groupId.getGroupId());
767
768         return new GroupActionCaseBuilder().setGroupAction(groupAction.build()).build();
769     }
770
771     /**
772      * Method converts OF SetMplsTTL action object to SAL SetMplsTTL action
773      * object.
774      *
775      * @param action
776      * @return
777      */
778     public static SetMplsTtlActionCase ofToSALSetMplsTtl(Action action) {
779
780         SetMplsTtlActionBuilder mplsTtlAction = new SetMplsTtlActionBuilder();
781         MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class);
782         mplsTtlAction.setMplsTtl(mplsTtl.getMplsTtl());
783         return new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(mplsTtlAction.build()).build();
784     }
785
786     /**
787      * Method converts OF Pushvlan action to SAL PushVlan action.
788      *
789      * @param action
790      * @return PushVlanAction
791      */
792     public static PushVlanActionCase ofToSALPushVlanAction(Action action) {
793
794         PushVlanActionBuilder pushVlanAction = new PushVlanActionBuilder();
795
796         EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
797         pushVlanAction.setEthernetType(etherType.getEthertype().getValue());
798
799         return new PushVlanActionCaseBuilder().setPushVlanAction(pushVlanAction.build()).build();
800     }
801
802     /**
803      * Method converts OF PushMpls action to SAL PushMpls action.
804      *
805      * @param action
806      * @return PushMplsAction
807      */
808     public static PushMplsActionCase ofToSALPushMplsAction(Action action) {
809
810         PushMplsActionBuilder pushMplsAction = new PushMplsActionBuilder();
811
812         EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
813         pushMplsAction.setEthernetType(etherType.getEthertype().getValue());
814
815         return new PushMplsActionCaseBuilder().setPushMplsAction(pushMplsAction.build()).build();
816     }
817
818     /**
819      * Method converts OF PopMpls action to SAL PopMpls action.
820      *
821      * @param action
822      * @return PopMplsActionCase
823      */
824     public static PopMplsActionCase ofToSALPopMplsAction(Action action) {
825
826         PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder();
827
828         EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
829         popMplsAction.setEthernetType(etherType.getEthertype().getValue());
830
831         return new PopMplsActionCaseBuilder().setPopMplsAction(popMplsAction.build()).build();
832     }
833
834     /**
835      * Method converts OF SetQueue action to SAL SetQueue action.
836      *
837      * @param action
838      * @return SetQueueAction
839      */
840     public static SetQueueActionCase ofToSALSetQueue(Action action) {
841
842         SetQueueActionBuilder setQueueAction = new SetQueueActionBuilder();
843
844         QueueIdAction queueId = action.getAugmentation(QueueIdAction.class);
845         setQueueAction.setQueueId(queueId.getQueueId());
846
847         return new SetQueueActionCaseBuilder().setSetQueueAction(setQueueAction.build()).build();
848     }
849
850     /**
851      * Method converts OF SetNwTtl action to SAL SetNwTtl action.
852      *
853      * @param action
854      * @return SetNwTtlAction
855      */
856     public static SetNwTtlActionCase ofToSALSetNwTtl(Action action) {
857
858         SetNwTtlActionBuilder setNwTtl = new SetNwTtlActionBuilder();
859         NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class);
860         setNwTtl.setNwTtl(nwTtl.getNwTtl());
861
862         return new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtl.build()).build();
863     }
864
865     /**
866      * Method converts OF Pushvlan action to SAL PushVlan action.
867      *
868      * @param action
869      * @return PushVlanAction
870      */
871     public static PushPbbActionCase ofToSALPushPbbAction(Action action) {
872
873         PushPbbActionBuilder pushPbbAction = new PushPbbActionBuilder();
874
875         EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
876         pushPbbAction.setEthernetType(etherType.getEthertype().getValue());
877
878         return new PushPbbActionCaseBuilder().setPushPbbAction(pushPbbAction.build()).build();
879     }
880
881     public static Object ofToSALExperimenter(Action action) {
882
883         ExperimenterAction ExperimenterAction = action.getAugmentation(ExperimenterAction.class);
884
885         return null;
886         /*
887          * TODO: Need to explore/discuss about how to handle experimenter
888          */
889
890     }
891 }