Added dumpMsgCount osgi command
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / match / MatchConvertorImpl.java
index 7d18d6c8a0176f73bd85cd4e5208a7a85e1698e5..e6d9b0ad67d8e5e2534a922cca681a56685515b6 100644 (file)
@@ -14,6 +14,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 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.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
@@ -181,15 +182,15 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
     private static final short PROTO_UDP = 17;
 
     @Override
-    public List<MatchEntries> convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match) {
+    public List<MatchEntries> convert(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match,BigInteger datapathid) {
         List<MatchEntries> matchEntriesList = new ArrayList<>();
 
         if (match.getInPort() != null) {
-            matchEntriesList.add(toOfPort(InPort.class, match.getInPort()));
+            matchEntriesList.add(toOfPort(InPort.class, InventoryDataServiceUtil.portNumberfromNodeConnectorId(match.getInPort())));
         }
 
         if (match.getInPhyPort() != null) {
-            matchEntriesList.add(toOfPort(InPhyPort.class, match.getInPhyPort()));
+            matchEntriesList.add(toOfPort(InPhyPort.class, InventoryDataServiceUtil.portNumberfromNodeConnectorId(match.getInPhyPort())));
         }
 
         org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata metadata = match
@@ -403,7 +404,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
      * @return
      * @author avishnoi@in.ibm.com
      */
-    public static Match fromOFMatchV10ToSALMatch(MatchV10 swMatch){
+    public static Match fromOFMatchV10ToSALMatch(MatchV10 swMatch,BigInteger datapathid){
         MatchBuilder matchBuilder = new MatchBuilder();
         EthernetMatchBuilder ethMatchBuilder =  new EthernetMatchBuilder();
         VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
@@ -411,7 +412,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
        
         if(swMatch.getInPort() != null){
-            matchBuilder.setInPort((long)swMatch.getInPort());
+            matchBuilder.setInPort(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathid,(long)swMatch.getInPort()));
         }
         
         if(swMatch.getDlSrc()!= null){
@@ -499,7 +500,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
      * @author avishnoi@in.ibm.com
      */
     public static Match fromOFMatchToSALMatch(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match swMatch) {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match swMatch,BigInteger datapathid) {
         
         MatchBuilder matchBuilder = new MatchBuilder();
         EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
@@ -521,15 +522,15 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
             
             if(ofMatch.getOxmMatchField().equals(InPort.class)){
                 PortNumberMatchEntry portNumber = ofMatch.getAugmentation(PortNumberMatchEntry.class);
-                matchBuilder.setInPort(portNumber.getPortNumber().getValue());
+                matchBuilder.setInPort(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathid, portNumber.getPortNumber().getValue()));
             }else if (ofMatch.getOxmMatchField().equals(InPhyPort.class)){
                 PortNumberMatchEntry portNumber = ofMatch.getAugmentation(PortNumberMatchEntry.class);
-                matchBuilder.setInPhyPort(portNumber.getPortNumber().getValue());
+                matchBuilder.setInPhyPort(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathid,portNumber.getPortNumber().getValue()));
             }else if(ofMatch.getOxmMatchField().equals(Metadata.class)){
                 MetadataBuilder metadataBuilder = new MetadataBuilder();
                 MetadataMatchEntry metadataMatchEntry = ofMatch.getAugmentation(MetadataMatchEntry.class);
                 if(metadataMatchEntry != null){
-                    metadataBuilder.setMetadata(new BigInteger(metadataMatchEntry.getMetadata()));
+                    metadataBuilder.setMetadata(new BigInteger(1, metadataMatchEntry.getMetadata()));
                     MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
                     if(maskMatchEntry != null){
                         metadataBuilder.setMetadataMask(maskMatchEntry.getMask());
@@ -823,7 +824,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
                 TunnelBuilder tunnelBuilder = new TunnelBuilder();
                 MetadataMatchEntry metadataMatchEntry = ofMatch.getAugmentation(MetadataMatchEntry.class);
                 if(metadataMatchEntry != null){
-                    tunnelBuilder.setTunnelId(new BigInteger(metadataMatchEntry.getMetadata()));
+                    tunnelBuilder.setTunnelId(new BigInteger(1, metadataMatchEntry.getMetadata()));
                     MaskMatchEntry maskMatchEntry = ofMatch.getAugmentation(MaskMatchEntry.class);
                     if(maskMatchEntry != null){
                         tunnelBuilder.setTunnelMask(maskMatchEntry.getMask());
@@ -1089,7 +1090,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntries>> {
         matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
         matchEntriesBuilder.setOxmMatchField(VlanVid.class);
         VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
-        if (vlanId.isVlanIdPresent() == true) {
+        if (vlanId.isVlanIdPresent() == Boolean.TRUE) {
             setCfiBit = true;
             if (vlanId.getVlanId() != null) {
                 vidEntryValue = vlanId.getVlanId().getValue();