Bug 868: Replaced use of toInstance() for build().
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / ActionConvertor.java
index f1fdc80371788f35a7579e70f12cd986e9431a00..014210c0f1e7a41f4a651b019c609077f1a7b71c 100644 (file)
@@ -9,17 +9,25 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.opendaylight.openflowjava.protocol.api.util.BinContent;
-import org.opendaylight.openflowplugin.openflow.md.OFConstants;
+import com.google.common.collect.Ordering;
+
+import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
+import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
+import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
+import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
+import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.extension.ActionExtensionHelper;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwDstReactor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwSrcReactor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
+import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
+import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
@@ -91,16 +99,22 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.CommonPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
@@ -113,6 +127,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction;
@@ -121,7 +137,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
@@ -136,50 +151,63 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValues;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValuesV10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author usha@ericsson Action List:This class takes data from SAL layer and
  *         converts into OF Data
  * @author avishnoi@in.ibm.com Added convertor for OF bucket actions to SAL
  *         actions
- *
  */
 public final class ActionConvertor {
     private static final Logger logger = LoggerFactory.getLogger(ActionConvertor.class);
-    private static final String PREFIX_SEPARATOR = "/";
-    final private static Long MAXPortOF13 = new Long(4294967040L); // 0xffffff00
-    final private static Long MAXPortOF10 = new Long(0xff00);
-
+    
     private ActionConvertor() {
         // NOOP
     }
 
     /**
      * Translates SAL actions into OF Library actions
-     * @param actions SAL actions
-     * @param version Openflow protocol version used
+     *
+     * @param actions    SAL actions
+     * @param version    Openflow protocol version used
      * @param datapathid
+     * @param flow TODO
      * @return OF Library actions
      */
     public static List<Action> getActions(
             List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions,
-            short version, BigInteger datapathid)
-
-    {
+            short version, BigInteger datapathid, Flow flow) {
         List<Action> actionsList = new ArrayList<>();
         Action ofAction;
 
+        actions = Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>build())
+            .sortedCopy(actions);
+
         for (int actionItem = 0; actionItem < actions.size(); actionItem++) {
             ofAction = null;
             ActionBuilder actionBuilder = new ActionBuilder();
@@ -200,9 +228,11 @@ public final class ActionConvertor {
             else if (action instanceof DecMplsTtlCase)
                 ofAction = SalToOFDecMplsTtl(actionBuilder);
             else if (action instanceof PushVlanActionCase)
-                ofAction = SalToOFPushVlanAction(action, actionBuilder);
+                ofAction = SalToOFPushVlanAction(action, actionBuilder, version);
             else if (action instanceof PopVlanActionCase)
-                ofAction = SalToOFPopVlan(actionBuilder);
+                ofAction = (version == OFConstants.OFP_VERSION_1_0) ?
+                    SalToOFStripVlan(actionBuilder, version)
+                        : SalToOFPopVlan(actionBuilder);
             else if (action instanceof PushMplsActionCase)
                 ofAction = SalToOFPushMplsAction(action, actionBuilder);
             else if (action instanceof PopMplsActionCase)
@@ -219,12 +249,17 @@ public final class ActionConvertor {
                 ofAction = SalToOFPushPbbAction(action, actionBuilder);
             else if (action instanceof PopPbbActionCase)
                 ofAction = SalToOFPopPBB(actionBuilder);
-            else if (action instanceof ExperimenterAction)
-                ofAction = SalToOFExperimenter(action, actionBuilder);
 
-            // 1.0 Actions
-            else if (action instanceof SetVlanIdActionCase)
+                // 1.0 Actions
+            else if (action instanceof SetVlanIdActionCase) {
+                /*if (version == OFConstants.OFP_VERSION_1_0) {
+
+                } else {
+                    List<Action> setVlanIdActionsList = convertToOF13(action, actionBuilder);
+                    actionsList.addAll(setVlanIdActionsList);
+                }*/
                 ofAction = SalToOFSetVlanId(action, actionBuilder, version);
+            }
             else if (action instanceof SetVlanPcpActionCase)
                 ofAction = SalToOFSetVlanpcp(action, actionBuilder, version);
             else if (action instanceof StripVlanActionCase)
@@ -237,13 +272,45 @@ public final class ActionConvertor {
                 ofAction = SalToOFSetNwSrc(action, actionBuilder, version);
             else if (action instanceof SetNwDstActionCase)
                 ofAction = SalToOFSetNwDst(action, actionBuilder, version);
-            else if (action instanceof SetTpSrcActionCase)
-                ofAction = SalToOFSetTpSrc(action, actionBuilder, version);
-            else if (action instanceof SetTpDstActionCase)
-                ofAction = SalToOFSetTpDst(action, actionBuilder, version);
+            else if (action instanceof SetTpSrcActionCase) {
+                ofAction = SalToOFSetTpSrc(action, actionBuilder, version, IPProtocols.fromProtocolNum(flow.getMatch().
+                        getIpMatch().getIpProtocol()));
+            }
+            else if (action instanceof SetTpDstActionCase) {
+                ofAction = SalToOFSetTpDst(action, actionBuilder, version, IPProtocols.fromProtocolNum(flow.getMatch().
+                        getIpMatch().getIpProtocol()));
+            }
             else if (action instanceof SetNwTosActionCase)
                 ofAction = SalToOFSetNwTos(action, actionBuilder, version);
-
+            else if (action instanceof GeneralExtensionGrouping) {
+                
+                /**
+                 * TODO: EXTENSION PROPOSAL (action, MD-SAL to OFJava)
+                 * - we might need sessionContext as converter input
+                 * 
+                 */
+                
+                GeneralExtensionGrouping extensionCaseGrouping = (GeneralExtensionGrouping) action;
+                Extension extAction = extensionCaseGrouping.getExtension();
+                ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(extensionCaseGrouping.getExtensionKey(), version);
+                ConvertorToOFJava<Action> convertor = 
+                        OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
+                if (convertor != null) {
+                    ofAction = convertor.convert(extAction);
+                }
+            } else {
+                // try vendor codecs
+                TypeVersionKey<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> key =
+                        new TypeVersionKey<>(
+                                (Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>) action.getImplementedInterface(),
+                                version);
+                ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action> convertor = 
+                        OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
+                if (convertor != null) {
+                    ofAction = convertor.convert(action);
+                }
+            }
+            
             if (ofAction != null) {
                 actionsList.add(ofAction);
             }
@@ -256,17 +323,33 @@ public final class ActionConvertor {
             ActionBuilder actionBuilder, short version, BigInteger datapathid) {
 
         SetFieldCase setFieldCase = (SetFieldCase) action;
-        org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match = setFieldCase
-                .getSetField();
+        org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match =
+            setFieldCase.getSetField();
 
-        OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
-        MatchReactor.getInstance().convert(match, version, oxmFieldsActionBuilder, datapathid);
+        if (version == OFConstants.OFP_VERSION_1_0) {
+            // pushvlan +setField can be called to configure 1.0 switches via MDSAL app
+            if (match.getVlanMatch() != null) {
+                VlanVidActionBuilder vlanidActionBuilder = new VlanVidActionBuilder();
+                vlanidActionBuilder.setVlanVid(match.getVlanMatch().getVlanId().getVlanId().getValue());
+                actionBuilder.setType(
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid.class);
+                actionBuilder.addAugmentation(VlanVidAction.class, vlanidActionBuilder.build());
+                return actionBuilder.build();
+            } else {
+                return emtpyAction(actionBuilder);
+            }
 
-        actionBuilder
-                .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
+        } else {
+            OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
+            MatchReactor.getInstance().convert(match, version, oxmFieldsActionBuilder, datapathid);
+
+            actionBuilder.setType(
+                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
+
+            actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
+            return actionBuilder.build();
+        }
 
-        actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
-        return actionBuilder.build();
     }
 
     private static Action SalToOFDecNwTtl(ActionBuilder actionBuilder) {
@@ -295,7 +378,13 @@ public final class ActionConvertor {
 
     private static Action SalToOFPushVlanAction(
             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            ActionBuilder actionBuilder) {
+            ActionBuilder actionBuilder, short version) {
+        if (version == OFConstants.OFP_VERSION_1_0) {
+            // if client configure openflow 1.0 switch as a openflow 1.3 switch using openflow 1.3 instructions
+            // then we can ignore PUSH_VLAN as set-vlan-id will push a vlan header if not present
+            return null;
+        }
+
         PushVlanActionCase pushVlanActionCase = (PushVlanActionCase) action;
         PushVlanAction pushVlanAction = pushVlanActionCase.getPushVlanAction();
         actionBuilder.setType(PushVlan.class);
@@ -347,19 +436,7 @@ public final class ActionConvertor {
         return emtpyAction(actionBuilder);
     }
 
-    private static Action SalToOFExperimenter(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            ActionBuilder actionBuilder) {
-        ExperimenterActionBuilder experimenterActionBuilder = new ExperimenterActionBuilder();
-        experimenterActionBuilder.setExperimenter(((ExperimenterAction) action).getExperimenter());
-        actionBuilder.setType(Experimenter.class);
-        actionBuilder
-                .addAugmentation(
-                        ExperimenterAction.class,
-                        (Augmentation<Action>) experimenterActionBuilder);
-        return actionBuilder.build();
-    }
-
+    // set-vlan-id (1.0 feature) can be called on  1.3 switches as well using ADSAL apis
     private static Action SalToOFSetVlanId(
             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
             ActionBuilder actionBuilder, short version) {
@@ -375,6 +452,7 @@ public final class ActionConvertor {
                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid.class);
             actionBuilder.addAugmentation(VlanVidAction.class, vlanidActionBuilder.build());
             return actionBuilder.build();
+
         } else if (version >= OFConstants.OFP_VERSION_1_3) {
             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
             actionBuilder
@@ -443,7 +521,7 @@ public final class ActionConvertor {
             matchEntriesBuilder.setOxmMatchField(VlanVid.class);
             VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
             vlanVidBuilder.setCfiBit(true);
-            vlanVidBuilder.setVlanVid(new Integer(0x0000));
+            vlanVidBuilder.setVlanVid(0x0000);
             matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
             matchEntriesBuilder.setHasMask(false);
             matchEntriesList.add(matchEntriesBuilder.build());
@@ -483,7 +561,6 @@ public final class ActionConvertor {
             logger.error("Unknown Action Type for the Version", version);
             return null;
         }
-
     }
 
     private static Action SalToOFSetDlDst(
@@ -513,7 +590,6 @@ public final class ActionConvertor {
             logger.error("Unknown Action Type for the Version", version);
             return null;
         }
-
     }
 
     protected static Action SalToOFSetNwSrc(
@@ -526,47 +602,8 @@ public final class ActionConvertor {
             logger.error(e.getMessage(), e);
             return null;
         }
-        
-        return actionBuilder.build();
-        
-//        SetNwSrcActionCase setnwsrccase = (SetNwSrcActionCase) action;
-//        SetNwSrcAction setnwsrcaction = setnwsrccase.getSetNwSrcAction();
-//        Ipv4 address_ipv4 = (Ipv4) setnwsrcaction.getAddress();
-//
-//        if (version == OFConstants.OFP_VERSION_1_0) {
-//            IpAddressActionBuilder ipvaddress = new IpAddressActionBuilder();
-//
-//            Ipv4Address address = new Ipv4Address(address_ipv4.getIpv4Address().getValue());
-//            ipvaddress.setIpAddress(address);
-//            actionBuilder
-//                    .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc.class);
-//            actionBuilder.addAugmentation(
-//                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction.class,
-//                    ipvaddress.build());
-//            return actionBuilder.build();
-//        } else if (version >= OFConstants.OFP_VERSION_1_3) {
-//            OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
-//            actionBuilder
-//                    .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
-//            List<MatchEntries> matchEntriesList = new ArrayList<>();
-//            String[] addressParts = address_ipv4.getIpv4Address().getValue().split(PREFIX_SEPARATOR);
-//            MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
-//            matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
-//            matchEntriesBuilder.setOxmMatchField(Ipv4Src.class);
-//            Ipv4Address ipv4Address = new Ipv4Address(addressParts[0]);
-//            Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder();
-//            ipv4AddressBuilder.setIpv4Address(ipv4Address);
-//            matchEntriesBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build());
-//            matchEntriesBuilder.setHasMask(false);
-//            matchEntriesList.add(matchEntriesBuilder.build());
-//            oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
-//            actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
-//            return actionBuilder.build();
-//        } else {
-//            logger.error("Unknown Action Type for the Version", version);
-//            return null;
-//        }
 
+        return actionBuilder.build();
     }
 
     protected static Action SalToOFSetNwDst(
@@ -579,47 +616,8 @@ public final class ActionConvertor {
             logger.error(e.getMessage(), e);
             return null;
         }
-        
-        return actionBuilder.build();
-        
-//        SetNwDstActionCase setnwdstcase = (SetNwDstActionCase) action;
-//        SetNwDstAction setnwdstaction = setnwdstcase.getSetNwDstAction();
-//        Ipv4 address_ipv4 = (Ipv4) setnwdstaction.getAddress();
-//
-//        if (version == OFConstants.OFP_VERSION_1_0) {
-//            IpAddressActionBuilder ipvaddress = new IpAddressActionBuilder();
-//
-//            Ipv4Address address = new Ipv4Address(address_ipv4.getIpv4Address().getValue());
-//            ipvaddress.setIpAddress(address);
-//            actionBuilder
-//                    .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst.class);
-//            actionBuilder.addAugmentation(
-//                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction.class,
-//                    ipvaddress.build());
-//            return actionBuilder.build();
-//        } else if (version >= OFConstants.OFP_VERSION_1_3) {
-//            OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
-//            actionBuilder
-//                    .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
-//            List<MatchEntries> matchEntriesList = new ArrayList<>();
-//            String[] addressParts = address_ipv4.getIpv4Address().getValue().split(PREFIX_SEPARATOR);
-//            MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
-//            matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
-//            matchEntriesBuilder.setOxmMatchField(Ipv4Dst.class);
-//            Ipv4Address ipv4Address = new Ipv4Address(addressParts[0]);
-//            Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder();
-//            ipv4AddressBuilder.setIpv4Address(ipv4Address);
-//            matchEntriesBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build());
-//            matchEntriesBuilder.setHasMask(false);
-//            matchEntriesList.add(matchEntriesBuilder.build());
-//            oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
-//            actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
-//            return actionBuilder.build();
-//        } else {
-//            logger.error("Unknown Action Type for the Version", version);
-//            return null;
-//        }
 
+        return actionBuilder.build();
     }
 
     private static Action SalToOFSetNwTos(
@@ -642,7 +640,9 @@ public final class ActionConvertor {
             actionBuilder
                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
             List<MatchEntries> matchEntriesList = new ArrayList<>();
-            matchEntriesList.add(MatchConvertorImpl.toOfIpDscp(new Dscp(setnwtosaction.getTos().shortValue())));
+            matchEntriesList.add(MatchConvertorImpl.toOfIpDscp(new Dscp(
+                    ActionUtil.tosToDscp(setnwtosaction.getTos().shortValue())
+                    )));
             oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
             return actionBuilder.build();
@@ -655,7 +655,7 @@ public final class ActionConvertor {
 
     private static Action SalToOFSetTpSrc(
             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            ActionBuilder actionBuilder, short version) {
+            ActionBuilder actionBuilder, short version, IPProtocols protocol) {
 
         if (version == OFConstants.OFP_VERSION_1_0) {
             SetTpSrcActionCase settpsrccase = (SetTpSrcActionCase) action;
@@ -669,6 +669,54 @@ public final class ActionConvertor {
                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc.class);
             actionBuilder.addAugmentation(PortAction.class, settpsrc.build());
             return actionBuilder.build();
+        } else if (version == OFConstants.OFP_VERSION_1_3) {
+            SetTpSrcActionCase settpsrccase = (SetTpSrcActionCase) action;
+            SetTpSrcAction settpsrcaction = settpsrccase.getSetTpSrcAction();
+            
+            MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
+            matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntriesBuilder.setHasMask(false);
+            PortMatchEntryBuilder portMatchEntryBuilder = new PortMatchEntryBuilder();
+            int port = settpsrcaction.getPort().getValue().intValue();
+            int type = 0x0f & port;
+            
+            switch(protocol) {
+            case ICMP: 
+                matchEntriesBuilder.setOxmMatchField(Icmpv4Type.class);
+                Icmpv4TypeMatchEntryBuilder icmpv4TypeMatchEntryBuilder = new Icmpv4TypeMatchEntryBuilder();
+                icmpv4TypeMatchEntryBuilder.setIcmpv4Type((short) type);
+                matchEntriesBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeMatchEntryBuilder.build());
+                break;
+            case ICMPV6: 
+                matchEntriesBuilder.setOxmMatchField(Icmpv6Type.class);
+                Icmpv6TypeMatchEntryBuilder icmpv6TypeMatchEntryBuilder = new Icmpv6TypeMatchEntryBuilder();
+                icmpv6TypeMatchEntryBuilder.setIcmpv6Type((short) type);
+                matchEntriesBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeMatchEntryBuilder.build());
+                break;
+            case TCP: 
+                matchEntriesBuilder.setOxmMatchField(TcpSrc.class);
+                portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port));
+                matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build());
+                break;
+            case UDP: 
+                matchEntriesBuilder.setOxmMatchField(UdpSrc.class);
+                portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port));
+                matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build());
+                break;
+            default: logger.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
+                break;
+            }
+            
+            actionBuilder
+            .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
+            
+            OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
+            List<MatchEntries> matchEntries = new ArrayList<MatchEntries>();
+            matchEntries.add(matchEntriesBuilder.build());
+            oxmFieldsActionBuilder.setMatchEntries(matchEntries);
+
+            actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
+            return actionBuilder.build();
         }
         logger.error("Unknown Action Type for the Version", version);
         return null;
@@ -676,7 +724,7 @@ public final class ActionConvertor {
 
     private static Action SalToOFSetTpDst(
             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
-            ActionBuilder actionBuilder, short version) {
+            ActionBuilder actionBuilder, short version, IPProtocols protocol) {
 
         if (version == OFConstants.OFP_VERSION_1_0) {
             SetTpDstActionCase settpdstcase = (SetTpDstActionCase) action;
@@ -689,6 +737,54 @@ public final class ActionConvertor {
                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst.class);
             actionBuilder.addAugmentation(PortAction.class, settpdst.build());
             return actionBuilder.build();
+        } else if (version == OFConstants.OFP_VERSION_1_3) {
+            SetTpDstActionCase settpdstcase = (SetTpDstActionCase) action;
+            SetTpDstAction settpdstaction = settpdstcase.getSetTpDstAction();
+            
+            MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
+            matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
+            matchEntriesBuilder.setHasMask(false);
+            PortMatchEntryBuilder portMatchEntryBuilder = new PortMatchEntryBuilder();
+            int port = settpdstaction.getPort().getValue().intValue();
+            int code = 0x0f & port;
+            
+            switch(protocol) {
+            case ICMP: 
+                matchEntriesBuilder.setOxmMatchField(Icmpv4Code.class);
+                Icmpv4CodeMatchEntryBuilder icmpv4CodeMatchEntryBuilder = new Icmpv4CodeMatchEntryBuilder();
+                icmpv4CodeMatchEntryBuilder.setIcmpv4Code((short) code);
+                matchEntriesBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeMatchEntryBuilder.build());
+                break;
+            case ICMPV6: 
+                matchEntriesBuilder.setOxmMatchField(Icmpv6Code.class);
+                Icmpv6CodeMatchEntryBuilder icmpv6CodeMatchEntryBuilder = new Icmpv6CodeMatchEntryBuilder();
+                icmpv6CodeMatchEntryBuilder.setIcmpv6Code((short) code);
+                matchEntriesBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeMatchEntryBuilder.build());
+                break;
+            case TCP: 
+                matchEntriesBuilder.setOxmMatchField(TcpDst.class);
+                portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port));
+                matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build());
+                break;
+            case UDP: 
+                matchEntriesBuilder.setOxmMatchField(UdpDst.class);
+                portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port));
+                matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build());
+                break;
+            default: logger.warn("Unknown protocol with combination of SetDestinationPort: {}", protocol);
+                break;
+            }
+            
+            actionBuilder
+            .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
+            
+            OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
+            List<MatchEntries> matchEntries = new ArrayList<MatchEntries>();
+            matchEntries.add(matchEntriesBuilder.build());
+            oxmFieldsActionBuilder.setMatchEntries(matchEntries);
+
+            actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
+            return actionBuilder.build();
         }
         logger.error("Unknown Action Type for the Version", version);
         return null;
