Merge branch 'master' into funnel

Conflicts:
	java_gen/java_type.py
	java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/DatapathId.java
diff --git a/c_gen/templates/locitest/Makefile b/c_gen/templates/locitest/Makefile
index ed4ba13..a7a6f37 100644
--- a/c_gen/templates/locitest/Makefile
+++ b/c_gen/templates/locitest/Makefile
@@ -10,3 +10,6 @@
 
 locitest: $(OBJS)
 	$(CC) $^ -o $@
+
+# BSN build system magic
+MODULE := locitest
diff --git a/java_gen/java_model.py b/java_gen/java_model.py
index d07ddaf..f2191c0 100644
--- a/java_gen/java_model.py
+++ b/java_gen/java_model.py
@@ -49,7 +49,7 @@
 class JavaModel(object):
     # registry for enums that should not be generated
     # set(${java_enum_name})
-    enum_blacklist = set(("OFDefinitions", "OFPortNo", "OFVlanId"))
+    enum_blacklist = set(("OFDefinitions", "OFPortNo", "OFVlanId", "OFGroup"))
     # registry for enum *entry* that should not be generated
     # map: ${java_enum_name} -> set(${java_entry_entry_name})
     enum_entry_blacklist = defaultdict(lambda: set(), OFFlowWildcards=set([ "NW_DST_BITS", "NW_SRC_BITS", "NW_SRC_SHIFT", "NW_DST_SHIFT" ]))
@@ -926,6 +926,8 @@
                 name = 'length'
             elif member.name == 'value_mask':
                 name = 'mask'
+            elif member.name == 'group_id':
+                name = 'group'
             else:
                 name = java_type.name_c_to_camel(member.name)
             j_type = java_type.convert_to_jtype(java_class.c_name, member.name, member.oftype)
diff --git a/java_gen/java_type.py b/java_gen/java_type.py
index 907e8c8..331aeea 100644
--- a/java_gen/java_type.py
+++ b/java_gen/java_type.py
@@ -455,6 +455,13 @@
             write='ChannelUtilsVer10.writeSupportedActions(bb, $name)',
             default='ImmutableSet.<OFActionType>of()',
             funnel='ChannelUtilsVer10.putSupportedActionsTo($name, sink)')
+of_group = JType("OFGroup") \
+         .op(version=ANY, read="OFGroup.read4Bytes(bb)", write="$name.write4Bytes(bb)", default="OFGroup.ALL")
+# the outgroup field of of_flow_stats_request has a special default value
+of_group_default_any = JType("OFGroup") \
+         .op(version=ANY, read="OFGroup.read4Bytes(bb)", write="$name.write4Bytes(bb)", default="OFGroup.ANY")
+buffer_id = JType("OFBufferId") \
+         .op(read="OFBufferId.of(bb.readInt())", write="bb.writeInt($name.getInt())", default="OFBufferId.NO_BUFFER")
 
 generic_t = JType("T")
 
@@ -553,6 +560,8 @@
                 },
         'of_bsn_set_l2_table_request': { 'l2_table_enable': boolean },
         'of_bsn_set_l2_table_reply': { 'l2_table_enable': boolean },
+        'of_bsn_set_pktin_suppression_request': { 'enabled': boolean },
+        'of_flow_stats_request': { 'out_group': of_group_default_any },
 }
 
 
@@ -607,6 +616,8 @@
         return of_version
     elif field_name == "buffer_id" and c_type == "uint32_t":
         return buffer_id
+    elif field_name == "group_id" and c_type == "uint32_t":
+        return of_group
     elif field_name == 'datapath_id':
         return datapath_id
     elif field_name == 'actions' and obj_name == 'of_features_reply':
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/DatapathId.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/DatapathId.java
index 42f5c1c..1908d28 100644
--- a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/DatapathId.java
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/DatapathId.java
@@ -3,6 +3,7 @@
 import org.projectfloodlight.openflow.util.HexString;
 
 import com.google.common.hash.PrimitiveSink;
