Added couple of codec classes for table feature property,group feature and group...
[openflowjava.git] / third-party / openflow-codec / src / main / java / org / openflow / codec / protocol / OFPGroupMod.java
index e1cfdb439b782b00441115e5edecd1c0dc7c5d33..9dadf0a64eb4f81f3beba60ad61936364b160221 100644 (file)
@@ -6,6 +6,8 @@ import java.util.List;
 
 import org.openflow.codec.io.IDataBuffer;
 import org.openflow.codec.protocol.action.OFPBucket;
+import org.openflow.codec.protocol.factory.OFPActionFactory;
+import org.openflow.codec.protocol.factory.OFPActionFactoryAware;
 import org.openflow.codec.util.U16;
 
 /**
@@ -14,18 +16,23 @@ import org.openflow.codec.util.U16;
  * @author Yugandhar Sarraju (ysarraju@in.ibm.com)
  *
  */
-public class OFPGroupMod extends OFPMessage implements Cloneable {
+public class OFPGroupMod extends OFPMessage implements OFPActionFactoryAware, Cloneable {
     public static int MINIMUM_LENGTH = 16;
 
     public static final short OFPGC_ADD = 0; /* New group. */
     public static final short OFPGC_MODIFY = 1; /* Modify all matching groups. */
     public static final short OFPGC_DELETE = 2; /* Delete all matching groups. */
 
-    public static final short OFPGT_ALL = 0; /* All (multicast/broadcast) group. */
-    public static final short OFPGT_SELECT = 1; /* Select group. */
-    public static final short OFPGT_INDIRECT = 2; /* Indirect group. */
-    public static final short OFPGT_FF = 3; /* Fast failover group. */
+    public static final byte OFPGT_ALL = 0; /* All (multicast/broadcast) group. */
+    public static final byte OFPGT_SELECT = 1; /* Select group. */
+    public static final byte OFPGT_INDIRECT = 2; /* Indirect group. */
+    public static final byte OFPGT_FF = 3; /* Fast failover group. */
 
+    public static final int OFPG_MAX = (int) 0xffffff00;
+    public static final int OFPG_ALL = (int) 0xfffffffc;
+    public static final int OFPG_ANY = (int) 0xffffffff;
+
+    protected OFPActionFactory actionFactory;
     protected short groupCommand;
     protected byte groupType;
     protected int group_id;
@@ -94,10 +101,10 @@ public class OFPGroupMod extends OFPMessage implements Cloneable {
         } else {
             this.buckets.clear();
         }
-        int bucketCount = (super.getLengthU() - 16) / OFPBucket.MINIMUM_LENGTH;
         OFPBucket bucket;
-        for (int i = 0; i < bucketCount; ++i) {
+        while (data.remaining() > 0) {
             bucket = new OFPBucket();
+            bucket.setActionFactory(actionFactory);
             bucket.readFrom(data);
             this.buckets.add(bucket);
         }
@@ -189,4 +196,10 @@ public class OFPGroupMod extends OFPMessage implements Cloneable {
         return "OFPGroupMod [ buckets=" + buckets + ", groupCommand=" + groupCommand + ", groupType=" + groupType
                 + ", group_id=" + group_id + "]";
     }
+
+    @Override
+    public void setActionFactory(OFPActionFactory actionFactory) {
+        this.actionFactory = actionFactory;
+
+    }
 }