@@ -710,7 +806,9 @@ public final class ActionConvertor {
 
     private static Action SalToOFPushAction(Integer ethernetType, ActionBuilder actionBuilder) {
         EthertypeActionBuilder ethertypeActionBuilder = new EthertypeActionBuilder();
-        ethertypeActionBuilder.setEthertype(new EtherType(ethernetType));
+        if (ethernetType != null) {
+            ethertypeActionBuilder.setEthertype(new EtherType(ethernetType));
+        }
 
         /* OF */
         actionBuilder.addAugmentation(EthertypeAction.class, ethertypeActionBuilder.build());
@@ -765,77 +863,21 @@ public final class ActionConvertor {
         if (outputAction.getMaxLength() != null) {
             maxLenActionBuilder.setMaxLength(outputAction.getMaxLength());
         } else {
-            maxLenActionBuilder.setMaxLength(new Integer(0));
+            maxLenActionBuilder.setMaxLength(0);
         }
         actionBuilder.addAugmentation(MaxLengthAction.class, maxLenActionBuilder.build());
 
         Uri uri = outputAction.getOutputNodeConnector();
 
-        if (version >= OFConstants.OFP_VERSION_1_3) {
-
-            if (uri.getValue().equals(OutputPortValues.CONTROLLER.toString())) {
-                portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.CONTROLLER
-                        .getIntValue())));
-            } else if (uri.getValue().equals(OutputPortValues.ALL.toString())) {
-                portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.ALL.getIntValue())));
-            } else if (uri.getValue().equals(OutputPortValues.ANY.toString())) {
-                portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.ANY.getIntValue())));
-
-            } else if (uri.getValue().equals(OutputPortValues.FLOOD.toString())) {
-                portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.FLOOD.getIntValue())));
-
-            } else if (uri.getValue().equals(OutputPortValues.INPORT.toString())) {
-                portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.INPORT.getIntValue())));
-
-            } else if (uri.getValue().equals(OutputPortValues.LOCAL.toString())) {
-                portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.LOCAL.getIntValue())));
-
-            } else if (uri.getValue().equals(OutputPortValues.NORMAL.toString())) {
-                portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.NORMAL.getIntValue())));
-
-            } else if (uri.getValue().equals(OutputPortValues.TABLE.toString())) {
-                portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.TABLE.getIntValue())));
-
-            } else if (uri.getValue().equals(OutputPortValues.NONE.toString())) {
-                logger.error("Unknown Port Type for the Version");
-            } else if (InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction.getOutputNodeConnector()
-                    .getValue()) < MAXPortOF13) {
-                portAction.setPort(new PortNumber(InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction
-                        .getOutputNodeConnector().getValue())));
-            } else {
-                logger.error("Invalid Port for Output Action");
-            }
-        } else if (version == OFConstants.OFP_VERSION_1_0) {
-
-            if (uri.getValue().equals(OutputPortValues.CONTROLLER.toString())) {
-                portAction.setPort(new PortNumber((long) PortNumberValuesV10.CONTROLLER.getIntValue()));
-            } else if (uri.getValue().equals(OutputPortValues.ALL.toString())) {
-                portAction.setPort(new PortNumber((long) PortNumberValuesV10.ALL.getIntValue()));
-            } else if (uri.getValue().equals(OutputPortValues.FLOOD.toString())) {
-                portAction.setPort(new PortNumber((long) PortNumberValuesV10.FLOOD.getIntValue()));
-            } else if (uri.getValue().equals(OutputPortValues.INPORT.toString())) {
-                portAction.setPort(new PortNumber((long) PortNumberValuesV10.INPORT.getIntValue()));
-            } else if (uri.getValue().equals(OutputPortValues.LOCAL.toString())) {
-                portAction.setPort(new PortNumber((long) PortNumberValuesV10.LOCAL.getIntValue()));
-            } else if (uri.getValue().equals(OutputPortValues.NORMAL.toString())) {
-                portAction.setPort(new PortNumber((long) PortNumberValuesV10.NORMAL.getIntValue()));
-            } else if (uri.getValue().equals(OutputPortValues.TABLE.toString())) {
-                portAction.setPort(new PortNumber((long) PortNumberValuesV10.TABLE.getIntValue()));
-            } else if (uri.getValue().equals(OutputPortValues.NONE.toString())) {
-                portAction.setPort(new PortNumber((long) PortNumberValuesV10.NONE.getIntValue()));
-            } else if (uri.getValue().equals(OutputPortValues.ANY.toString())) {
-                logger.error("Unknown Port Type for the Version");
-            } else if (InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction.getOutputNodeConnector()
-                    .getValue()) < MAXPortOF10) {
-                portAction.setPort(new PortNumber(InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction
-                        .getOutputNodeConnector().getValue())));
-            } else {
-                logger.error("Invalid Port for Output Action");
-            }
+        OpenflowVersion ofVersion = OpenflowVersion.get(version);
+        Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(ofVersion, uri.getValue());
+        if (OpenflowPortsUtil.checkPortValidity(ofVersion, portNumber)) {
+            portAction.setPort(new PortNumber(portNumber));
+        } else {
+            logger.error("Invalid Port specified " + portNumber + " for Output Action for OF version:" + ofVersion);
         }
 