+import com.google.common.primitives.Longs;
 import com.google.common.primitives.UnsignedLongs;
 
 /**
@@ -29,6 +30,10 @@
         return new DatapathId(HexString.toLong(s));
     }
 
+    public static DatapathId of(byte[] bytes) {
+        return new DatapathId(Longs.fromByteArray(bytes));
+    }
+
     public long getLong() {
         return rawValue;
     }
@@ -37,6 +42,10 @@
         return U64.of(rawValue);
     }
 
+    public byte[] getBytes() {
+        return Longs.toByteArray(rawValue);
+    }
+
     @Override
     public String toString() {
         return HexString.toHexString(rawValue);
@@ -69,6 +78,7 @@
         sink.putLong(rawValue);
     }
 
+    @Override
     public int compareTo(DatapathId o) {
         return UnsignedLongs.compare(rawValue, o.rawValue);
     }
diff --git a/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFGroup.java b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFGroup.java
new file mode 100644
index 0000000..d522202
--- /dev/null
+++ b/java_gen/pre-written/src/main/java/org/projectfloodlight/openflow/types/OFGroup.java
@@ -0,0 +1,163 @@
+package org.projectfloodlight.openflow.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.projectfloodlight.openflow.annotations.Immutable;
+import org.projectfloodlight.openflow.exceptions.OFParseError;
+
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.primitives.UnsignedInts;
+
+/**
+ * Abstraction of an logical / OpenFlow group (ofp_group) in OpenFlow.
+ * Immutable.
+ *
+ * @author Andreas Wundsam <andreas.wundsam@bigswitch.com>
+ */
+@Immutable
+public class OFGroup implements OFValueType<OFGroup> {
+    static final int LENGTH = 4;
+
+    // private int constants (OF1.1+) to avoid duplication in the code
+    // should not have to use these outside this class
+    private static final int ZERO_VAL = 0x00;
+    private static final int MAX_VAL = 0xffffff00;
+    private static final int ALL_VAL = 0xfffffffc;
+    private static final int ANY_VAL = 0xffffffff;
+
+
+    // ////////////// public constants - use to access well known OpenFlow ports
+
+    /** Maximum number of physical and logical switch ports. */
+    public final static OFGroup MAX = new NamedGroup(MAX_VAL, "max");
+
+    /**
+     * Send the packet out the input port. This reserved port must be explicitly
+     * used in order to send back out of the input port.
+     */
+    public final static OFGroup ALL = new NamedGroup(ALL_VAL, "all");
+
+    /**
+     * Wildcard group used only for flow mod (delete) and flow stats requests.
+     * Selects all flows regardless of output port (including flows with no
+     * output port). NOTE: OpenFlow 1.0 calls this 'NONE'
+     */
+    public final static OFGroup ANY = new NamedGroup(ANY_VAL, "any");
+
+    /** group 0 in case we need it
+     */
+    public static final OFGroup ZERO = OFGroup.of(ZERO_VAL);
+
+    public static final OFGroup NO_MASK = ANY;
+    public static final OFGroup FULL_MASK = ZERO;
+
+    /** raw openflow port number as a signed 32 bit integer */
+    private final int groupNumber;
+
+    /** private constructor. use of*-Factory methods instead */
+    private OFGroup(final int portNumber) {
+        this.groupNumber = portNumber;
+    }
+
+    /**
+     * get an OFPort object corresponding to a raw 32-bit integer port number.
+     * NOTE: The port object may either be newly allocated or cached. Do not
+     * rely on either behavior.
+     *
+     * @param portNumber
+     * @return a corresponding OFPort
+     */
+    public static OFGroup of(final int groupNumber) {
+        switch(groupNumber) {
+            case ZERO_VAL:
+                return MAX;
+            case MAX_VAL:
+                return MAX;
+            case ALL_VAL:
+                return ALL;
+            case ANY_VAL:
+                return ANY;
+            default:
+                if(UnsignedInts.compare(groupNumber, MAX_VAL) > 0) {
+                    // greater than max_val, but not one of the reserved values
+                    throw new IllegalArgumentException("Unknown special group number: "
+                            + groupNumber);
+                }
+                return new OFGroup(groupNumber);
+        }
+    }
+
+    /** return the port number as a int32 */
+    public int getGroupNumber() {
+        return groupNumber;
+    }
+
+    @Override
+    public String toString() {
+        return UnsignedInts.toString(groupNumber);
+    }
+
+    /** Extension of OFPort for named groups */
+    static class NamedGroup extends OFGroup {
+        private final String name;
+
+        NamedGroup(final int portNo, final String name) {
+            super(portNo);
+            this.name = name;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public String toString() {
+            return name;
+        }
+    }
+
+    @Override
+    public int getLength() {
+        return LENGTH;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof OFGroup))
+            return false;
+        OFGroup other = (OFGroup)obj;
+        if (other.groupNumber != this.groupNumber)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 53;
+        int result = 1;
+        result = prime * result + groupNumber;
+        return result;
+    }
+
+    public void write4Bytes(ChannelBuffer c) {
+        c.writeInt(this.groupNumber);
+    }
+
+    public static OFGroup read4Bytes(ChannelBuffer c) throws OFParseError {
+        return OFGroup.of(c.readInt());
+    }
+
+    @Override
+    public OFGroup applyMask(OFGroup mask) {
+        return OFGroup.of(this.groupNumber & mask.groupNumber);
+    }
+
+    @Override
+    public int compareTo(OFGroup o) {
+        return UnsignedInts.compare(this.groupNumber, o.groupNumber);
+    }
+
+    @Override
+    public void putTo(PrimitiveSink sink) {
+        sink.putInt(groupNumber);
+    }
+}
diff --git a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/MacAddressTest.java b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/MacAddressTest.java
index ed380ee..3ccceb3 100644
--- a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/MacAddressTest.java
+++ b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/MacAddressTest.java
@@ -84,7 +84,7 @@
         for(String invalid : invalidMacStrings) {
             try {
                 MacAddress.of(invalid);
-                fail("Invalid IP "+invalid+ " should have raised IllegalArgumentException");
+                fail("Invalid MAC address "+invalid+ " should have raised IllegalArgumentException");
             } catch(IllegalArgumentException e) {
                 // ok
             }
@@ -96,7 +96,7 @@
         for(byte[] invalid : invalidMacBytes) {
             try {
                 MacAddress.of(invalid);
-                fail("Invalid IP "+invalid+ " should have raised IllegalArgumentException");
+                fail("Invalid MAC address bytes "+ Arrays.toString(invalid) + " should have raised IllegalArgumentException");
             } catch(IllegalArgumentException e) {
                 // ok
             }
diff --git a/java_gen/templates/of_factories.java b/java_gen/templates/of_factories.java
index 0a27c59..f8c9a80 100644
--- a/java_gen/templates/of_factories.java
+++ b/java_gen/templates/of_factories.java
@@ -37,7 +37,7 @@
 
 public final class OFFactories {
 
-    private final static GenericReader GENERIC_READER = new GenericReader();
+    private static final GenericReader GENERIC_READER = new GenericReader();
 
     public static OFFactory getFactory(OFVersion version) {
         switch(version) {
diff --git a/openflow_input/standard-1.0 b/openflow_input/standard-1.0
index 79d5bad..ad2e76f 100644
--- a/openflow_input/standard-1.0
+++ b/openflow_input/standard-1.0
@@ -211,6 +211,10 @@
     OFPFF_EMERG = 0x4,
 };
 
+enum ofp_stats_request_flags(wire_type=uint16_t, bitmask=True) {
+};
+
+
 enum ofp_stats_reply_flags(wire_type=uint16_t, bitmask=True) {
     OFPSF_REPLY_MORE = 0x1,
 };
@@ -825,7 +829,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == ?;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
 };
 
 struct of_stats_reply : of_header {
@@ -834,7 +838,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == ?;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
 };
 
 struct of_desc_stats_request : of_stats_request {
@@ -843,7 +847,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
 };
 
 struct of_desc_stats_reply : of_stats_reply {
@@ -852,7 +856,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     of_desc_str_t mfr_desc;
     of_desc_str_t hw_desc;
     of_desc_str_t sw_desc;
@@ -866,7 +870,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 1;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     of_match_t match;
     uint8_t table_id;
     pad(1);
@@ -879,7 +883,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 1;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     list(of_flow_stats_entry_t) entries;
 };
 
@@ -889,7 +893,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 2;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     of_match_t match;
     uint8_t table_id;
     pad(1);
@@ -902,7 +906,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 2;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     uint64_t packet_count;
     uint64_t byte_count;
     uint32_t flow_count;
@@ -915,7 +919,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 3;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
 };
 
 struct of_table_stats_reply : of_stats_reply {
@@ -924,7 +928,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 3;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     list(of_table_stats_entry_t) entries;
 };
 
@@ -934,7 +938,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 4;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     of_port_no_t port_no;
     pad(6);
 };
@@ -945,7 +949,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 4;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     list(of_port_stats_entry_t) entries;
 };
 
