updated to tp_src, nw_tos match issue and setting actionslist for OF1.0, 09/3809/2
authorAnilGujele <angujele@in.ibm.com>
Wed, 18 Dec 2013 05:39:33 +0000 (11:09 +0530)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 19 Dec 2013 08:10:34 +0000 (08:10 +0000)
updated test cases also.

Change-Id: I29d4f7d6a3d7d49219fbe8ea07cc75462fb95c1c
Signed-off-by: AnilGujele <angujele@in.ibm.com>
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertorV10Impl.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java

index cfd8cebe1283be6a88d8f2bf3b6f44a3f713e7e6..b0cbfb0a8d5482433a77a2871cfe212b4f1ca4cf 100644 (file)
@@ -15,6 +15,7 @@ import java.util.List;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag.FlowFlagReactor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.ActionList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow;
@@ -39,6 +40,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.InstructionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
@@ -163,8 +165,10 @@ public class FlowConvertor {
 
         if (flow.getInstructions() != null) {
             flowMod.setInstructions(toInstructions(flow.getInstructions(), version));
+            flowMod.setActionsList(getActionsList(flow.getInstructions(), version));
         }
         flowMod.setVersion(version);
+        
         return flowMod.build();
     }
 
@@ -252,4 +256,23 @@ public class FlowConvertor {
         }
         return instructionsList;
     }
+    
+    private static List<ActionsList> getActionsList(
+            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions instructions,
+            short version) {
+
+        for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : instructions
+                .getInstruction()) {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction
+                    .getInstruction();
+
+            if (curInstruction instanceof ApplyActionsCase) {
+                ApplyActionsCase applyActionscase = (ApplyActionsCase) curInstruction;
+                ApplyActions applyActions = applyActionscase.getApplyActions();
+                return ActionConvertor.getActionList(applyActions.getAction(), version);
+            }
+
+        }
+        return null;
+    }
 }
\ No newline at end of file
index df2fed4d5ca0ea7636175c49920a957c0afbf61d..6fe6ba3bd0d64dac338a488270254d684746f187 100644 (file)
@@ -177,9 +177,9 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
             TcpMatch tcpMatch) {
         if (tcpMatch.getTcpSourcePort() != null) {
             matchBuilder.setTpSrc(tcpMatch.getTcpSourcePort().getValue());
-            return true;
+            return false;
         }
-        return false;
+        return true;
     }
 
     /**
@@ -191,9 +191,9 @@ public class MatchConvertorV10Impl implements MatchConvertor<MatchV10> {
             IpMatch ipMatch) {
         if (ipMatch.getIpDscp() != null) {
             matchBuilder.setNwTos(ipMatch.getIpDscp().getValue());
-            return true;
+            return false;
         }
-        return false;
+        return true;
     }
 
     /**
index c7731a6c36f52119601391296324b903cbecc6c0..6e732995728b5a31b1a354ebe68c47fbd7953403 100644 (file)
@@ -463,25 +463,23 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
             flow.setMatch(createVlanMatch().build());
             flow.setInstructions(createMeterInstructions().build());
             break;
-
         case "f50":
             id += 50;
             flow.setMatch(createPbbMatch().build());
             flow.setInstructions(createMeterInstructions().build());
             break;
-        case "51":
+        case "f51":
             id += 51;
-            flow.setMatch(createIPMatch().build());
+            flow.setMatch(createVlanMatch().build());
             flow.setInstructions(createDropInstructions().build());
             break;
-    
-        case "52":
+        case "f52":
             id += 52;
             flow.setMatch(createL4TCPMatch().build());
             flow.setInstructions(createDropInstructions().build());
             break;    
             
-        case "53":
+        case "f53":
             id += 53;
             flow.setMatch(createL4UDPMatch().build());
             flow.setInstructions(createDropInstructions().build());
@@ -491,6 +489,13 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
             flow.setMatch(new MatchBuilder().build());
             flow.setInstructions(createSentToControllerInstructions().build());
             break;
+        case "f55":
+            id += 55;
+            flow.setMatch(createToSMatch().build());
+            flow.setInstructions(createDropInstructions().build());
+            break;
+        
         default:
             LOG.warn("flow type not understood: {}", flowType);
         }
@@ -1852,6 +1857,26 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider {
 
         return match;
     }
+    
+    /**
+     * @return
+     */
+    private static MatchBuilder createToSMatch() {
+        MatchBuilder match = new MatchBuilder();
+        EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
+        EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
+        EtherType type = new EtherType(0x0800L);
+        ethmatch.setEthernetType(ethtype.setType(type).build());
+        match.setEthernetMatch(ethmatch.build());
+
+        IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+        ipmatch.setIpProtocol((short) 6);
+        Dscp dscp = new Dscp((short) 8);
+        ipmatch.setIpDscp(dscp);
+        match.setIpMatch(ipmatch.build());
+        return match;
+    }
+
 
     /**
      * @return