-        actionBuilder
-                .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
+        actionBuilder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
         actionBuilder.addAugmentation(PortAction.class, portAction.build());
         return actionBuilder.build();
 
@@ -845,79 +887,99 @@ public final class ActionConvertor {
      * Method to convert OF actions associated with bucket to SAL Actions.
      *
      * @param actionList
+     * @param ofVersion  current ofp version
+     * @param actionPath TODO
      * @return List of converted SAL Actions.
      */
     public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> toMDSalActions(
-            List<Action> actionList) {
+            List<Action> actionList, OpenflowVersion ofVersion, ActionPath actionPath) {
 
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> bucketActions = new ArrayList<>();
         for (Action action : actionList) {
             if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class))
-                bucketActions.add(ofToSALOutputAction(action));
-            else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class))
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class)) {
+                bucketActions.add(ofToSALOutputAction(ofVersion, action));
+
+            } else if (action.getType().equals(
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class)) {
                 bucketActions.add(ofToSALGroupAction(action));
-            else if (action.getType().equals(
+
+            } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class)) {
                 CopyTtlOutBuilder copyTtlOutaction = new CopyTtlOutBuilder();
                 bucketActions.add(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyTtlOutaction.build()).build());
+
             } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class)) {
                 CopyTtlInBuilder copyTtlInaction = new CopyTtlInBuilder();
                 bucketActions.add(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInaction.build()).build());