@@ -955,7 +959,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 5;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     of_port_no_t port_no;
     pad(2);
     uint32_t queue_id;
@@ -967,7 +971,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 5;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     list(of_queue_stats_entry_t) entries;
 };
 
@@ -977,7 +981,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0xffff;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     uint32_t experimenter == ?;
     of_octets_t data;
 };
@@ -988,7 +992,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0xffff;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     uint32_t experimenter == ?;
     of_octets_t data;
 };
diff --git a/openflow_input/standard-1.1 b/openflow_input/standard-1.1
index 9937c6d..a6f511f 100644
--- a/openflow_input/standard-1.1
+++ b/openflow_input/standard-1.1
@@ -399,6 +399,11 @@
     OFPST_EXPERIMENTER = 0xffff,
 };
 
+// none defined
+enum ofp_stats_request_flags(wire_type=uint16_t, bitmask=True) {
+};
+
+
 enum ofp_stats_reply_flags(wire_type=uint16_t, bitmask=True) {
     OFPSF_REPLY_MORE = 0x1,
 };
@@ -1217,7 +1222,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == ?;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1227,7 +1232,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == ?;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
 };
 
@@ -1237,7 +1242,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1247,7 +1252,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     of_desc_str_t mfr_desc;
     of_desc_str_t hw_desc;
