Bug-835 - Reserve Ports should be logical ports
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / FlowStatsResponseConvertor.java
index 3aa10487fddceb12be0c67da284cc5ab5aaff227..c9e224bafc44fddd51226d28bd990a250806dbbb 100644 (file)
@@ -7,19 +7,21 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowVersion;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
 
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * Class is an utility class for converting flow related statistics messages coming from openflow 
  * switch to MD-SAL messages.
@@ -34,12 +36,12 @@ public class FlowStatsResponseConvertor {
      * @param allFlowStats
      * @return
      */
-    public List<FlowAndStatisticsMapList> toSALFlowStatsList(List<FlowStats> allFlowStats,BigInteger datapathid){
+    public List<FlowAndStatisticsMapList> toSALFlowStatsList(List<FlowStats> allFlowStats, BigInteger datapathid, OpenflowVersion ofVersion){
         
         List<FlowAndStatisticsMapList> convertedSALFlowStats = new ArrayList<FlowAndStatisticsMapList>();
         
         for(FlowStats flowStats : allFlowStats){
-            convertedSALFlowStats.add(toSALFlowStats(flowStats, datapathid));
+            convertedSALFlowStats.add(toSALFlowStats(flowStats, datapathid, ofVersion));
         }
         
         return convertedSALFlowStats;
@@ -51,10 +53,10 @@ public class FlowStatsResponseConvertor {
      * @param flowStats
      * @return
      */
-    public FlowAndStatisticsMapList toSALFlowStats(FlowStats flowStats,BigInteger datapathid){
+    public FlowAndStatisticsMapList toSALFlowStats(FlowStats flowStats, BigInteger datapathid, OpenflowVersion ofVersion){
         FlowAndStatisticsMapListBuilder salFlowStatsBuilder = new FlowAndStatisticsMapListBuilder();
         salFlowStatsBuilder.setByteCount(new Counter64(flowStats.getByteCount()));
-        salFlowStatsBuilder.setCookie(flowStats.getCookie());
+        salFlowStatsBuilder.setCookie(new FlowCookie(flowStats.getCookie()));
 
         DurationBuilder time = new DurationBuilder();
         time.setSecond(new Counter32(flowStats.getDurationSec()));
@@ -67,13 +69,13 @@ public class FlowStatsResponseConvertor {
         salFlowStatsBuilder.setPriority(flowStats.getPriority());
         salFlowStatsBuilder.setTableId(flowStats.getTableId());
         if(flowStats.getMatchV10() != null){
-            salFlowStatsBuilder.setMatch(MatchConvertorImpl.fromOFMatchV10ToSALMatch(flowStats.getMatchV10(),datapathid));
-            if(flowStats.getActionsList().size()!=0){
-                salFlowStatsBuilder.setInstructions(OFToMDSalFlowConvertor.wrapOF10ActionsToInstruction(flowStats.getActionsList()));
+            salFlowStatsBuilder.setMatch(MatchConvertorImpl.fromOFMatchV10ToSALMatch(flowStats.getMatchV10(),datapathid, OpenflowVersion.OF10));
+            if(flowStats.getAction().size()!=0){
+                salFlowStatsBuilder.setInstructions(OFToMDSalFlowConvertor.wrapOF10ActionsToInstruction(flowStats.getAction(), ofVersion));
             }
         }
         if(flowStats.getMatch() != null){
-            salFlowStatsBuilder.setMatch(MatchConvertorImpl.fromOFMatchToSALMatch(flowStats.getMatch(),datapathid));
+            salFlowStatsBuilder.setMatch(MatchConvertorImpl.fromOFMatchToSALMatch(flowStats.getMatch(),datapathid, ofVersion));
             salFlowStatsBuilder.setFlags(
                     new FlowModFlags(flowStats.getFlags().isOFPFFCHECKOVERLAP(),
                             flowStats.getFlags().isOFPFFRESETCOUNTS(),
@@ -81,8 +83,8 @@ public class FlowStatsResponseConvertor {
                             flowStats.getFlags().isOFPFFNOBYTCOUNTS(),
                             flowStats.getFlags().isOFPFFSENDFLOWREM()));
         }
-        if(flowStats.getInstructions()!= null){
-            salFlowStatsBuilder.setInstructions(OFToMDSalFlowConvertor.toSALInstruction(flowStats.getInstructions()));
+        if(flowStats.getInstruction()!= null){
+            salFlowStatsBuilder.setInstructions(OFToMDSalFlowConvertor.toSALInstruction(flowStats.getInstruction(), ofVersion));
         }
         
         return salFlowStatsBuilder.build();