+
             } else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class))
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class)) {
                 bucketActions.add(ofToSALSetMplsTtl(action));
-            else if (action.getType().equals(
+
+            } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class)) {
                 DecMplsTtlBuilder decMplsTtl = new DecMplsTtlBuilder();
                 bucketActions.add(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtl.build()).build());
+
             } else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class))
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class)) {
                 bucketActions.add(ofToSALPushVlanAction(action));
-            else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)) {
+
+            } else if (action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)
+                    || action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class)) {
+                // OF1.0 nodes will emit StripVlan and OF1.3+ will emit StripVlan/PopVlan, convert both to PopVlan for SAL
                 PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
                 bucketActions.add(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
+
             } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class)) {
-                PushMplsActionBuilder pushMpls = new PushMplsActionBuilder();
-                bucketActions.add(new PushMplsActionCaseBuilder().setPushMplsAction(pushMpls.build()).build());
+                bucketActions.add(ofToSALPushMplsAction(action));
+
             } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class)) {
-                PopMplsActionBuilder popMpls = new PopMplsActionBuilder();
-                bucketActions.add(new PopMplsActionCaseBuilder().setPopMplsAction(popMpls.build()).build());
+                bucketActions.add(ofToSALPopMplsAction(action));
+
             } else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class))
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class)) {
                 bucketActions.add(ofToSALSetQueue(action));
 
-            else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class))
+            else if (action.getType().equals(
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class)) {
                 bucketActions.add(ofToSALSetNwTtl(action));
-            else if (action.getType().equals(
+
+            } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class)) {
                 DecNwTtlBuilder decNwTtl = new DecNwTtlBuilder();
                 bucketActions.add(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl.build()).build());