@@ -1262,7 +1267,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 1;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     uint8_t table_id;
     pad(3);
@@ -1280,7 +1285,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 1;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_flow_stats_entry_t) entries;
 };
@@ -1291,7 +1296,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 2;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     uint8_t table_id;
     pad(3);
@@ -1309,7 +1314,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 2;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     uint64_t packet_count;
     uint64_t byte_count;
@@ -1323,7 +1328,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 3;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1333,7 +1338,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 3;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_table_stats_entry_t) entries;
 };
@@ -1344,7 +1349,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 4;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     of_port_no_t port_no;
     pad(4);
@@ -1356,7 +1361,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 4;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_port_stats_entry_t) entries;
 };
@@ -1367,7 +1372,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 5;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     of_port_no_t port_no;
     uint32_t queue_id;
@@ -1379,7 +1384,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 5;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_queue_stats_entry_t) entries;
 };
@@ -1390,7 +1395,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 6;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     uint32_t group_id;
     pad(4);
@@ -1402,7 +1407,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 6;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_group_stats_entry_t) entries;
 };
@@ -1413,7 +1418,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 7;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1423,7 +1428,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 7;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_group_desc_stats_entry_t) entries;
 };
@@ -1434,7 +1439,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0xffff;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     uint32_t experimenter == ?;
     pad(4);
@@ -1447,7 +1452,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0xffff;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     uint32_t experimenter == ?;
     pad(4);
diff --git a/openflow_input/standard-1.2 b/openflow_input/standard-1.2
index 182794e..a804643 100644
--- a/openflow_input/standard-1.2
+++ b/openflow_input/standard-1.2
@@ -424,6 +424,9 @@
     OFPST_EXPERIMENTER = 0xffff,
 };
 
+enum ofp_stats_request_flags(wire_type=uint16_t, bitmask=True) {
+};
+
 enum ofp_stats_reply_flags(wire_type=uint16_t, bitmask=True) {
     OFPSF_REPLY_MORE = 0x1,
 };
@@ -1187,7 +1190,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == ?;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1197,7 +1200,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == ?;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
 };
 
@@ -1207,7 +1210,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1217,7 +1220,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     of_desc_str_t mfr_desc;
     of_desc_str_t hw_desc;
@@ -1232,7 +1235,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 1;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     uint8_t table_id;
     pad(3);
@@ -1250,7 +1253,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 1;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_flow_stats_entry_t) entries;
 };
@@ -1261,7 +1264,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 2;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     uint8_t table_id;
     pad(3);
@@ -1279,7 +1282,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 2;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     uint64_t packet_count;
     uint64_t byte_count;
@@ -1293,7 +1296,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 3;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1303,7 +1306,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 3;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_table_stats_entry_t) entries;
 };
@@ -1314,7 +1317,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 4;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     of_port_no_t port_no;
     pad(4);
@@ -1326,7 +1329,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 4;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_port_stats_entry_t) entries;
 };
@@ -1337,7 +1340,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 5;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     of_port_no_t port_no;
     uint32_t queue_id;
@@ -1349,7 +1352,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 5;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_queue_stats_entry_t) entries;
 };
@@ -1360,7 +1363,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 6;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     uint32_t group_id;
     pad(4);
@@ -1372,7 +1375,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 6;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_group_stats_entry_t) entries;
 };
