Bug 1187 - of-flow: instruction/.../action/set-field with missing detail in operation...
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / match / MatchConvertorImpl.java
index a08f28d20b08f8c2e17f45a5dbaae0e7f528862a..74701163cacade026bd62def819d3c5cac9e21c7 100644 (file)
@@ -11,8 +11,10 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
 import java.math.BigInteger;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
 import org.opendaylight.openflowplugin.openflow.md.OFConstants;
 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
@@ -54,6 +56,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagMatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
@@ -107,6 +111,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
 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.PortNumberMatchEntry;
@@ -117,6 +122,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
@@ -156,11 +163,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Meta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpFlag;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;
@@ -173,12 +182,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Splitter;
+
 /**
  * Utility class for converting a MD-SAL Flow into the OF flow mod
  */
 public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
     private static final Logger logger = LoggerFactory.getLogger(MatchConvertorImpl.class);
     static final String PREFIX_SEPARATOR = "/";
+    static final Splitter PREFIX_SPLITTER = Splitter.on('/');
     private static final byte[] VLAN_VID_MASK = new byte[] { 16, 0 };
     private static final short PROTO_TCP = 6;
     private static final short PROTO_UDP = 17;
@@ -186,7 +198,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
 
     @Override
     public List<MatchEntries> convert(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match, BigInteger datapathid) {
+            final org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match, final BigInteger datapathid) {
         List<MatchEntries> matchEntriesList = new ArrayList<>();
 
         if (match.getInPort() != null) {
@@ -393,6 +405,14 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
             }
         }
 
+        //FIXME: move to extensible support
+        TcpFlagMatch tcpFlagMatch = match.getTcpFlagMatch();
+        if (tcpFlagMatch != null) {
+            if (tcpFlagMatch.getTcpFlag() != null) {
+                matchEntriesList.add(toOfTcpFlag(tcpFlagMatch.getTcpFlag()));
+            }
+        }
+
         org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel tunnel = match
                 .getTunnel();
         if (tunnel != null) {
@@ -410,7 +430,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
      * @return
      * @author avishnoi@in.ibm.com
      */
-    public static Match fromOFMatchV10ToSALMatch(MatchV10 swMatch, BigInteger datapathid) {
+    public static Match fromOFMatchV10ToSALMatch(final MatchV10 swMatch, final BigInteger datapathid) {
         MatchBuilder matchBuilder = new MatchBuilder();
         EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
         VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
@@ -442,8 +462,9 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         }
         if (!swMatch.getWildcards().isDLVLAN().booleanValue() && swMatch.getDlVlan() != null) {
             VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
-            vlanIdBuilder.setVlanId(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId(swMatch
-                    .getDlVlan()));
+            int vlanId = (swMatch.getDlVlan() == ((int) 0xffff)) ? 0 : swMatch.getDlVlan();
+            vlanIdBuilder.setVlanId(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId(vlanId));
+            vlanIdBuilder.setVlanIdPresent(vlanId == 0 ? false: true);
             vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
             matchBuilder.setVlanMatch(vlanMatchBuilder.build());
         }
@@ -478,31 +499,37 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         }
         if (!swMatch.getWildcards().isNWPROTO().booleanValue() && swMatch.getNwProto() == PROTO_TCP) {
             TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
-            if (!swMatch.getWildcards().isTPSRC().booleanValue() && swMatch.getTpSrc() != null)
+            if (!swMatch.getWildcards().isTPSRC().booleanValue() && swMatch.getTpSrc() != null) {
                 tcpMatchBuilder
                         .setTcpSourcePort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(
                                 swMatch.getTpSrc()));
-            if (!swMatch.getWildcards().isTPDST().booleanValue() && swMatch.getTpDst() != null)
+            }
+            if (!swMatch.getWildcards().isTPDST().booleanValue() && swMatch.getTpDst() != null) {
                 tcpMatchBuilder
                         .setTcpDestinationPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(
                                 swMatch.getTpDst()));
+            }
 
-            if (!swMatch.getWildcards().isTPSRC().booleanValue() || !swMatch.getWildcards().isTPDST().booleanValue())
+            if (!swMatch.getWildcards().isTPSRC().booleanValue() || !swMatch.getWildcards().isTPDST().booleanValue()) {
                 matchBuilder.setLayer4Match(tcpMatchBuilder.build());
+            }
         }
         if (!swMatch.getWildcards().isNWPROTO().booleanValue() && swMatch.getNwProto() == PROTO_UDP) {
             UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
-            if (!swMatch.getWildcards().isTPSRC().booleanValue() && swMatch.getTpSrc() != null)
+            if (!swMatch.getWildcards().isTPSRC().booleanValue() && swMatch.getTpSrc() != null) {
                 udpMatchBuilder
                         .setUdpSourcePort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(
                                 swMatch.getTpSrc()));
-            if (!swMatch.getWildcards().isTPDST().booleanValue() && swMatch.getTpDst() != null)
+            }
+            if (!swMatch.getWildcards().isTPDST().booleanValue() && swMatch.getTpDst() != null) {
                 udpMatchBuilder
                         .setUdpDestinationPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(
                                 swMatch.getTpDst()));
+            }
 