+
             } else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class))
-                bucketActions.add(new SetFieldCaseBuilder().setSetField(MatchConvertorImpl.ofToSALSetField(action))
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class)) {
+                bucketActions.add(new SetFieldCaseBuilder().setSetField(MatchConvertorImpl.fromOFSetFieldToSALSetFieldAction(action, ofVersion))
                         .build());
-
-            else if (action.getType().equals(
-                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class))
+            } else if (action.getType().equals(
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class)) {
                 bucketActions.add(ofToSALPushPbbAction(action));
-            else if (action.getType().equals(
+
+            } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb.class)) {
                 PopPbbActionBuilder popPbb = new PopPbbActionBuilder();
                 bucketActions.add(new PopPbbActionCaseBuilder().setPopPbbAction(popPbb.build()).build());
+
             } else if (action.getType().equals(
                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) {
-                // bucketActions.add(ofToSALExperimenter(action));
-                // TODO: Need to explore/discuss on how to handle experimenter
-                // case.
+                /**
+                 * TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
+                 * - we might also need a way on how to identify exact type of augmentation to be 
+                 *   used as match can be bound to multiple models
+                 */
+                org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action processedAction = 
+                        ActionExtensionHelper.processAlienAction(action, ofVersion, actionPath);
+                if (processedAction != null) {
+                    bucketActions.add(processedAction);
+                }
             }
-
         }
         return bucketActions;
     }