@@ -1383,7 +1386,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 7;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1393,7 +1396,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 7;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_group_desc_stats_entry_t) entries;
 };
@@ -1404,7 +1407,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 8;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1414,7 +1417,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 8;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     uint32_t types;
     uint32_t capabilities;
@@ -1434,7 +1437,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0xffff;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     uint32_t experimenter == ?;
     uint32_t subtype;
@@ -1447,7 +1450,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0xffff;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     uint32_t experimenter == ?;
     uint32_t subtype;
@@ -1519,7 +1522,7 @@
     uint8_t type == 24;
     uint16_t length;
     uint32_t xid;
-    uint32_t role;
+    enum ofp_controller_role role;
     pad(4);
     uint64_t generation_id;
 };
@@ -1529,5 +1532,7 @@
     uint8_t type == 25;
     uint16_t length;
     uint32_t xid;
-    of_octets_t data;
+    enum ofp_controller_role role;
+    pad(4);
+    uint64_t generation_id;
 };
diff --git a/openflow_input/standard-1.3 b/openflow_input/standard-1.3
index 9d53f11..29e6c76 100644
--- a/openflow_input/standard-1.3
+++ b/openflow_input/standard-1.3
@@ -1402,7 +1402,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == ?;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1412,7 +1412,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == ?;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
 };
 
@@ -1422,7 +1422,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1432,7 +1432,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 0;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     of_desc_str_t mfr_desc;
     of_desc_str_t hw_desc;
@@ -1447,7 +1447,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 1;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     uint8_t table_id;
     pad(3);
@@ -1465,7 +1465,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 1;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_flow_stats_entry_t) entries;
 };
@@ -1476,7 +1476,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 2;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     uint8_t table_id;
     pad(3);
@@ -1494,7 +1494,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 2;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     uint64_t packet_count;
     uint64_t byte_count;
@@ -1508,7 +1508,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 3;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1518,7 +1518,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 3;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_table_stats_entry_t) entries;
 };
@@ -1659,7 +1659,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 4;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     of_port_no_t port_no;
     pad(4);
@@ -1671,7 +1671,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 4;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_port_stats_entry_t) entries;
 };
@@ -1682,7 +1682,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 5;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     of_port_no_t port_no;
     uint32_t queue_id;
@@ -1694,7 +1694,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 5;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_queue_stats_entry_t) entries;
 };
@@ -1705,7 +1705,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 6;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     uint32_t group_id;
     pad(4);
@@ -1717,7 +1717,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 6;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_group_stats_entry_t) entries;
 };
@@ -1728,7 +1728,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 7;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1738,7 +1738,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 7;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_group_desc_stats_entry_t) entries;
 };
@@ -1749,7 +1749,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 8;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1759,7 +1759,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 8;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     uint32_t types;
     uint32_t capabilities;
@@ -1779,7 +1779,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 9;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     uint32_t meter_id;
     pad(4);
@@ -1791,7 +1791,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 9;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_meter_stats_t) entries;
 };
@@ -1802,7 +1802,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 10;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     uint32_t meter_id;
     pad(4);
@@ -1814,7 +1814,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 10;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_meter_band_t) entries;
 };
@@ -1826,7 +1826,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 11;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1837,7 +1837,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 11;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     of_meter_features_t features;
 };
@@ -1849,7 +1849,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 12;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
     list(of_table_features_t) entries;
 };
@@ -1861,7 +1861,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 12;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_table_features_t) entries;
 };
@@ -1873,7 +1873,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 13;
-    uint16_t flags;
+    enum ofp_stats_request_flags flags;
     pad(4);
 };
 
@@ -1884,7 +1884,7 @@
     uint16_t length;
     uint32_t xid;
     uint16_t stats_type == 13;
-    uint16_t flags;
+    enum ofp_stats_reply_flags flags;
     pad(4);
     list(of_port_desc_t) entries;
 };
@@ -1983,7 +1983,7 @@
     uint8_t type == 24;
     uint16_t length;
     uint32_t xid;
-    uint32_t role;
+    enum ofp_controller_role role;
     pad(4);
     uint64_t generation_id;
 };
@@ -1993,7 +1993,9 @@
     uint8_t type == 25;
     uint16_t length;
     uint32_t xid;
-    of_octets_t data;
+    enum ofp_controller_role role;
+    pad(4);
+    uint64_t generation_id;
 };
 
 ////////////////////////////////////////////////////////////////