-            if (!swMatch.getWildcards().isTPSRC().booleanValue() || !swMatch.getWildcards().isTPDST().booleanValue())
+            if (!swMatch.getWildcards().isTPSRC().booleanValue() || !swMatch.getWildcards().isTPDST().booleanValue()) {
                 matchBuilder.setLayer4Match(udpMatchBuilder.build());
+            }
         }
         if (!swMatch.getWildcards().isNWTOS().booleanValue() && swMatch.getNwTos() != null) {
             // DSCP default value is 0 from the library but controller side it
@@ -526,9 +553,15 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
      * @author avishnoi@in.ibm.com
      */
     public static Match fromOFMatchToSALMatch(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match swMatch,
-            BigInteger datapathid) {
+            final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match swMatch,
+            final BigInteger datapathid) {
+        
+        return OfMatchToSALMatchConvertor(swMatch.getMatchEntries(), datapathid);
+
+    }
 
+    private static Match OfMatchToSALMatchConvertor(List<MatchEntries> swMatchList, final BigInteger datapathid){
+        
         MatchBuilder matchBuilder = new MatchBuilder();
         EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
         VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
@@ -542,8 +575,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
         Ipv6MatchBuilder ipv6MatchBuilder = new Ipv6MatchBuilder();
         ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = new ProtocolMatchFieldsBuilder();
-
-        List<MatchEntries> swMatchList = swMatch.getMatchEntries();
+        TcpFlagMatchBuilder tcpFlagMatchBuilder = new TcpFlagMatchBuilder();
 
         for (MatchEntries ofMatch : swMatchList) {
 
@@ -704,7 +736,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
                         }
                         ipv4PrefixStr += PREFIX_SEPARATOR + (32-shiftCount);
                     }else{
-                        //Openflow Spec : 1.3.2 
+                        //Openflow Spec : 1.3.2
                         //An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
                         // So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
                         // statistics response.
@@ -751,7 +783,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
                         arpSourceHardwareAddressBuilder.setAddress(macAddressMatchEntry.getMacAddress());
                         MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
                         if (maskMatchEntry != null) {
-                            arpSourceHardwareAddressBuilder.setMask(new MacAddress(ByteUtil
+                            arpSourceHardwareAddressBuilder.setMask(new MacAddress(ByteBufUtils
                                     .macAddressToString(maskMatchEntry.getMask())));
                         }
                         arpMatchBuilder.setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder.build());
@@ -762,7 +794,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
                         arpTargetHardwareAddressBuilder.setAddress(macAddressMatchEntry.getMacAddress());
                         MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
                         if (maskMatchEntry != null) {
-                            arpTargetHardwareAddressBuilder.setMask(new MacAddress(ByteUtil
+                            arpTargetHardwareAddressBuilder.setMask(new MacAddress(ByteBufUtils
                                     .macAddressToString(maskMatchEntry.getMask())));
                         }
                         arpMatchBuilder.setArpTargetHardwareAddress(arpTargetHardwareAddressBuilder.build());
@@ -775,9 +807,11 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
                 if (ipv6AddressMatchEntry != null) {
                     String ipv6PrefixStr = ipv6AddressMatchEntry.getIpv6Address().getValue();
                     MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
-                    if (maskMatchEntry != null) {
-                        ipv6PrefixStr += PREFIX_SEPARATOR + ByteBuffer.wrap(maskMatchEntry.getMask()).getInt();
+                    if(maskMatchEntry != null){
+                        ipv6PrefixStr += PREFIX_SEPARATOR
+                                + MatchConvertorUtil.ipv6NetmaskArrayToCIDRValue(maskMatchEntry.getMask());
                     }
+                        
                     if (ofMatch.getOxmMatchField().equals(Ipv6Src.class)) {
                         ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix(ipv6PrefixStr));
                     }
@@ -875,12 +909,18 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
                     }
                     matchBuilder.setTunnel(tunnelBuilder.build());
                 }
+            } else if (ofMatch.getOxmMatchField().equals(TcpFlag.class)) {
+                //FIXME: move to extensible support
+                TcpFlagMatchEntry tcpFlagMatch = ofMatch.getAugmentation(TcpFlagMatchEntry.class);
+                if (tcpFlagMatch != null) {
+                    tcpFlagMatchBuilder.setTcpFlag(tcpFlagMatch.getTcpFlag());
+                    matchBuilder.setTcpFlagMatch(tcpFlagMatchBuilder.build());
+                }
             }
         }
         return matchBuilder.build();
     }
-
-    private static MatchEntries toOfMplsPbb(Pbb pbb) {
+    private static MatchEntries toOfMplsPbb(final Pbb pbb) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         boolean hasmask = false;
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
@@ -896,7 +936,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfMplsTc(Short mplsTc) {
+    private static MatchEntries toOfMplsTc(final Short mplsTc) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -907,7 +947,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfMplsBos(Short mplsBos) {
+    private static MatchEntries toOfMplsBos(final Short mplsBos) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -922,7 +962,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfMplsLabel(Long mplsLabel) {
+    private static MatchEntries toOfMplsLabel(final Long mplsLabel) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -933,7 +973,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfIpv6ExtHeader(Ipv6ExtHeader ipv6ExtHeader) {
+    private static MatchEntries toOfIpv6ExtHeader(final Ipv6ExtHeader ipv6ExtHeader) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         boolean hasmask = false;
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
@@ -959,7 +999,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfIpv6FlowLabel(Ipv6Label ipv6Label) {
+    private static MatchEntries toOfIpv6FlowLabel(final Ipv6Label ipv6Label) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         boolean hasmask = false;
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
@@ -975,7 +1015,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfPort(Class<? extends MatchField> field, Long portNumber) {
+    private static MatchEntries toOfPort(final Class<? extends MatchField> field, final Long portNumber) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -986,8 +1026,8 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfMetadata(Class<? extends MatchField> field, BigInteger metadata,
-            BigInteger metadataMask) {
+    private static MatchEntries toOfMetadata(final Class<? extends MatchField> field, final BigInteger metadata,
+            final BigInteger metadataMask) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         boolean hasmask = false;
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
@@ -1002,9 +1042,9 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    public static MatchEntries toOfMacAddress(Class<? extends MatchField> field,
-            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress macAddress,
-            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress mask) {
+    public static MatchEntries toOfMacAddress(final Class<? extends MatchField> field,
+            final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress macAddress,
+            final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress mask) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         boolean hasmask = false;
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
@@ -1012,13 +1052,13 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         addMacAddressAugmentation(matchEntriesBuilder, macAddress);
         if (mask != null) {
             hasmask = true;
-            addMaskAugmentation(matchEntriesBuilder, ByteUtil.macAddressToBytes(mask));
+            addMaskAugmentation(matchEntriesBuilder, ByteBufUtils.macAddressToBytes(mask.getValue()));
         }
         matchEntriesBuilder.setHasMask(hasmask);
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfEthernetType(EthernetType ethernetType) {
+    private static MatchEntries toOfEthernetType(final EthernetType ethernetType) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -1029,8 +1069,8 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfLayer3Port(Class<? extends MatchField> field,
-            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber portNumber) {
+    private static MatchEntries toOfLayer3Port(final Class<? extends MatchField> field,
+            final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber portNumber) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -1041,7 +1081,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfIcmpv4Type(Short icmpv4Type) {
+    private static MatchEntries toOfIcmpv4Type(final Short icmpv4Type) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -1052,7 +1092,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfIcmpv4Code(Short icmpv4Code) {
+    private static MatchEntries toOfIcmpv4Code(final Short icmpv4Code) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -1063,7 +1103,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfIcmpv6Type(Short icmpv6Type) {
+    private static MatchEntries toOfIcmpv6Type(final Short icmpv6Type) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -1074,7 +1114,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfIcmpv6Code(Short icmpv6Code) {
+    private static MatchEntries toOfIcmpv6Code(final Short icmpv6Code) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -1085,7 +1125,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    public static MatchEntries toOfIpv4Prefix(Class<? extends MatchField> field, Ipv4Prefix ipv4Prefix) {
+    public static MatchEntries toOfIpv4Prefix(final Class<? extends MatchField> field, final Ipv4Prefix ipv4Prefix) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setOxmMatchField(field);
@@ -1094,7 +1134,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfIpv6Prefix(Class<? extends MatchField> field, Ipv6Prefix ipv6Prefix) {
+    private static MatchEntries toOfIpv6Prefix(final Class<? extends MatchField> field, final Ipv6Prefix ipv6Prefix) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setOxmMatchField(field);
@@ -1103,7 +1143,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    public static MatchEntries toOfIpDscp(Dscp ipDscp) {
+    public static MatchEntries toOfIpDscp(final Dscp ipDscp) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -1115,7 +1155,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
     }
 
     public static MatchEntries toOfVlanPcp(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp vlanPcp) {
+            final org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp vlanPcp) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -1126,7 +1166,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfVlanVid(VlanId vlanId) {
+    private static MatchEntries toOfVlanVid(final VlanId vlanId) {
         // TODO: verify
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         boolean hasmask = false;
@@ -1152,7 +1192,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfIpProto(Short ipProtocol) {
+    private static MatchEntries toOfIpProto(final Short ipProtocol) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -1163,7 +1203,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfIpEcn(Short ipEcn) {
+    private static MatchEntries toOfIpEcn(final Short ipEcn) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -1174,7 +1214,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfArpOpCode(Integer arpOp) {
+    private static MatchEntries toOfArpOpCode(final Integer arpOp) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -1185,7 +1225,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static MatchEntries toOfIpv6Address(Ipv6Address address) {
+    private static MatchEntries toOfIpv6Address(final Ipv6Address address) {
         MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setHasMask(false);
@@ -1196,21 +1236,34 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return matchEntriesBuilder.build();
     }
 
-    private static void addMaskAugmentation(MatchEntriesBuilder builder, byte[] mask) {
+    //FIXME: move to extensible support
+    private static MatchEntries toOfTcpFlag(Integer tcpFlag) {
+        MatchEntriesBuilder matchBuilder = new MatchEntriesBuilder();
+        matchBuilder.setOxmClass(Nxm1Class.class);
+        matchBuilder.setHasMask(false);
+        matchBuilder.setOxmMatchField(TcpFlag.class);
+        TcpFlagMatchEntryBuilder tcpFlagBuilder = new TcpFlagMatchEntryBuilder();
+        tcpFlagBuilder.setTcpFlag(tcpFlag);
+        matchBuilder.addAugmentation(TcpFlagMatchEntry.class, tcpFlagBuilder.build());
+        return matchBuilder.build();
+    }
+
+    private static void addMaskAugmentation(final MatchEntriesBuilder builder, final byte[] mask) {
         MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder();
         maskBuilder.setMask(mask);
         builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());
     }
 
-    private static boolean addIpv6PrefixAugmentation(MatchEntriesBuilder builder, Ipv6Prefix address) {
+    private static boolean addIpv6PrefixAugmentation(final MatchEntriesBuilder builder, final Ipv6Prefix address) {
         boolean hasMask = false;
-        String[] addressParts = address.getValue().split(PREFIX_SEPARATOR);
+        Iterator<String> addressParts = PREFIX_SPLITTER.split(address.getValue()).iterator();
+        Ipv6Address ipv6Address = new Ipv6Address(addressParts.next());
+
         Integer prefix = null;
-        if (addressParts.length == 2) {
-            prefix = Integer.parseInt(addressParts[1]);
+        if (addressParts.hasNext()) {
+            prefix = Integer.parseInt(addressParts.next());
         }
 
-        Ipv6Address ipv6Address = new Ipv6Address(addressParts[0]);
         Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder();
         ipv6AddressBuilder.setIpv6Address(ipv6Address);
         builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build());
@@ -1221,7 +1274,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return hasMask;
     }
 
-    private static byte[] convertIpv6PrefixToByteArray(int prefix) {
+    private static byte[] convertIpv6PrefixToByteArray(final int prefix) {
         // TODO: Temporary fix. Has performance impacts.
         byte[] mask = new byte[16];
         int oneCount = prefix;
@@ -1240,7 +1293,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return mask;
     }
 
-    private static void addMetadataAugmentation(MatchEntriesBuilder builder, BigInteger metadata) {
+    private static void addMetadataAugmentation(final MatchEntriesBuilder builder, final BigInteger metadata) {
         MetadataMatchEntryBuilder metadataMatchEntry = new MetadataMatchEntryBuilder();
         metadataMatchEntry.setMetadata(ByteUtil.convertBigIntegerToNBytes(metadata, OFConstants.SIZE_OF_LONG_IN_BYTES));
         builder.addAugmentation(MetadataMatchEntry.class, metadataMatchEntry.build());
@@ -1250,17 +1303,18 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
      * @return true if Ipv4Prefix contains prefix (and it is used in mask),
      *         false otherwise
      */
-    private static boolean addIpv4PrefixAugmentation(MatchEntriesBuilder builder, Ipv4Prefix address) {
+    private static boolean addIpv4PrefixAugmentation(final MatchEntriesBuilder builder, final Ipv4Prefix address) {
         boolean hasMask = false;
-        String[] addressParts = address.getValue().split(PREFIX_SEPARATOR);
-        Integer prefix = null;
-        if (addressParts.length < 2) {
-            prefix = 0;
+        Iterator<String> addressParts = PREFIX_SPLITTER.split(address.getValue()).iterator();
+        Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
+
+        final int prefix;
+        if (addressParts.hasNext()) {
+            prefix = Integer.parseInt(addressParts.next());
         } else {
-            prefix = Integer.parseInt(addressParts[1]);
+            prefix = 0;
         }
 
-        Ipv4Address ipv4Address = new Ipv4Address(addressParts[0]);
         Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder();
         ipv4AddressBuilder.setIpv4Address(ipv4Address);
         builder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build());
@@ -1274,433 +1328,25 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         return hasMask;
     }
 
-    private static void addMacAddressAugmentation(MatchEntriesBuilder builder, MacAddress address) {
+    private static void addMacAddressAugmentation(final MatchEntriesBuilder builder, final MacAddress address) {
         MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder();
         macAddress.setMacAddress(address);
         builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build());
     }
 
     /**
-     * Method converts OF SetField Match to SAL SetFiled matches TODO: enable or
-     * delete
+     * Method converts OF SetField action to SAL SetFiled action.
      *
      * @param action
      * @return
      */
-    public static SetField ofToSALSetField(
-            Action action) {
-        logger.debug("OF SetField match to SAL SetField match converstion begins");
+    public static SetField fromOFSetFieldToSALSetFieldAction(
+            final Action action) {
+        logger.debug("Converting OF SetField action to SAL SetField action");
         SetFieldBuilder setField = new SetFieldBuilder();
-        /*
-         * OxmFieldsAction oxmFields =
-         * action.getAugmentation(OxmFieldsAction.class);
-         *
-         * List<MatchEntries> matchEntries = oxmFields.getMatchEntries();
-         * org.opendaylight
-         * .yang.gen.v1.urn.opendaylight.action.types.rev131112.action
-         * .action.set.field.MatchBuilder match =new
-         * org.opendaylight.yang.gen.v1
-         * .urn.opendaylight.action.types.rev131112.action
-         * .action.set.field.MatchBuilder();
-         *
-         * EthernetMatchBuilder ethernetMatchBuilder = null; VlanMatchBuilder
-         * vlanMatchBuilder = null; IpMatchBuilder ipMatchBuilder = null;
-         * TcpMatchBuilder tcpMatchBuilder = null; UdpMatchBuilder
-         * udpMatchBuilder = null; SctpMatchBuilder sctpMatchBuilder = null;
-         * Icmpv4MatchBuilder icmpv4MatchBuilder = null; Icmpv6MatchBuilder
-         * icmpv6MatchBuilder = null; Ipv4MatchBuilder ipv4MatchBuilder = null;
-         * ArpMatchBuilder arpMatchBuilder = null; Ipv6MatchBuilder
-         * ipv6MatchBuilder = null; ProtocolMatchFieldsBuilder
-         * protocolMatchFieldsBuilder = null;
-         *
-         * for(MatchEntries matchEntry : matchEntries){ if(matchEntry instanceof
-         * InPort){ PortNumberMatchEntry inPort =
-         * matchEntry.getAugmentation(PortNumberMatchEntry.class);
-         * match.setInPort(inPort.getPortNumber().getValue()); }else if
-         * (matchEntry instanceof InPhyPort){ PortNumberMatchEntry phyPort =
-         * matchEntry.getAugmentation(PortNumberMatchEntry.class);
-         * match.setInPhyPort(phyPort.getPortNumber().getValue()); }else if
-         * (matchEntry instanceof Metadata){ MetadataMatchEntry metadataMatch =
-         * matchEntry.getAugmentation(MetadataMatchEntry.class); MetadataBuilder
-         * metadataBuilder = new MetadataBuilder();
-         * metadataBuilder.setMetadata(new
-         * BigInteger(metadataMatch.getMetadata())); MaskMatchEntry maskMatch =
-         * matchEntry.getAugmentation(MaskMatchEntry.class); if (maskMatch !=
-         * null){ metadataBuilder.setMetadataMask(maskMatch.getMask()); }
-         * match.setMetadata(metadataBuilder.build()); }else if (matchEntry
-         * instanceof EthDst){
-         *
-         * if(ethernetMatchBuilder == null) ethernetMatchBuilder = new
-         * EthernetMatchBuilder();
-         *
-         * MacAddressMatchEntry macAddressMatch =
-         * matchEntry.getAugmentation(MacAddressMatchEntry.class);
-         * MaskMatchEntry maskMatch =
-         * matchEntry.getAugmentation(MaskMatchEntry.class);
-         * EthernetDestinationBuilder ethernetDestination = new
-         * EthernetDestinationBuilder();
-         * ethernetDestination.setAddress(macAddressMatch.getMacAddress());
-         * if(maskMatch != null){
-         * ethernetDestination.setMask(maskMatch.getMask()); }
-         * ethernetMatchBuilder
-         * .setEthernetDestination(ethernetDestination.build()); }else if
-         * (matchEntry instanceof EthSrc){ if(ethernetMatchBuilder == null)
-         * ethernetMatchBuilder = new EthernetMatchBuilder();
-         *
-         * MacAddressMatchEntry macAddressMatch =
-         * matchEntry.getAugmentation(MacAddressMatchEntry.class);
-         * MaskMatchEntry maskMatch =
-         * matchEntry.getAugmentation(MaskMatchEntry.class);
-         * EthernetSourceBuilder ethernetSource = new EthernetSourceBuilder();
-         * ethernetSource.setAddress(macAddressMatch.getMacAddress());
-         * if(maskMatch != null){ ethernetSource.setMask(maskMatch.getMask()); }
-         * ethernetMatchBuilder.setEthernetSource(ethernetSource.build()); }else
-         * if (matchEntry instanceof EthType){ if(ethernetMatchBuilder == null)
-         * ethernetMatchBuilder = new EthernetMatchBuilder();
-         *
-         * EthTypeMatchEntry etherTypeMatch =
-         * matchEntry.getAugmentation(EthTypeMatchEntry.class);
-         * EthernetTypeBuilder ethernetType= new EthernetTypeBuilder();
-         * org.opendaylight
-         * .yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType etherType
-         * = new
-         * org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827
-         * .EtherType((long)etherTypeMatch.getEthType().getValue());
-         * ethernetType.setType(etherType);
-         * ethernetMatchBuilder.setEthernetType(ethernetType.build()); }else if
-         * (matchEntry instanceof VlanVid){ if(vlanMatchBuilder == null)
-         * vlanMatchBuilder = new VlanMatchBuilder();
-         *
-         * VlanVidMatchEntry vlanVidMatch =
-         * matchEntry.getAugmentation(VlanVidMatchEntry.class); MaskMatchEntry
-         * maskMatch = matchEntry.getAugmentation(MaskMatchEntry.class);
-         *
-         * VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
-         * vlanIdBuilder.setVlanId( new
-         * org.opendaylight.yang.gen.v1.urn.opendaylight
-         * .l2.types.rev130827.VlanId(vlanVidMatch.getVlanVid())); if(maskMatch
-         * != null){ vlanIdBuilder.setMask(maskMatch.getMask()); }
-         * vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
-         *
-         * }else if (matchEntry instanceof VlanPcp){ if(vlanMatchBuilder ==
-         * null) vlanMatchBuilder = new VlanMatchBuilder();
-         *
-         * VlanPcpMatchEntry vlanPcpMatch =
-         * matchEntry.getAugmentation(VlanPcpMatchEntry.class);
-         * vlanMatchBuilder.setVlanPcp( new
-         * org.opendaylight.yang.gen.v1.urn.opendaylight
-         * .l2.types.rev130827.VlanPcp(vlanPcpMatch.getVlanPcp())); }else if
-         * (matchEntry instanceof IpDscp){ if(ipMatchBuilder == null)
-         * ipMatchBuilder = new IpMatchBuilder();
-         *
-         * DscpMatchEntry dscpMatchEntry =
-         * matchEntry.getAugmentation(DscpMatchEntry.class);
-         * ipMatchBuilder.setIpDscp(dscpMatchEntry.getDscp());
-         *
-         * }else if (matchEntry instanceof IpEcn){ if(ipMatchBuilder == null)
-         * ipMatchBuilder = new IpMatchBuilder();
-         *
-         * EcnMatchEntry ecnMatchEntry =
-         * matchEntry.getAugmentation(EcnMatchEntry.class);
-         * ipMatchBuilder.setIpEcn(ecnMatchEntry.getEcn());
-         *
-         * }else if (matchEntry instanceof IpProto){ if(ipMatchBuilder == null)
-         * ipMatchBuilder = new IpMatchBuilder();
-         *
-         * ProtocolNumberMatchEntry protocolNumberMatch =
-         * matchEntry.getAugmentation(ProtocolNumberMatchEntry.class);
-         * ipMatchBuilder
-         * .setIpProtocol(protocolNumberMatch.getProtocolNumber()); }else if
-         * (matchEntry instanceof TcpSrc){ if(tcpMatchBuilder == null)
-         * tcpMatchBuilder = new TcpMatchBuilder();
-         *
-         * PortMatchEntry portMatchEntry =
-         * matchEntry.getAugmentation(PortMatchEntry.class);
-         * tcpMatchBuilder.setTcpSourcePort(portMatchEntry.getPort());
-         *
-         * }else if (matchEntry instanceof TcpDst){ if(tcpMatchBuilder == null)
-         * tcpMatchBuilder = new TcpMatchBuilder();
-         *
-         * PortMatchEntry portMatchEntry =
-         * matchEntry.getAugmentation(PortMatchEntry.class);
-         * tcpMatchBuilder.setTcpDestinationPort(portMatchEntry.getPort());
-         *
-         * }else if (matchEntry instanceof UdpSrc){ if(udpMatchBuilder == null)
-         * udpMatchBuilder = new UdpMatchBuilder();
-         *
-         * PortMatchEntry portMatchEntry =
-         * matchEntry.getAugmentation(PortMatchEntry.class);
-         * udpMatchBuilder.setUdpSourcePort(portMatchEntry.getPort());
-         *
-         *
-         * }else if (matchEntry instanceof UdpDst){ if(udpMatchBuilder == null)
-         * udpMatchBuilder = new UdpMatchBuilder();
-         *
-         * PortMatchEntry portMatchEntry =
-         * matchEntry.getAugmentation(PortMatchEntry.class);
-         * udpMatchBuilder.setUdpDestinationPort(portMatchEntry.getPort());
-         * }else if (matchEntry instanceof SctpSrc){ if(sctpMatchBuilder ==
-         * null) sctpMatchBuilder = new SctpMatchBuilder();
-         *
-         * PortMatchEntry portMatchEntry =
-         * matchEntry.getAugmentation(PortMatchEntry.class);
-         * sctpMatchBuilder.setSctpSourcePort(portMatchEntry.getPort());
-         *
-         * }else if (matchEntry instanceof SctpDst){ if(sctpMatchBuilder ==
-         * null) sctpMatchBuilder = new SctpMatchBuilder();
-         *
-         * PortMatchEntry portMatchEntry =
-         * matchEntry.getAugmentation(PortMatchEntry.class);
-         * sctpMatchBuilder.setSctpDestinationPort(portMatchEntry.getPort());
-         * }else if (matchEntry instanceof Icmpv4Type){ if(icmpv4MatchBuilder ==
-         * null) icmpv4MatchBuilder = new Icmpv4MatchBuilder();
-         *
-         * Icmpv4TypeMatchEntry icmpv4TypeMatchEntry =
-         * matchEntry.getAugmentation(Icmpv4TypeMatchEntry.class);
-         * icmpv4MatchBuilder
-         * .setIcmpv4Type(icmpv4TypeMatchEntry.getIcmpv4Type());
-         *
-         * }else if (matchEntry instanceof Icmpv4Code){ if(icmpv4MatchBuilder ==
-         * null) icmpv4MatchBuilder = new Icmpv4MatchBuilder();
-         *
-         * Icmpv4CodeMatchEntry icmpv4CodeMatchEntry =
-         * matchEntry.getAugmentation(Icmpv4CodeMatchEntry.class);
-         * icmpv4MatchBuilder
-         * .setIcmpv4Code(icmpv4CodeMatchEntry.getIcmpv4Code());
-         *
-         * }else if (matchEntry instanceof Icmpv6Type){ if(icmpv6MatchBuilder ==
-         * null) icmpv6MatchBuilder = new Icmpv6MatchBuilder();
-         *
-         * Icmpv6TypeMatchEntry icmpv6TypeMatchEntry =
-         * matchEntry.getAugmentation(Icmpv6TypeMatchEntry.class);
-         * icmpv6MatchBuilder
-         * .setIcmpv6Type(icmpv6TypeMatchEntry.getIcmpv6Type()); }else if
-         * (matchEntry instanceof Icmpv6Code){ if(icmpv6MatchBuilder == null)
-         * icmpv6MatchBuilder = new Icmpv6MatchBuilder();
-         *
-         * Icmpv6CodeMatchEntry icmpv6CodeMatchEntry =
-         * matchEntry.getAugmentation(Icmpv6CodeMatchEntry.class);
-         * icmpv6MatchBuilder
-         * .setIcmpv6Code(icmpv6CodeMatchEntry.getIcmpv6Code()); }else if
-         * (matchEntry instanceof Ipv4Src){ if(ipv4MatchBuilder == null)
-         * ipv4MatchBuilder = new Ipv4MatchBuilder();
-         *
-         * Ipv4AddressMatchEntry ipv4AddressMatchEntry =
-         * matchEntry.getAugmentation(Ipv4AddressMatchEntry.class);
-         * MaskMatchEntry maskMatchEntry =
-         * matchEntry.getAugmentation(MaskMatchEntry.class);
-         * ipv4MatchBuilder.setIpv4Source( new
-         * Ipv4Prefix(ipv4AddressMatchEntry.getIpv4Address().getValue() +"/"+new
-         * String(maskMatchEntry.getMask())));
-         *
-         * }else if (matchEntry instanceof Ipv4Dst){ if(ipv4MatchBuilder ==
-         * null) ipv4MatchBuilder = new Ipv4MatchBuilder();
-         *
-         * Ipv4AddressMatchEntry ipv4AddressMatchEntry =
-         * matchEntry.getAugmentation(Ipv4AddressMatchEntry.class);
-         * MaskMatchEntry maskMatchEntry =
-         * matchEntry.getAugmentation(MaskMatchEntry.class);
-         * ipv4MatchBuilder.setIpv4Destination( new
-         * Ipv4Prefix(ipv4AddressMatchEntry.getIpv4Address().getValue() +"/"+new
-         * String(maskMatchEntry.getMask()))); }else if (matchEntry instanceof
-         * ArpOp){ if(arpMatchBuilder == null) arpMatchBuilder = new
-         * ArpMatchBuilder();
-         *
-         * OpCodeMatchEntry opCodeMatchEntry =
-         * matchEntry.getAugmentation(OpCodeMatchEntry.class);
-         * arpMatchBuilder.setArpOp(opCodeMatchEntry.getOpCode());
-         *
-         * }else if (matchEntry instanceof ArpSpa){ if(arpMatchBuilder == null)
-         * arpMatchBuilder = new ArpMatchBuilder();
-         *
-         * Ipv4AddressMatchEntry ipv4AddressMatchEntry =
-         * matchEntry.getAugmentation(Ipv4AddressMatchEntry.class);
-         * MaskMatchEntry maskMatchEntry =
-         * matchEntry.getAugmentation(MaskMatchEntry.class);
-         * arpMatchBuilder.setArpSourceTransportAddress( new
-         * Ipv4Prefix(ipv4AddressMatchEntry.getIpv4Address().getValue() +"/"+new
-         * String(maskMatchEntry.getMask())));
-         *
-         * }else if (matchEntry instanceof ArpTpa){ if(arpMatchBuilder == null)
-         * arpMatchBuilder = new ArpMatchBuilder();
-         *
-         * Ipv4AddressMatchEntry ipv4AddressMatchEntry =
-         * matchEntry.getAugmentation(Ipv4AddressMatchEntry.class);
-         * MaskMatchEntry maskMatchEntry =
-         * matchEntry.getAugmentation(MaskMatchEntry.class);
-         * arpMatchBuilder.setArpTargetTransportAddress( new
-         * Ipv4Prefix(ipv4AddressMatchEntry.getIpv4Address().getValue() +"/"+new
-         * String(maskMatchEntry.getMask())));
-         *
-         * }else if (matchEntry instanceof ArpSha){ if(arpMatchBuilder == null)
-         * arpMatchBuilder = new ArpMatchBuilder();
-         *
-         * MacAddressMatchEntry macAddressMatchEntry =
-         * matchEntry.getAugmentation(MacAddressMatchEntry.class);
-         * MaskMatchEntry maskMatchEntry =
-         * matchEntry.getAugmentation(MaskMatchEntry.class);
-         * ArpSourceHardwareAddressBuilder arpSourceHardwareAddressBuilder = new
-         * ArpSourceHardwareAddressBuilder();
-         * arpSourceHardwareAddressBuilder.setAddress
-         * (macAddressMatchEntry.getMacAddress());
-         * arpSourceHardwareAddressBuilder.setMask(maskMatchEntry.getMask());
-         * arpMatchBuilder
-         * .setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder
-         * .build());
-         *
-         * }else if (matchEntry instanceof ArpTha){ if(arpMatchBuilder == null)
-         * arpMatchBuilder = new ArpMatchBuilder();
-         *
-         * MacAddressMatchEntry macAddressMatchEntry =
-         * matchEntry.getAugmentation(MacAddressMatchEntry.class);
-         * MaskMatchEntry maskMatchEntry =
-         * matchEntry.getAugmentation(MaskMatchEntry.class);
-         * ArpTargetHardwareAddressBuilder arpTargetHardwareAddressBuilder = new
-         * ArpTargetHardwareAddressBuilder();
-         * arpTargetHardwareAddressBuilder.setAddress
-         * (macAddressMatchEntry.getMacAddress());
-         * arpTargetHardwareAddressBuilder.setMask(maskMatchEntry.getMask());
-         * arpMatchBuilder
-         * .setArpTargetHardwareAddress(arpTargetHardwareAddressBuilder
-         * .build()); }else if (matchEntry instanceof Ipv6Src){
-         * if(ipv6MatchBuilder == null) ipv6MatchBuilder = new
-         * Ipv6MatchBuilder();
-         *
-         * Ipv6AddressMatchEntry ipv6AddressMatchEntry =
-         * matchEntry.getAugmentation(Ipv6AddressMatchEntry.class);
-         * MaskMatchEntry maskMatchEntry =
-         * matchEntry.getAugmentation(MaskMatchEntry.class);
-         * ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix
-         * (ipv6AddressMatchEntry.getIpv6Address().getValue()+ "/"+new
-         * String(maskMatchEntry.getMask())));
-         *
-         * }else if (matchEntry instanceof Ipv6Dst){ if(ipv6MatchBuilder ==
-         * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
-         *
-         * Ipv6AddressMatchEntry ipv6AddressMatchEntry =
-         * matchEntry.getAugmentation(Ipv6AddressMatchEntry.class);
-         * MaskMatchEntry maskMatchEntry =
-         * matchEntry.getAugmentation(MaskMatchEntry.class);
-         * ipv6MatchBuilder.setIpv6Destination(new Ipv6Prefix
-         * (ipv6AddressMatchEntry.getIpv6Address().getValue()+ "/"+new
-         * String(maskMatchEntry.getMask())));
-         *
-         * }else if (matchEntry instanceof Ipv6Flabel){ if(ipv6MatchBuilder ==
-         * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
-         *
-         * Ipv6FlabelMatchEntry ipv6FlabelMatchEntry =
-         * matchEntry.getAugmentation(Ipv6FlabelMatchEntry.class);
-         * MaskMatchEntry maskMatchEntry =
-         * matchEntry.getAugmentation(MaskMatchEntry.class); Ipv6LabelBuilder
-         * ipv6LabelBuilder = new Ipv6LabelBuilder();
-         * ipv6LabelBuilder.setIpv6Flabel(ipv6FlabelMatchEntry.getIpv6Flabel());
-         * ipv6LabelBuilder.setFlabelMask(maskMatchEntry.getMask());
-         * ipv6MatchBuilder.setIpv6Label(ipv6LabelBuilder.build());
-         *
-         * }else if (matchEntry instanceof Ipv6NdTarget){ if(ipv6MatchBuilder ==
-         * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
-         * Ipv6AddressMatchEntry ipv6AddressMatchEntry =
-         * matchEntry.getAugmentation(Ipv6AddressMatchEntry.class);
-         * ipv6MatchBuilder
-         * .setIpv6NdTarget(ipv6AddressMatchEntry.getIpv6Address());
-         *
-         * }else if (matchEntry instanceof Ipv6NdSll){ if(ipv6MatchBuilder ==
-         * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
-         *
-         * MacAddressMatchEntry macAddressMatchEntry =
-         * matchEntry.getAugmentation(MacAddressMatchEntry.class);
-         * ipv6MatchBuilder.setIpv6NdSll(macAddressMatchEntry.getMacAddress());
-         * }else if (matchEntry instanceof Ipv6NdTll){ if(ipv6MatchBuilder ==
-         * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
-         *
-         * MacAddressMatchEntry macAddressMatchEntry =
-         * matchEntry.getAugmentation(MacAddressMatchEntry.class);
-         * ipv6MatchBuilder.setIpv6NdTll(macAddressMatchEntry.getMacAddress());
-         *
-         * }else if (matchEntry instanceof Ipv6Exthdr){ if(ipv6MatchBuilder ==
-         * null) ipv6MatchBuilder = new Ipv6MatchBuilder();
-         *
-         * PseudoFieldMatchEntry pseudoFieldMatchEntry =
-         * matchEntry.getAugmentation(PseudoFieldMatchEntry.class); PseudoField
-         * pseudoField = pseudoFieldMatchEntry.getPseudoField(); int
-         * pseudoFieldInt = 0; pseudoFieldInt |= pseudoField.isNonext()?(1 <<
-         * 0):~(1 << 0); pseudoFieldInt |= pseudoField.isEsp()?(1 << 1):~(1 <<
-         * 1); pseudoFieldInt |= pseudoField.isAuth()?(1 << 2):~(1 << 2);
-         * pseudoFieldInt |= pseudoField.isDest()?(1 << 3):~(1 << 3);
-         * pseudoFieldInt |= pseudoField.isFrag()?(1 << 4):~(1 << 4);
-         * pseudoFieldInt |= pseudoField.isRouter()?(1 << 5):~(1 << 5);
-         * pseudoFieldInt |= pseudoField.isHop()?(1 << 6):~(1 << 6);
-         * pseudoFieldInt |= pseudoField.isUnrep()?(1 << 7):~(1 << 7);
-         * pseudoFieldInt |= pseudoField.isUnseq()?(1 << 8):~(1 << 8);
-         *
-         * ipv6MatchBuilder.setIpv6Exthdr(pseudoFieldInt); }else if (matchEntry
-         * instanceof MplsLabel){ if(protocolMatchFieldsBuilder == null)
-         * protocolMatchFieldsBuilder = new ProtocolMatchFieldsBuilder();
-         *
-         * MplsLabelMatchEntry MplsLabelMatchEntry =
-         * matchEntry.getAugmentation(MplsLabelMatchEntry.class);
-         * protocolMatchFieldsBuilder
-         * .setMplsLabel(MplsLabelMatchEntry.getMplsLabel());
-         *
-         * }else if (matchEntry instanceof MplsBos){
-         * if(protocolMatchFieldsBuilder == null) protocolMatchFieldsBuilder =
-         * new ProtocolMatchFieldsBuilder();
-         *
-         * BosMatchEntry bosMatchEntry =
-         * matchEntry.getAugmentation(BosMatchEntry.class);
-         * protocolMatchFieldsBuilder
-         * .setMplsBos(bosMatchEntry.isBos()?(short)1:(short)0);
-         *
-         * }else if (matchEntry instanceof MplsTc) {
-         * if(protocolMatchFieldsBuilder == null) protocolMatchFieldsBuilder =
-         * new ProtocolMatchFieldsBuilder();
-         *
-         * TcMatchEntry tcMatchEntry =
-         * matchEntry.getAugmentation(TcMatchEntry.class);
-         * protocolMatchFieldsBuilder.setMplsTc(tcMatchEntry.getTc());
-         *
-         * }else if (matchEntry instanceof PbbIsid){
-         * if(protocolMatchFieldsBuilder == null) protocolMatchFieldsBuilder =
-         * new ProtocolMatchFieldsBuilder();
-         *
-         * IsidMatchEntry isidMatchEntry =
-         * matchEntry.getAugmentation(IsidMatchEntry.class); PbbBuilder
-         * pbbBuilder = new PbbBuilder();
-         * pbbBuilder.setPbbIsid(isidMatchEntry.getIsid()); MaskMatchEntry
-         * maskMatchEntry = matchEntry.getAugmentation(MaskMatchEntry.class);
-         * if(maskMatchEntry != null)
-         * pbbBuilder.setPbbMask(maskMatchEntry.getMask());
-         *
-         * protocolMatchFieldsBuilder.setPbb(pbbBuilder.build()); }else if
-         * (matchEntry instanceof TunnelId){ MetadataMatchEntry
-         * metadataMatchEntry =
-         * matchEntry.getAugmentation(MetadataMatchEntry.class); MaskMatchEntry
-         * maskMatchEntry = matchEntry.getAugmentation(MaskMatchEntry.class);
-         * TunnelBuilder tunnelBuilder = new TunnelBuilder();
-         * tunnelBuilder.setTunnelId(new
-         * BigInteger(metadataMatchEntry.getMetadata()));
-         * tunnelBuilder.setTunnelMask(maskMatchEntry.getMask());
-         * match.setTunnel(tunnelBuilder.build()); } } if(ethernetMatchBuilder
-         * != null){ match.setEthernetMatch(ethernetMatchBuilder.build()); } if
-         * (vlanMatchBuilder != null){
-         * match.setVlanMatch(vlanMatchBuilder.build()); } if(ipMatchBuilder !=
-         * null){ match.setIpMatch(ipMatchBuilder.build()); } if(tcpMatchBuilder
-         * != null){ match.setLayer4Match(tcpMatchBuilder.build()); }
-         * if(udpMatchBuilder != null){
-         * match.setLayer4Match(udpMatchBuilder.build()); } if(sctpMatchBuilder
-         * != null){ match.setLayer4Match(sctpMatchBuilder.build()); }
-         * if(icmpv4MatchBuilder != null){
-         * match.setIcmpv4Match(icmpv4MatchBuilder.build()); }
-         * if(icmpv6MatchBuilder != null){
-         * match.setIcmpv6Match(icmpv6MatchBuilder.build()); }
-         * if(ipv4MatchBuilder != null){
-         * match.setLayer3Match(ipv4MatchBuilder.build()); } if(arpMatchBuilder
-         * != null){ match.setLayer3Match(arpMatchBuilder.build()); }
-         * if(ipv6MatchBuilder != null){
-         * match.setLayer3Match(ipv6MatchBuilder.build()); }
-         * if(protocolMatchFieldsBuilder != null){
-         * match.setProtocolMatchFields(protocolMatchFieldsBuilder.build()); }
-         * setField.setMatch(match.build());
-         */return setField.build();
+        OxmFieldsAction oxmFields = action.getAugmentation(OxmFieldsAction.class);
+        Match match = OfMatchToSALMatchConvertor(oxmFields.getMatchEntries(), null);
+        setField.fieldsFrom(match);
+        return setField.build();
     }
 }