@@ -925,17 +987,20 @@ public final class ActionConvertor {
     /**
      * Method converts OF Output action object to SAL Output action object.
      *
-     * @param action
-     *            org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.
-     *            action.rev130731.actions.actions.list.Action
+     * @param ofVersion
+     * @param ofVersion
+     * @param action    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.
+     *                  action.rev130731.actions.actions.list.Action
      * @return OutputAction
      */
-    public static OutputActionCase ofToSALOutputAction(Action action) {
-
+    public static OutputActionCase ofToSALOutputAction(OpenflowVersion ofVersion, Action action) {
         OutputActionBuilder outputAction = new OutputActionBuilder();
         PortAction port = action.getAugmentation(PortAction.class);
         if (port != null) {
-            outputAction.setOutputNodeConnector(new Uri(port.getPort().getValue().toString()));
+            CommonPort.PortNumber protocolAgnosticPort = OpenflowPortsUtil.getProtocolAgnosticPort(
+                    ofVersion, port.getPort().getValue());
+            String portNumberAsString = OpenflowPortsUtil.portNumberToString(protocolAgnosticPort);
+            outputAction.setOutputNodeConnector(new Uri(portNumberAsString));
         } else {
             logger.error("Provided action is not OF Output action, no associated port found!");
         }
@@ -992,11 +1057,43 @@ public final class ActionConvertor {
         PushVlanActionBuilder pushVlanAction = new PushVlanActionBuilder();
 
         EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
-        pushVlanAction.setVlanId(new VlanId(etherType.getEthertype().getValue()));
+        pushVlanAction.setEthernetType(etherType.getEthertype().getValue());
 
         return new PushVlanActionCaseBuilder().setPushVlanAction(pushVlanAction.build()).build();
     }
 
+    /**
+     * Method converts OF PushMpls action to SAL PushMpls action.
+     *
+     * @param action
+     * @return PushMplsAction
+     */
+    public static PushMplsActionCase ofToSALPushMplsAction(Action action) {
+
+        PushMplsActionBuilder pushMplsAction = new PushMplsActionBuilder();
+
+        EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
+        pushMplsAction.setEthernetType(etherType.getEthertype().getValue());
+
+        return new PushMplsActionCaseBuilder().setPushMplsAction(pushMplsAction.build()).build();
+    }
+
+    /**
+     * Method converts OF PopMpls action to SAL PopMpls action.
+     *
+     * @param action
+     * @return PopMplsActionCase
+     */
+    public static PopMplsActionCase ofToSALPopMplsAction(Action action) {
+
+        PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder();
+
+        EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
+        popMplsAction.setEthernetType(etherType.getEthertype().getValue());
+
+        return new PopMplsActionCaseBuilder().setPopMplsAction(popMplsAction.build()).build();
+    }
+
     /**
      * Method converts OF SetQueue action to SAL SetQueue action.
      *
@@ -1009,7 +1106,6 @@ public final class ActionConvertor {
 
         QueueIdAction queueId = action.getAugmentation(QueueIdAction.class);
         setQueueAction.setQueueId(queueId.getQueueId());
-
         return new SetQueueActionCaseBuilder().setSetQueueAction(setQueueAction.build()).build();
     }
 
@@ -1044,14 +1140,38 @@ public final class ActionConvertor {
         return new PushPbbActionCaseBuilder().setPushPbbAction(pushPbbAction.build()).build();
     }
 
-    public static Object ofToSALExperimenter(Action action) {
-
-        ExperimenterAction ExperimenterAction = action.getAugmentation(ExperimenterAction.class);
+    //TODO make a model in YANG for protocols 
+    /*private enum IPProtocols {
+        ICMP(1), 
+        TCP(6), 
+        UDP(17), 
+        ICMPV6(58);
 
-        return null;
-        /*
-         * TODO: Need to explore/discuss about how to handle experimenter
-         */
+        private int protocol;
+        
+        private static Map<Integer, IPProtocols> valueMap;
+        static {
+            valueMap = new HashMap<>();
+            for(IPProtocols protocols : IPProtocols.values()) {
+                valueMap.put(protocols.protocol, protocols);
+            }
+        }
+        
+        private IPProtocols(int value) {
+            this.protocol = value;
+        }
 
-    }
+        private byte getValue() {
+            return (byte) this.protocol;
+        }
+        
+        private Short getShortValue() {
+            return new Short((short) protocol);
+        }
+        
+        private IPProtocols fromProtocolNum(Short protocolNum) {
+            return valueMap.get(protocolNum);
+        }
+    }    */
+    
 }